Tabnine Logo
LatencyAwarePolicy
Code IndexAdd Tabnine to your IDE (free)

How to use
LatencyAwarePolicy
in
com.datastax.driver.core.policies

Best Java code snippets using com.datastax.driver.core.policies.LatencyAwarePolicy (Showing top 20 results out of 315)

origin: Impetus/Kundera

loadBalancingPolicy = LatencyAwarePolicy.builder(loadBalancingPolicy).build();
origin: com.datastax.cassandra/cassandra-driver-core

double currentMin = latencyTracker.getMinAverage();
for (Map.Entry<Host, Snapshot.Stats> entry :
  getScoresSnapshot().getAllStats().entrySet()) {
 Host host = entry.getKey();
 Snapshot.Stats stats = entry.getValue();
origin: com.datastax.cassandra/cassandra-driver-core

 /**
  * Builds a new latency aware policy using the options set on this builder.
  *
  * @return the newly created {@code LatencyAwarePolicy}.
  */
 public LatencyAwarePolicy build() {
  return new LatencyAwarePolicy(
    childPolicy, exclusionThreshold, scale, retryPeriod, updateRate, minMeasure);
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

primingClient.prime(queryBuilder().withQuery(query).build());
LatencyAwarePolicy latencyAwarePolicy =
  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).hasSize(1);
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: com.datastax.cassandra/cassandra-driver-core

  queryBuilder().withQuery(query).withThen(then().withResult(unavailable)).build());
LatencyAwarePolicy latencyAwarePolicy =
  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).isEmpty();
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: com.datastax.cassandra/cassandra-driver-core

  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).hasSize(1);
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: adejanovski/cassandra-jdbc-wrapper

Builder builder = LatencyAwarePolicy.builder((LoadBalancingPolicy) paramList.get(0));
origin: io.prestosql.cassandra/cassandra-driver

for (Map.Entry<Host, Snapshot.Stats> entry : getScoresSnapshot().getAllStats().entrySet()) {
  Host host = entry.getKey();
  Snapshot.Stats stats = entry.getValue();
origin: com.facebook.presto.cassandra/cassandra-driver

  /**
   * Builds a new latency aware policy using the options set on this
   * builder.
   *
   * @return the newly created {@code LatencyAwarePolicy}.
   */
  public LatencyAwarePolicy build() {
    return new LatencyAwarePolicy(childPolicy, exclusionThreshold, scale, retryPeriod, updateRate, minMeasure);
  }
}
origin: com.datastax.dse/dse-java-driver-core

primingClient.prime(queryBuilder().withQuery(query).build());
LatencyAwarePolicy latencyAwarePolicy =
  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).hasSize(1);
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: EinsamHauer/disthene

  public static LoadBalancingPolicy getLoadBalancingPolicy(String policy) {
    LoadBalancingPolicy loadBalancingPolicy;
    switch (policy) {
      case tokenAwarePolicy:
        loadBalancingPolicy = new TokenAwarePolicy(new RoundRobinPolicy());
        break;
      case tokenDcAwareRoundRobinPolicy:
        loadBalancingPolicy = new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().build());
        break;
      case tokenLatencyAwarePolicy:
        loadBalancingPolicy = new TokenAwarePolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
        break;
      default:
        throw new IllegalArgumentException("Cassandra load balancing policy can be " + tokenAwarePolicy + " ," + tokenLatencyAwarePolicy
            + " ," + tokenDcAwareRoundRobinPolicy);
    }
    return loadBalancingPolicy;
  }
}
origin: com.stratio.cassandra/cassandra-driver-core

for (Map.Entry<Host, Snapshot.Stats> entry : getScoresSnapshot().getAllStats().entrySet()) {
  Host host = entry.getKey();
  Snapshot.Stats stats = entry.getValue();
origin: io.prestosql.cassandra/cassandra-driver

  /**
   * Builds a new latency aware policy using the options set on this
   * builder.
   *
   * @return the newly created {@code LatencyAwarePolicy}.
   */
  public LatencyAwarePolicy build() {
    return new LatencyAwarePolicy(childPolicy, exclusionThreshold, scale, retryPeriod, updateRate, minMeasure);
  }
}
origin: com.datastax.dse/dse-java-driver-core

  queryBuilder().withQuery(query).withThen(then().withResult(unavailable)).build());
