com.datastax.driver.core.Configuration.getPolicies()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.datastax.driver.core.Configuration.getPolicies()方法的一些代码示例,展示了Configuration.getPolicies()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getPolicies()方法的具体详情如下:
包路径:com.datastax.driver.core.Configuration
类名称:Configuration
方法名:getPolicies

Configuration.getPolicies介绍

[英]Returns the policies set for the cluster.
[中]返回为群集设置的策略。

代码示例

代码示例来源:origin: prestodb/presto

private <T> T executeWithSession(SessionCallable<T> sessionCallable)
{
  ReconnectionPolicy reconnectionPolicy = cluster.getConfiguration().getPolicies().getReconnectionPolicy();
  ReconnectionSchedule schedule = reconnectionPolicy.newSchedule();
  long deadline = System.currentTimeMillis() + noHostAvailableRetryTimeout.toMillis();
  while (true) {
    try {
      return sessionCallable.executeWithSession(session.get());
    }
    catch (NoHostAvailableException e) {
      long timeLeft = deadline - System.currentTimeMillis();
      if (timeLeft <= 0) {
        throw e;
      }
      else {
        long delay = Math.min(schedule.nextDelayMs(), timeLeft);
        log.warn(e.getCustomMessage(10, true, true));
        log.warn("Reconnecting in %dms", delay);
        try {
          Thread.sleep(delay);
        }
        catch (InterruptedException interrupted) {
          Thread.currentThread().interrupt();
          throw new RuntimeException("interrupted", interrupted);
        }
      }
    }
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

LoadBalancingPolicy loadBalancingPolicy() {
 return configuration.getPolicies().getLoadBalancingPolicy();
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

SpeculativeExecutionPolicy speculativeExecutionPolicy() {
 return configuration.getPolicies().getSpeculativeExecutionPolicy();
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

ReconnectionPolicy reconnectionPolicy() {
 return configuration.getPolicies().getReconnectionPolicy();
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

InetSocketAddress translateAddress(InetSocketAddress address) {
 InetSocketAddress translated =
   configuration.getPolicies().getAddressTranslator().translate(address);
 return translated == null ? address : translated;
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private RetryPolicy retryPolicy() {
 return statement.getRetryPolicy() == null
   ? manager.configuration().getPolicies().getRetryPolicy()
   : statement.getRetryPolicy();
}

代码示例来源:origin: intuit/wasabi

private void poolingMonitoring(PoolingOptions poolingOptions) {
    final LoadBalancingPolicy loadBalancingPolicy =
        cluster.getConfiguration().getPolicies().getLoadBalancingPolicy();
    ScheduledExecutorService scheduled =
        Executors.newScheduledThreadPool(1);
    scheduled.scheduleAtFixedRate((Runnable) () -> {
      Session.State state = session.getState();
      for (Host host : state.getConnectedHosts()) {
        HostDistance distance = loadBalancingPolicy.distance(host);
        int connections = state.getOpenConnections(host);
        int inFlightQueries = state.getInFlightQueries(host);
        LOGGER.info("{} connections={}, current load={}, max load={}",
            host, connections, inFlightQueries,
            connections * poolingOptions.getMaxRequestsPerConnection(distance));
      }
    }, 5, 5, TimeUnit.SECONDS);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

configuration.getPolicies().getRetryPolicy().close();
reconnectionPolicy().close();
configuration.getPolicies().getAddressTranslator().close();
for (LatencyTracker tracker : latencyTrackers) tracker.onUnregister(Cluster.this);
for (Host.StateListener listener : listeners) listener.onUnregister(Cluster.this);

代码示例来源:origin: Impetus/Kundera

Assert.assertEquals(configuration.getPoolingOptions()
    .getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(), TAP);
Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), CRP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), LRTP);

代码示例来源:origin: Impetus/Kundera

Assert.assertEquals(configuration.getPoolingOptions()
    .getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(),
    LatencyAwarePolicy.class.getName());
Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), CRP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), LRTP);

代码示例来源:origin: Impetus/Kundera

.getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(), RRP);
Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), ERP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

代码示例来源:origin: Impetus/Kundera

.getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(), RRP);
Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), ERP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

代码示例来源:origin: Impetus/Kundera

.getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(), DRRP);
Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), CRP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Copy constructor.
 *
 * @param toCopy the object to copy from.
 */
protected Configuration(Configuration toCopy) {
 this(
   toCopy.getPolicies(),
   toCopy.getProtocolOptions(),
   toCopy.getPoolingOptions(),
   toCopy.getSocketOptions(),
   toCopy.getMetricsOptions(),
   toCopy.getQueryOptions(),
   toCopy.getThreadingOptions(),
   toCopy.getNettyOptions(),
   toCopy.getCodecRegistry());
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

if (!(cluster().getConfiguration().getPolicies().getReconnectionPolicy()
  instanceof ConstantReconnectionPolicy)) {
 fail("Set policy does not match retrieved policy.");
    cluster().getConfiguration().getPolicies().getReconnectionPolicy();
assertTrue(reconnectionPolicy.getConstantDelayMs() == 10 * 1000);

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

if (!(cluster().getConfiguration().getPolicies().getReconnectionPolicy()
  instanceof ExponentialReconnectionPolicy)) {
 fail("Set policy does not match retrieved policy.");
    cluster().getConfiguration().getPolicies().getReconnectionPolicy();
assertTrue(reconnectionPolicy.getBaseDelayMs() == 2 * 1000);
assertTrue(reconnectionPolicy.getMaxDelayMs() == 5 * 60 * 1000);

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

configuration.getPolicies().getRetryPolicy().init(Cluster.this);
reconnectionPolicy().init(Cluster.this);
configuration.getPolicies().getAddressTranslator().init(Cluster.this);
for (LatencyTracker tracker : latencyTrackers) tracker.onRegister(Cluster.this);
for (Host.StateListener listener : listeners) listener.onRegister(Cluster.this);

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

defaultTimestamp = statement.getDefaultTimestamp();
if (defaultTimestamp == Long.MIN_VALUE)
 defaultTimestamp = cluster.getConfiguration().getPolicies().getTimestampGenerator().next();

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

InetSocketAddress translateAddress(InetAddress address) {
  InetSocketAddress sa = new InetSocketAddress(address, connectionFactory.getPort());
  InetSocketAddress translated = configuration.getPolicies().getAddressTranslator().translate(sa);
  return translated == null ? sa : translated;
}

代码示例来源:origin: hawkular/hawkular-metrics

public RxSessionImpl(Session session) {
  this.session = session;
  this.loadBalancingPolicy = session.getCluster().getConfiguration().getPolicies().getLoadBalancingPolicy();
  PoolingOptions poolingOptions = session.getCluster().getConfiguration().getPoolingOptions();
  maxInFlightLocal = poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL) *
      poolingOptions.getMaxRequestsPerConnection(HostDistance.LOCAL);
  maxInFlightRemote = poolingOptions.getCoreConnectionsPerHost(HostDistance.REMOTE) *
      poolingOptions.getMaxRequestsPerConnection(HostDistance.REMOTE);
}

相关文章