com.datastax.driver.core.policies.Policies.getReconnectionPolicy()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(173)

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

Policies.getReconnectionPolicy介绍

[英]The reconnection policy in use.

The reconnection policy defines how often the driver tries to reconnect to a dead node.
[中]正在使用的重新连接策略。
重新连接策略定义驱动程序尝试重新连接到死节点的频率。

代码示例

代码示例来源: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

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

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

.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.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

Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), ERP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

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

Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), ERP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

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

Assert.assertEquals(configuration.getPolicies().getReconnectionPolicy().getClass().getName(), CRP);
Assert.assertEquals(configuration.getPolicies().getRetryPolicy().getClass().getName(), DCRP);

代码示例来源: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.facebook.presto.cassandra/cassandra-driver

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

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

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

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

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

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

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

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

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: prestosql/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.dse/dse-java-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: spring-cloud/spring-cloud-connectors

@Test
public void cassandraSessionWithConfiguration() throws Exception {
  ApplicationContext testContext = getTestApplicationContext(
      "cloud-cassandra-with-config.xml", createService("my-service"));
  Cluster cluster = testContext.getBean("cassandra-full-config",
      getConnectorType());
  assertNotNull(cluster.getConfiguration().getSocketOptions());
  assertEquals(15000,
      cluster.getConfiguration().getSocketOptions().getConnectTimeoutMillis());
  assertTrue(DefaultRetryPolicy.class.isAssignableFrom(
      cluster.getConfiguration().getPolicies().getRetryPolicy().getClass()));
  assertTrue(RoundRobinPolicy.class.isAssignableFrom(cluster.getConfiguration()
      .getPolicies().getLoadBalancingPolicy().getClass()));
  assertTrue(ConstantReconnectionPolicy.class.isAssignableFrom(cluster
      .getConfiguration().getPolicies().getReconnectionPolicy().getClass()));
}

代码示例来源:origin: com.github.ddth/ddth-cql-utils

builder.withLoadBalancingPolicy(lbp);
ReconnectionPolicy rnp = policies != null ? policies.getReconnectionPolicy() : null;
if (rnp != null) {
  builder.withReconnectionPolicy(rnp);

代码示例来源:origin: com.netflix.astyanax/astyanax-cql

.withPort(port)
.withLoadBalancingPolicy(config.getPolicies().getLoadBalancingPolicy())
.withReconnectionPolicy(config.getPolicies().getReconnectionPolicy())
.withRetryPolicy(config.getPolicies().getRetryPolicy())
.withCompression(config.getProtocolOptions().getCompression())

代码示例来源:origin: spring-cloud/spring-cloud-connectors

assertThat(policies.getLoadBalancingPolicy(),
    is(config.getLoadBalancingPolicy()));
assertThat(policies.getReconnectionPolicy(), is(config.getReconnectionPolicy()));
assertThat(policies.getRetryPolicy(), is(config.getRetryPolicy()));

相关文章