public static class ErrorAwarePolicy.Builder extends Object
ErrorAwarePolicy
.Constructor and Description |
---|
Builder(LoadBalancingPolicy childPolicy)
Creates a
ErrorAwarePolicy.Builder instance. |
Modifier and Type | Method and Description |
---|---|
ErrorAwarePolicy |
build()
Creates the
ErrorAwarePolicy instance. |
ErrorAwarePolicy.Builder |
withErrorsFilter(ErrorAwarePolicy.ErrorFilter errorFilter)
Provides a filter that will decide which errors are counted towards
withMaxErrorsPerMinute(int) . |
ErrorAwarePolicy.Builder |
withMaxErrorsPerMinute(int maxErrorsPerMinute)
Defines the maximum number of errors allowed per minute for each host.
|
ErrorAwarePolicy.Builder |
withRetryPeriod(long retryPeriod,
TimeUnit retryPeriodTimeUnit)
Defines the time during which a host is excluded by the policy once it has exceeded
withMaxErrorsPerMinute(int) . |
public Builder(LoadBalancingPolicy childPolicy)
ErrorAwarePolicy.Builder
instance.childPolicy
- the load balancing policy to wrap with error
awareness.public ErrorAwarePolicy.Builder withMaxErrorsPerMinute(int maxErrorsPerMinute)
withErrorsFilter(com.datastax.driver.core.policies.ErrorAwarePolicy.ErrorFilter)
)
over a sliding 1-minute window. If a host had more than this number
of errors, it will be excluded from the query plan for the duration defined by
withRetryPeriod(long, TimeUnit)
.
Default value for the threshold is 1.maxErrorsPerMinute
- the number.ErrorAwarePolicy.Builder
instance, for method chaining.public ErrorAwarePolicy.Builder withRetryPeriod(long retryPeriod, TimeUnit retryPeriodTimeUnit)
withMaxErrorsPerMinute(int)
.
Default value for the retry period is 2 minutes.retryPeriod
- the period of exclusion for a host.retryPeriodTimeUnit
- the time unit for the retry period.ErrorAwarePolicy.Builder
instance, for method chaining.public ErrorAwarePolicy.Builder withErrorsFilter(ErrorAwarePolicy.ErrorFilter errorFilter)
withMaxErrorsPerMinute(int)
.
The default implementation will exclude from the error counting, the following exception types:
QueryConsistencyException
and UnavailableException
: the assumption is that these errors
are most often caused by other replicas being unavailable, not by something wrong on the coordinator;InvalidQueryException
, AlreadyExistsException
, SyntaxError
: these are likely
caused by a bad query in client code, that will fail on all hosts. Excluding hosts could lead to complete
loss of connectivity, rather the solution is to fix the query;FunctionExecutionException
: similarly, this is caused by a bad function definition and likely to
fail on all hosts.errorFilter
- the filter class that the policy will use.ErrorAwarePolicy.Builder
instance, for method chaining.public ErrorAwarePolicy build()
ErrorAwarePolicy
instance.ErrorAwarePolicy
.Copyright © 2012–2017. All rights reserved.