Class ConstantSpeculativeExecutionPolicy
- java.lang.Object
-
- com.datastax.driver.core.policies.ConstantSpeculativeExecutionPolicy
-
- All Implemented Interfaces:
SpeculativeExecutionPolicy
public class ConstantSpeculativeExecutionPolicy extends Object implements SpeculativeExecutionPolicy
ASpeculativeExecutionPolicythat schedules a given number of speculative executions, separated by a fixed delay.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.datastax.driver.core.policies.SpeculativeExecutionPolicy
SpeculativeExecutionPolicy.SpeculativeExecutionPlan
-
-
Constructor Summary
Constructors Constructor Description ConstantSpeculativeExecutionPolicy(long constantDelayMillis, int maxSpeculativeExecutions)Builds a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Gets invoked at cluster shutdown.longgetConstantDelayMillis()The delay between each speculative execution, as specified at instantiation.intgetMaxSpeculativeExecutions()The number of speculative executions this policy schedules for a request, as specified at instantiation.voidinit(Cluster cluster)Gets invoked at cluster startup.SpeculativeExecutionPolicy.SpeculativeExecutionPlannewPlan(String loggedKeyspace, Statement statement)Returns the plan to use for a new query.
-
-
-
Constructor Detail
-
ConstantSpeculativeExecutionPolicy
public ConstantSpeculativeExecutionPolicy(long constantDelayMillis, int maxSpeculativeExecutions)Builds a new instance.- Parameters:
constantDelayMillis- the delay between each speculative execution. Must be >= 0. A zero delay means it should immediately send `maxSpeculativeExecutions` requests along with the original request.maxSpeculativeExecutions- the number of speculative executions. Must be strictly positive.- Throws:
IllegalArgumentException- if one of the arguments does not respect the preconditions above.
-
-
Method Detail
-
getMaxSpeculativeExecutions
@Beta public int getMaxSpeculativeExecutions()
The number of speculative executions this policy schedules for a request, as specified at instantiation. This does not include the initial, normal request.- Returns:
- the number of speculative executions, always strictly positive.
-
getConstantDelayMillis
@Beta public long getConstantDelayMillis()
The delay between each speculative execution, as specified at instantiation. Zero means all executions are sent immediately, along with the original request.- Returns:
- the delay in milliseconds, never negative.
-
newPlan
public SpeculativeExecutionPolicy.SpeculativeExecutionPlan newPlan(String loggedKeyspace, Statement statement)
Description copied from interface:SpeculativeExecutionPolicyReturns the plan to use for a new query.- Specified by:
newPlanin interfaceSpeculativeExecutionPolicy- Parameters:
loggedKeyspace- the currently logged keyspace (the one set through eitherCluster.connect(String)or by manually doing aUSEquery) for the session on which this plan need to be built. This can benullif the corresponding session has no keyspace logged in.statement- the query for which to build a plan.- Returns:
- the plan.
-
init
public void init(Cluster cluster)
Description copied from interface:SpeculativeExecutionPolicyGets invoked at cluster startup.- Specified by:
initin interfaceSpeculativeExecutionPolicy- Parameters:
cluster- the cluster that this policy is associated with.
-
close
public void close()
Description copied from interface:SpeculativeExecutionPolicyGets invoked at cluster shutdown.This gives the policy the opportunity to perform some cleanup, for instance stop threads that it might have started.
- Specified by:
closein interfaceSpeculativeExecutionPolicy
-
-