Class ChangeRequestHttpSyncer<T>
- java.lang.Object
-
- org.apache.druid.server.coordination.ChangeRequestHttpSyncer<T>
-
public class ChangeRequestHttpSyncer<T> extends Object
This class facilitates the usage of long-polling HTTP endpoints powered byChangeRequestHistory. For exampleHttpServerInventoryViewuses it to keep segment state in sync with data nodes which expose the segment state via HTTP endpoint inSegmentListerResource.getSegments(long, long, long, javax.servlet.http.HttpServletRequest).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceChangeRequestHttpSyncer.Listener<T>Concurrency guarantees: all calls toChangeRequestHttpSyncer.Listener.fullSync(java.util.List<T>)andChangeRequestHttpSyncer.Listener.deltaSync(java.util.List<T>)(that is done within theexecutor) are linearizable.
-
Field Summary
Fields Modifier and Type Field Description static longHTTP_TIMEOUT_EXTRA_MS
-
Constructor Summary
Constructors Constructor Description ChangeRequestHttpSyncer(com.fasterxml.jackson.databind.ObjectMapper smileMapper, org.apache.druid.java.util.http.client.HttpClient httpClient, ScheduledExecutorService executor, URL baseServerURL, String baseRequestPath, com.fasterxml.jackson.core.type.TypeReference<ChangeRequestsSnapshot<T>> responseTypeReferences, long serverTimeoutMS, long serverUnstabilityTimeout, ChangeRequestHttpSyncer.Listener<T> listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitInitialization()Waits for the first successful sync with this server up tomaxDurationToWaitForSync.Map<String,Object>getDebugInfo()Returns debugging information for printing, must not be used for any other purpose.longgetUnstableTimeMillis()booleanisExecutorShutdown()booleanisInitialized()Whether this server has been synced successfully at least once.booleanisSyncedSuccessfully()booleanneedsReset()Whether this syncer should be reset.voidstart()voidstop()
-
-
-
Field Detail
-
HTTP_TIMEOUT_EXTRA_MS
public static final long HTTP_TIMEOUT_EXTRA_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ChangeRequestHttpSyncer
public ChangeRequestHttpSyncer(com.fasterxml.jackson.databind.ObjectMapper smileMapper, org.apache.druid.java.util.http.client.HttpClient httpClient, ScheduledExecutorService executor, URL baseServerURL, String baseRequestPath, com.fasterxml.jackson.core.type.TypeReference<ChangeRequestsSnapshot<T>> responseTypeReferences, long serverTimeoutMS, long serverUnstabilityTimeout, ChangeRequestHttpSyncer.Listener<T> listener)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
awaitInitialization
public boolean awaitInitialization() throws InterruptedExceptionWaits for the first successful sync with this server up tomaxDurationToWaitForSync.- Throws:
InterruptedException
-
isInitialized
public boolean isInitialized()
Whether this server has been synced successfully at least once.
-
getDebugInfo
public Map<String,Object> getDebugInfo()
Returns debugging information for printing, must not be used for any other purpose.
-
needsReset
public boolean needsReset()
Whether this syncer should be reset. This method returning true typically indicates a problem with the sync scheduler.- Returns:
- true if the delay since the last request to the server (or since
syncer start in case of no request to the server) has exceeded
maxDelayBetweenSyncRequests.
-
getUnstableTimeMillis
public long getUnstableTimeMillis()
-
isSyncedSuccessfully
public boolean isSyncedSuccessfully()
- Returns:
- true if there have been no sync failures recently and the last
successful sync was not more than
maxDurationToWaitForSyncago.
-
isExecutorShutdown
public boolean isExecutorShutdown()
-
-