Package org.apache.druid.discovery
Class DruidLeaderClient
- java.lang.Object
-
- org.apache.druid.discovery.DruidLeaderClient
-
public class DruidLeaderClient extends Object
This class facilitates interaction with Coordinator/Overlord leader nodes. Instance of this class is injected via Guice with annotations @Coordinator or @IndexingService . Usage: Request request = druidLeaderClient.makeRequest(HttpMethod, requestPath) request.setXXX(..) FullResponseHolder responseHolder = druidLeaderClient.go(request)
-
-
Constructor Summary
Constructors Constructor Description DruidLeaderClient(org.apache.druid.java.util.http.client.HttpClient httpClient, DruidNodeDiscoveryProvider druidNodeDiscoveryProvider, NodeRole nodeRoleToWatch, String leaderRequestPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringfindCurrentLeader()org.apache.druid.java.util.http.client.response.StringFullResponseHoldergo(org.apache.druid.java.util.http.client.Request request)Executes a Request object aimed at the leader.<T,H extends org.apache.druid.java.util.http.client.response.FullResponseHolder<T>>
Hgo(org.apache.druid.java.util.http.client.Request request, org.apache.druid.java.util.http.client.response.HttpResponseHandler<H,H> responseHandler)Executes a Request object aimed at the leader.org.apache.druid.java.util.http.client.RequestmakeRequest(org.jboss.netty.handler.codec.http.HttpMethod httpMethod, String urlPath)Make a Request object aimed at the leader.voidstart()voidstop()
-
-
-
Constructor Detail
-
DruidLeaderClient
public DruidLeaderClient(org.apache.druid.java.util.http.client.HttpClient httpClient, DruidNodeDiscoveryProvider druidNodeDiscoveryProvider, NodeRole nodeRoleToWatch, String leaderRequestPath)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
makeRequest
public org.apache.druid.java.util.http.client.Request makeRequest(org.jboss.netty.handler.codec.http.HttpMethod httpMethod, String urlPath) throws IOExceptionMake a Request object aimed at the leader. Throws IOException if the leader cannot be located.- Throws:
IOException
-
go
public org.apache.druid.java.util.http.client.response.StringFullResponseHolder go(org.apache.druid.java.util.http.client.Request request) throws IOException, InterruptedExceptionExecutes a Request object aimed at the leader. Throws IOException if the leader cannot be located. Internal retries with cache invalidation are attempted if 503/504 response is received.- Parameters:
request-- Throws:
IOExceptionInterruptedException
-
go
public <T,H extends org.apache.druid.java.util.http.client.response.FullResponseHolder<T>> H go(org.apache.druid.java.util.http.client.Request request, org.apache.druid.java.util.http.client.response.HttpResponseHandler<H,H> responseHandler) throws IOException, InterruptedExceptionExecutes a Request object aimed at the leader. Throws IOException if the leader cannot be located. Internal retries with cache invalidation are attempted if 503/504 response is received.- Parameters:
request-responseHandler-- Throws:
IOExceptionInterruptedException
-
findCurrentLeader
public String findCurrentLeader()
-
-