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

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

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

Configuration.getSocketOptions介绍

[英]Returns the low-level TCP configuration options used (tcpNoDelay, keepAlive, ...).
[中]返回使用的低级TCP配置选项(tcpNoDelay、keepAlive等)。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

CONNECT_TIMEOUT_MILLIS_PROPERTY);
if (connectTimoutMillis != null) {
 cluster.getConfiguration().getSocketOptions()
   .setConnectTimeoutMillis(Integer.valueOf(connectTimoutMillis));
  READ_TIMEOUT_MILLIS_PROPERTY);
if (readTimoutMillis != null) {
 cluster.getConfiguration().getSocketOptions()
   .setReadTimeoutMillis(Integer.valueOf(readTimoutMillis));

代码示例来源:origin: apache/storm

cassandraConf.getReconnectionPolicyMaxMs()))
                 .withLoadBalancingPolicy(cassandraConf.getLoadBalancingPolicy());
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis((int) cassandraConf.getSocketReadTimeoutMillis());
cluster.getConfiguration().getSocketOptions().setConnectTimeoutMillis((int) cassandraConf.getSocketConnectTimeoutMillis());

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

long getReadTimeoutMillis() {
 return configuration.getSocketOptions().getReadTimeoutMillis();
}

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

private Bootstrap newBootstrap() {
 Bootstrap b = new Bootstrap();
 b.group(eventLoopGroup).channel(channelClass);
 SocketOptions options = configuration.getSocketOptions();
 b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, options.getConnectTimeoutMillis());
 Boolean keepAlive = options.getKeepAlive();
 if (keepAlive != null) b.option(ChannelOption.SO_KEEPALIVE, keepAlive);
 Boolean reuseAddress = options.getReuseAddress();
 if (reuseAddress != null) b.option(ChannelOption.SO_REUSEADDR, reuseAddress);
 Integer soLinger = options.getSoLinger();
 if (soLinger != null) b.option(ChannelOption.SO_LINGER, soLinger);
 Boolean tcpNoDelay = options.getTcpNoDelay();
 if (tcpNoDelay != null) b.option(ChannelOption.TCP_NODELAY, tcpNoDelay);
 Integer receiveBufferSize = options.getReceiveBufferSize();
 if (receiveBufferSize != null) b.option(ChannelOption.SO_RCVBUF, receiveBufferSize);
 Integer sendBufferSize = options.getSendBufferSize();
 if (sendBufferSize != null) b.option(ChannelOption.SO_SNDBUF, sendBufferSize);
 nettyOptions.afterBootstrapInitialized(b);
 return b;
}

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

Assert.assertEquals(configuration.getSocketOptions().getReadTimeoutMillis(), 110000);
Assert.assertEquals(configuration.getSocketOptions().getKeepAlive().booleanValue(), false);
Assert.assertEquals(configuration.getSocketOptions().getReceiveBufferSize().intValue(), 12);
Assert.assertEquals(configuration.getSocketOptions().getReuseAddress().booleanValue(), true);
Assert.assertEquals(configuration.getSocketOptions().getSendBufferSize().intValue(), 11);
Assert.assertEquals(configuration.getSocketOptions().getSoLinger().intValue(), 10);
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);

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

Assert.assertEquals(configuration.getSocketOptions().getReadTimeoutMillis(), 110000);
Assert.assertEquals(configuration.getSocketOptions().getKeepAlive().booleanValue(), false);
Assert.assertEquals(configuration.getSocketOptions().getReceiveBufferSize().intValue(), 12);
Assert.assertEquals(configuration.getSocketOptions().getReuseAddress().booleanValue(), true);
Assert.assertEquals(configuration.getSocketOptions().getSendBufferSize().intValue(), 11);
Assert.assertEquals(configuration.getSocketOptions().getSoLinger().intValue(), 10);
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);

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

Assert.assertEquals(configuration.getSocketOptions().getReadTimeoutMillis(), 110000);
Assert.assertEquals(configuration.getSocketOptions().getKeepAlive().booleanValue(), false);
Assert.assertEquals(configuration.getSocketOptions().getReceiveBufferSize().intValue(), 12);
Assert.assertEquals(configuration.getSocketOptions().getReuseAddress().booleanValue(), true);
Assert.assertEquals(configuration.getSocketOptions().getSendBufferSize().intValue(), 11);
Assert.assertEquals(configuration.getSocketOptions().getSoLinger().intValue(), 10);
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);

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

