@Beta public class PercentileSpeculativeExecutionPolicy extends Object implements SpeculativeExecutionPolicy
PerHostPercentileTracker
that must be registered with the cluster instance:
PerHostPercentileTracker tracker = PerHostPercentileTracker .builderWithHighestTrackableLatencyMillis(15000) .build(); PercentileSpeculativeExecutionPolicy policy = new PercentileSpeculativeExecutionPolicy(tracker, 99.0, 2); cluster = Cluster.builder() .addContactPoint("127.0.0.1") .withSpeculativeExecutionPolicy(policy) .build(); cluster.register(tracker);You must register the tracker with the cluster yourself (as shown on the last line above), this class will not do it itself. This class is currently provided as a beta preview: it hasn't been extensively tested yet, and the API is still subject to change.
SpeculativeExecutionPolicy.SpeculativeExecutionPlan
Constructor and Description |
---|
PercentileSpeculativeExecutionPolicy(PerHostPercentileTracker percentileTracker,
double percentile,
int maxSpeculativeExecutions)
Builds a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Gets invoked at cluster shutdown.
|
void |
init(Cluster cluster)
Gets invoked at cluster startup.
|
SpeculativeExecutionPolicy.SpeculativeExecutionPlan |
newPlan(String loggedKeyspace,
Statement statement)
Returns the plan to use for a new query.
|
public PercentileSpeculativeExecutionPolicy(PerHostPercentileTracker percentileTracker, double percentile, int maxSpeculativeExecutions)
percentileTracker
- the component that will record latencies. Note that this policy doesn't register it with the Cluster
,
you must do it yourself (see the code example in this class's Javadoc).percentile
- the percentile that a request's latency must fall into to be considered slow (ex: 99.0
).maxSpeculativeExecutions
- the maximum number of speculative executions that will be triggered for a given request (this does not
include the initial, normal request). Must be strictly positive.public SpeculativeExecutionPolicy.SpeculativeExecutionPlan newPlan(String loggedKeyspace, Statement statement)
SpeculativeExecutionPolicy
newPlan
in interface SpeculativeExecutionPolicy
loggedKeyspace
- the currently logged keyspace (the one set through either
Cluster.connect(String)
or by manually doing a USE
query) for
the session on which this plan need to be built. This can be null
if
the corresponding session has no keyspace logged in.statement
- the query for which to build a plan.public void init(Cluster cluster)
SpeculativeExecutionPolicy
init
in interface SpeculativeExecutionPolicy
cluster
- the cluster that this policy is associated with.public void close()
SpeculativeExecutionPolicy
close
in interface SpeculativeExecutionPolicy