LatencyAwarePolicy latencyAwarePolicy =
  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).isEmpty();
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: org.apache.camel/camel-cassandraql

  public LoadBalancingPolicy getLoadBalancingPolicy(String policy) {
    LoadBalancingPolicy loadBalancingPolicy = new RoundRobinPolicy();
    switch (policy) {
    case roundRobinPolicy:
      loadBalancingPolicy = new RoundRobinPolicy();
      break;
    case tokenAwarePolicy:
      loadBalancingPolicy = new TokenAwarePolicy(new RoundRobinPolicy());
      break;
    case dcAwareRoundRobinPolicy:
      loadBalancingPolicy = DCAwareRoundRobinPolicy.builder().build();
      break;
    case latencyAwarePolicy:
      loadBalancingPolicy = LatencyAwarePolicy.builder(new RoundRobinPolicy()).build();
      break;
    case errorAwarePolicy:
      loadBalancingPolicy = ErrorAwarePolicy.builder(new RoundRobinPolicy()).build();
      break;
    default:
      throw new IllegalArgumentException("Cassandra load balancing policy can be " + roundRobinPolicy + " ," + tokenAwarePolicy 
          + " ," + dcAwareRoundRobinPolicy);
    }
    return loadBalancingPolicy;
  }
}
origin: com.yugabyte/cassandra-driver-core

for (Map.Entry<Host, Snapshot.Stats> entry : getScoresSnapshot().getAllStats().entrySet()) {
  Host host = entry.getKey();
  Snapshot.Stats stats = entry.getValue();
origin: com.stratio.cassandra/cassandra-driver-core

  /**
   * Builds a new latency aware policy using the options set on this
   * builder.
   *
   * @return the newly created {@code LatencyAwarePolicy}.
   */
  public LatencyAwarePolicy build() {
    return new LatencyAwarePolicy(childPolicy, exclusionThreshold, scale, retryPeriod, updateRate, minMeasure);
  }
}
origin: com.datastax.dse/dse-java-driver-core

  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
Cluster.Builder builder = super.createClusterBuilder();
builder.withLoadBalancingPolicy(latencyAwarePolicy);
 LatencyAwarePolicy.Snapshot snapshot = latencyAwarePolicy.getScoresSnapshot();
 assertThat(snapshot.getAllStats()).hasSize(1);
 LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.core

if (loadBalancingProp != null) {
  if ("LatencyAwareRoundRobinPolicy".equals(loadBalancingProp)) {
    builder = builder.withLoadBalancingPolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
  } else if ("RoundRobinPolicy".equals(loadBalancingProp)) {
    builder = builder.withLoadBalancingPolicy(new RoundRobinPolicy());
origin: com.facebook.presto.cassandra/cassandra-driver

for (Map.Entry<Host, Snapshot.Stats> entry : getScoresSnapshot().getAllStats().entrySet()) {
  Host host = entry.getKey();
  Snapshot.Stats stats = entry.getValue();
com.datastax.driver.core.policiesLatencyAwarePolicy

Javadoc

A wrapper load balancing policy that adds latency awareness to a child policy.

When used, this policy will collect the latencies of the queries to each Cassandra node and maintain a per-node latency score (an average). Based on these scores, the policy will penalize (technically, it will ignore them unless no other nodes are up) the nodes that are slower than the best performing node by more than some configurable amount (the exclusion threshold).

The latency score for a given node is a based on a form of exponential moving average. In other words, the latency score of a node is the average of its previously measured latencies, but where older measurements gets an exponentially decreasing weight. The exact weight applied to a newly received latency is based on the time elapsed since the previous measure (to account for the fact that latencies are not necessarily reported with equal regularity, neither over time nor between different nodes).

Once a node is excluded from query plans (because its averaged latency grew over the exclusion threshold), its latency score will not be updated anymore (since it is not queried). To give a chance to this node to recover, the policy has a configurable retry period. The policy will not penalize a host for which no measurement has been collected for more than this retry period.

Please see the Builder class and methods for more details on the possible parameters of this policy.

Most used methods

  • builder
    Creates a new latency aware policy builder given the child policy that the resulting policy should w
  • getScoresSnapshot
    Returns a snapshot of the scores (latency averages) maintained by this policy.
  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now