Assert.assertEquals(configuration.getSocketOptions().getReadTimeoutMillis(), 110000);
Assert.assertEquals(configuration.getSocketOptions().getKeepAlive().booleanValue(), false);
Assert.assertEquals(configuration.getSocketOptions().getReceiveBufferSize().intValue(), 12);
Assert.assertEquals(configuration.getSocketOptions().getReuseAddress().booleanValue(), true);
Assert.assertEquals(configuration.getSocketOptions().getSendBufferSize().intValue(), 11);
Assert.assertEquals(configuration.getSocketOptions().getSoLinger().intValue(), 10);
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);

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

Assert.assertEquals(configuration.getSocketOptions().getReadTimeoutMillis(), 110000);
Assert.assertEquals(configuration.getSocketOptions().getKeepAlive().booleanValue(), false);
Assert.assertEquals(configuration.getSocketOptions().getReceiveBufferSize().intValue(), 12);
Assert.assertEquals(configuration.getSocketOptions().getReuseAddress().booleanValue(), true);
Assert.assertEquals(configuration.getSocketOptions().getSendBufferSize().intValue(), 11);
Assert.assertEquals(configuration.getSocketOptions().getSoLinger().intValue(), 10);
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);

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

@Test(groups = "short")
public void should_log_timed_out_queries() throws Exception {
 // given
 error.setLevel(DEBUG);
 queryLogger = builder().build();
 cluster.register(queryLogger);
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 String query = "SELECT foo FROM bar";
 primingClient.prime(
   queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
 // when
 try {
  session.execute(query);
  fail("Should have thrown OperationTimedOutException");
 } catch (OperationTimedOutException e) {
  // ok
 }
 // then
 String line = errorAppender.waitAndGet(5000);
 assertThat(line)
   .contains("Query error")
   .contains(ip)
   .contains(Integer.toString(scassandra.getBinaryPort()))
   .contains(query)
   .contains("Timed out waiting for server response");
}

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

@Test(groups = "short")
public void should_retry_on_client_timeout_if_statement_idempotent() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
    .node(1)
    .primingClient()
    .prime(
      PrimingRequest.queryBuilder()
        .withQuery("mock query")
        .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1")))
        .build());
  session.execute(new SimpleStatement("mock query").setIdempotent(true));
  assertOnRequestErrorWasCalled(1, OperationTimedOutException.class);
  assertThat(errors.getClientTimeouts().getCount()).isEqualTo(1);
  assertThat(errors.getRetries().getCount()).isEqualTo(1);
  assertThat(errors.getRetriesOnClientTimeout().getCount()).isEqualTo(1);
  assertQueried(1, 1);
  assertQueried(2, 1);
  assertQueried(3, 0);
 } finally {
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);
 }
}

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

@Test(groups = "short")
public void should_rethrow_on_client_timeouts() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

@BeforeMethod(groups = "short")
public void setup() {
 primingClient.prime(
   queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
 // Set default timeout too low
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(10);
}

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

@Test(groups = "short")
public void should_not_retry_on_client_timeout_if_statement_non_idempotent() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

.getSocketOptions()
  .setConnectTimeoutMillis(CONNECTION_TIMEOUT_IN_MS);
cluster().getConfiguration().getSocketOptions().setReadTimeoutMillis(READ_TIMEOUT_IN_MS);
Session newSession = cluster().connect(keyspace);
PreparedStatement statement =
   .getSocketOptions()
   .setConnectTimeoutMillis(SocketOptions.DEFAULT_CONNECT_TIMEOUT_MILLIS);
 cluster()
   .getConfiguration()
   .getSocketOptions()
   .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

@Test(groups = "short")
public void should_rethrow_on_client_timeouts() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

@Test(groups = "short")
public void should_try_next_host_on_client_timeouts() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
try {
 scassandras
 cluster
   .getConfiguration()
   .getSocketOptions()
   .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);

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

@Test(groups = "short")
public void should_wait_until_all_executions_have_finished() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1000);

相关文章