@Test void GetIngestionResource_TempStorage_VerifyRoundRubin() throws IngestionServiceException, IngestionClientException { List<String> availableStorages = new ArrayList<>(Arrays.asList(STORAGE_1, STORAGE_2)); String storage = resourceManager.getIngestionResource(ResourceManager.ResourceType.TEMP_STORAGE); int lastIndex = availableStorages.indexOf(storage); for (int i = 0; i < 10; i++) { storage = resourceManager.getIngestionResource(ResourceManager.ResourceType.TEMP_STORAGE); int currIdx = availableStorages.indexOf(storage); assertEquals((lastIndex + 1) % availableStorages.size(), currIdx); lastIndex = currIdx; } }
String getIngestionResource(ResourceType resourceType) throws IngestionServiceException, IngestionClientException { if (!ingestionResources.containsKey(resourceType)) { refreshIngestionResources(); try { ingestionResourcesLock.readLock().lock(); if (!ingestionResources.containsKey(resourceType)) { throw new IngestionServiceException("Unable to get ingestion resources for this type: " + resourceType.getName()); } } finally { ingestionResourcesLock.readLock().unlock(); } } return ingestionResources.get(resourceType).nextValue(); }
ResourceManager implements Closeable { String getIngestionResource(ResourceType resourceType) throws IngestionServiceException, IngestionClientException { if (!ingestionResources.containsKey(resourceType)) { refreshIngestionResources(); try { ingestionResourcesLock.readLock().lock(); if (!ingestionResources.containsKey(resourceType)) { throw new IngestionServiceException("Unable to get ingestion resources for this type: " + resourceType.getName()); } } finally { ingestionResourcesLock.readLock().unlock(); } } return ingestionResources.get(resourceType).nextValue(); } }
ResourceManager implements Closeable { String getIngestionResource(ResourceType resourceType) throws IngestionServiceException, IngestionClientException { if (!ingestionResources.containsKey(resourceType)) { refreshIngestionResources(); try { ingestionResourcesLock.readLock().lock(); if (!ingestionResources.containsKey(resourceType)) { throw new IngestionServiceException("Unable to get ingestion resources for this type: " + resourceType.getName()); } } finally { ingestionResourcesLock.readLock().unlock(); } } return ingestionResources.get(resourceType).nextValue(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); }
ResourceManager implements Closeable { String getIngestionResource(ResourceType resourceType) throws IngestionServiceException, IngestionClientException { if (!ingestionResources.containsKey(resourceType)) { refreshIngestionResources(); try { ingestionResourcesLock.readLock().lock(); if (!ingestionResources.containsKey(resourceType)) { throw new IngestionServiceException("Unable to get ingestion resources for this type: " + resourceType.getName()); } } finally { ingestionResourcesLock.readLock().unlock(); } } return ingestionResources.get(resourceType).nextValue(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); @Override void close(); }
ResourceManager implements Closeable { String getIngestionResource(ResourceType resourceType) throws IngestionServiceException, IngestionClientException { if (!ingestionResources.containsKey(resourceType)) { refreshIngestionResources(); try { ingestionResourcesLock.readLock().lock(); if (!ingestionResources.containsKey(resourceType)) { throw new IngestionServiceException("Unable to get ingestion resources for this type: " + resourceType.getName()); } } finally { ingestionResourcesLock.readLock().unlock(); } } return ingestionResources.get(resourceType).nextValue(); } ResourceManager(Client client, long defaultRefreshTime, long refreshTimeOnFailure);   ResourceManager(Client client); @Override void close();  }