@Test public void testDatastreamExists() throws Exception { Datastream datastream = generateDatastream(1111); DatastreamRestClient restClient = createRestClient(); restClient.createDatastream(datastream); Assert.assertNotNull(restClient.waitTillDatastreamIsInitialized(datastream.getName(), WAIT_TIMEOUT_MS)); Assert.assertTrue(restClient.datastreamExists(datastream.getName())); Assert.assertFalse(restClient.datastreamExists("No Such Datastream")); }
public boolean datastreamExists(String datastreamName) { return PollUtils.poll(() -> { try { doGetDatastream(datastreamName); return Boolean.TRUE; } catch (RemoteInvocationException e) { if (ExceptionUtils.getRootCause(e) instanceof TimeoutException) { LOG.warn("Timeout: datastreamExists. May retry...", e); return null; } if (isNotFoundHttpStatus(e)) { LOG.debug("Datastream {} is not found", datastreamName); } else { String errorMessage = String.format("Get Datastream %s failed with error.", datastreamName); ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } } return Boolean.FALSE; }, Objects::nonNull, getRetryPeriodMs(), getRetryTimeoutMs()).orElseThrow(RetriesExhaustedException::new); }
DatastreamRestClient { public boolean datastreamExists(String datastreamName) { return PollUtils.poll(() -> { try { doGetDatastream(datastreamName); return Boolean.TRUE; } catch (RemoteInvocationException e) { if (ExceptionUtils.getRootCause(e) instanceof TimeoutException) { LOG.warn("Timeout: datastreamExists. May retry...", e); return null; } if (isNotFoundHttpStatus(e)) { LOG.debug("Datastream {} is not found", datastreamName); } else { String errorMessage = String.format("Get Datastream %s failed with error.", datastreamName); ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } } return Boolean.FALSE; }, Objects::nonNull, getRetryPeriodMs(), getRetryTimeoutMs()).orElseThrow(RetriesExhaustedException::new); } }
DatastreamRestClient { public boolean datastreamExists(String datastreamName) { return PollUtils.poll(() -> { try { doGetDatastream(datastreamName); return Boolean.TRUE; } catch (RemoteInvocationException e) { if (ExceptionUtils.getRootCause(e) instanceof TimeoutException) { LOG.warn("Timeout: datastreamExists. May retry...", e); return null; } if (isNotFoundHttpStatus(e)) { LOG.debug("Datastream {} is not found", datastreamName); } else { String errorMessage = String.format("Get Datastream %s failed with error.", datastreamName); ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } } return Boolean.FALSE; }, Objects::nonNull, getRetryPeriodMs(), getRetryTimeoutMs()).orElseThrow(RetriesExhaustedException::new); } @Deprecated  DatastreamRestClient(RestClient restClient);  DatastreamRestClient(RestClient restClient, Properties config); }
DatastreamRestClient { public boolean datastreamExists(String datastreamName) { return PollUtils.poll(() -> { try { doGetDatastream(datastreamName); return Boolean.TRUE; } catch (RemoteInvocationException e) { if (ExceptionUtils.getRootCause(e) instanceof TimeoutException) { LOG.warn("Timeout: datastreamExists. May retry...", e); return null; } if (isNotFoundHttpStatus(e)) { LOG.debug("Datastream {} is not found", datastreamName); } else { String errorMessage = String.format("Get Datastream %s failed with error.", datastreamName); ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } } return Boolean.FALSE; }, Objects::nonNull, getRetryPeriodMs(), getRetryTimeoutMs()).orElseThrow(RetriesExhaustedException::new); } @Deprecated  DatastreamRestClient(RestClient restClient);  DatastreamRestClient(RestClient restClient, Properties config); Datastream getDatastream(String datastreamName); Datastream waitTillDatastreamIsInitialized(String datastreamName, long timeoutMs); void waitTillDatastreamIsDeleted(String datastreamName, long timeoutMs); List<Datastream> getAllDatastreams(); List<Datastream> getAllDatastreams(int start, int count); void createDatastream(Datastream datastream); void updateDatastream(Datastream datastream); void updateDatastream(List<Datastream> datastreams); void deleteDatastream(String datastreamName); boolean datastreamExists(String datastreamName); void pause(String datastreamName); void pause(String datastreamName, boolean force); void stop(String datastreamName); void resume(String datastreamName); void resume(String datastreamName, boolean force); void movePartitions(String datastreamName, String partitions, String targetHost); List<Datastream> findGroup(String datastreamName); void pauseSourcePartitions(String datastreamName, StringMap sourcePartitions); void resumeSourcePartitions(String datastreamName, StringMap sourcePartitions); }
DatastreamRestClient { public boolean datastreamExists(String datastreamName) { return PollUtils.poll(() -> { try { doGetDatastream(datastreamName); return Boolean.TRUE; } catch (RemoteInvocationException e) { if (ExceptionUtils.getRootCause(e) instanceof TimeoutException) { LOG.warn("Timeout: datastreamExists. May retry...", e); return null; } if (isNotFoundHttpStatus(e)) { LOG.debug("Datastream {} is not found", datastreamName); } else { String errorMessage = String.format("Get Datastream %s failed with error.", datastreamName); ErrorLogger.logAndThrowDatastreamRuntimeException(LOG, errorMessage, e); } } return Boolean.FALSE; }, Objects::nonNull, getRetryPeriodMs(), getRetryTimeoutMs()).orElseThrow(RetriesExhaustedException::new); } @Deprecated  DatastreamRestClient(RestClient restClient);  DatastreamRestClient(RestClient restClient, Properties config); Datastream getDatastream(String datastreamName); Datastream waitTillDatastreamIsInitialized(String datastreamName, long timeoutMs); void waitTillDatastreamIsDeleted(String datastreamName, long timeoutMs); List<Datastream> getAllDatastreams(); List<Datastream> getAllDatastreams(int start, int count); void createDatastream(Datastream datastream); void updateDatastream(Datastream datastream); void updateDatastream(List<Datastream> datastreams); void deleteDatastream(String datastreamName); boolean datastreamExists(String datastreamName); void pause(String datastreamName); void pause(String datastreamName, boolean force); void stop(String datastreamName); void resume(String datastreamName); void resume(String datastreamName, boolean force); void movePartitions(String datastreamName, String partitions, String targetHost); List<Datastream> findGroup(String datastreamName); void pauseSourcePartitions(String datastreamName, StringMap sourcePartitions); void resumeSourcePartitions(String datastreamName, StringMap sourcePartitions); static final String CONFIG_RETRY_PERIOD_MS; static final String CONFIG_RETRY_TIMEOUT_MS; }