当前位置: 首页>>代码示例>>Java>>正文


Java SocketOptions.setReuseAddress方法代码示例

本文整理汇总了Java中com.datastax.driver.core.SocketOptions.setReuseAddress方法的典型用法代码示例。如果您正苦于以下问题:Java SocketOptions.setReuseAddress方法的具体用法?Java SocketOptions.setReuseAddress怎么用?Java SocketOptions.setReuseAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datastax.driver.core.SocketOptions的用法示例。


在下文中一共展示了SocketOptions.setReuseAddress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initOpts

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
@PostConstruct
public void initOpts() {
    opts = new SocketOptions();
    opts.setConnectTimeoutMillis(connectTimeoutMillis);
    opts.setReadTimeoutMillis(readTimeoutMillis);
    if (keepAlive != null) {
        opts.setKeepAlive(keepAlive);
    }
    if (reuseAddress != null) {
        opts.setReuseAddress(reuseAddress);
    }
    if (soLinger != null) {
        opts.setSoLinger(soLinger);
    }
    if (tcpNoDelay != null) {
        opts.setTcpNoDelay(tcpNoDelay);
    }
    if (receiveBufferSize != null) {
        opts.setReceiveBufferSize(receiveBufferSize);
    }
    if (sendBufferSize != null) {
        opts.setSendBufferSize(sendBufferSize);
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:25,代码来源:CassandraSocketOptions.java

示例2: getReadSocketOptions

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
private static SocketOptions getReadSocketOptions(Configuration conf)
{
    SocketOptions socketOptions = new SocketOptions();
    Optional<Integer> connectTimeoutMillis = getInputNativeConnectionTimeout(conf);
    Optional<Integer> readTimeoutMillis = getInputNativeReadConnectionTimeout(conf);
    Optional<Integer> receiveBufferSize = getInputNativeReceiveBufferSize(conf);
    Optional<Integer> sendBufferSize = getInputNativeSendBufferSize(conf);
    Optional<Integer> soLinger = getInputNativeSolinger(conf);
    Optional<Boolean> tcpNoDelay = getInputNativeTcpNodelay(conf);
    Optional<Boolean> reuseAddress = getInputNativeReuseAddress(conf);       
    Optional<Boolean> keepAlive = getInputNativeKeepAlive(conf);

    if (connectTimeoutMillis.isPresent())
        socketOptions.setConnectTimeoutMillis(connectTimeoutMillis.get());
    if (readTimeoutMillis.isPresent())
        socketOptions.setReadTimeoutMillis(readTimeoutMillis.get());
    if (receiveBufferSize.isPresent())
        socketOptions.setReceiveBufferSize(receiveBufferSize.get());
    if (sendBufferSize.isPresent())
        socketOptions.setSendBufferSize(sendBufferSize.get());
    if (soLinger.isPresent())
        socketOptions.setSoLinger(soLinger.get());
    if (tcpNoDelay.isPresent())
        socketOptions.setTcpNoDelay(tcpNoDelay.get());
    if (reuseAddress.isPresent())
        socketOptions.setReuseAddress(reuseAddress.get());
    if (keepAlive.isPresent())
        socketOptions.setKeepAlive(keepAlive.get());     

    return socketOptions;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:32,代码来源:CqlConfigHelper.java

示例3: populateSocketOptions

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
private Cluster.Builder populateSocketOptions(Properties properties, Cluster.Builder builder) {
  String connectionTimeoutMillisProp = properties.getProperty(CassandraStoreParameters.CONNECTION_TIMEOUT_MILLIS);
  String keepAliveProp = properties.getProperty(CassandraStoreParameters.KEEP_ALIVE);
  String readTimeoutMillisProp = properties.getProperty(CassandraStoreParameters.READ_TIMEOUT_MILLIS);
  String receiveBufferSizeProp = properties.getProperty(CassandraStoreParameters.RECEIVER_BUFFER_SIZE);
  String reuseAddress = properties.getProperty(CassandraStoreParameters.REUSE_ADDRESS);
  String sendBufferSize = properties.getProperty(CassandraStoreParameters.SEND_BUFFER_SIZE);
  String soLinger = properties.getProperty(CassandraStoreParameters.SO_LINGER);
  String tcpNoDelay = properties.getProperty(CassandraStoreParameters.TCP_NODELAY);
  SocketOptions options = new SocketOptions();
  if (connectionTimeoutMillisProp != null) {
    options.setConnectTimeoutMillis(Integer.parseInt(connectionTimeoutMillisProp));
  }
  if (keepAliveProp != null) {
    options.setKeepAlive(Boolean.parseBoolean(keepAliveProp));
  }
  if (readTimeoutMillisProp != null) {
    options.setReadTimeoutMillis(Integer.parseInt(readTimeoutMillisProp));
  }
  if (receiveBufferSizeProp != null) {
    options.setReceiveBufferSize(Integer.parseInt(receiveBufferSizeProp));
  }
  if (reuseAddress != null) {
    options.setReuseAddress(Boolean.parseBoolean(reuseAddress));
  }
  if (sendBufferSize != null) {
    options.setSendBufferSize(Integer.parseInt(sendBufferSize));
  }
  if (soLinger != null) {
    options.setSoLinger(Integer.parseInt(soLinger));
  }
  if (tcpNoDelay != null) {
    options.setTcpNoDelay(Boolean.parseBoolean(tcpNoDelay));
  }
  return builder.withSocketOptions(options);
}
 
开发者ID:apache,项目名称:gora,代码行数:37,代码来源:CassandraClient.java

示例4: populateSocketOptions

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
private Builder populateSocketOptions(Map<String, String> properties, Builder builder) throws DataServiceFault {
    String connectionTimeoutMillisProp = properties.get(DBConstants.Cassandra.CONNECTION_TIMEOUT_MILLIS);
    String keepAliveProp = properties.get(DBConstants.Cassandra.KEEP_ALIVE);
    String readTimeoutMillisProp = properties.get(DBConstants.Cassandra.READ_TIMEOUT_MILLIS);
    String receiveBufferSizeProp = properties.get(DBConstants.Cassandra.RECEIVER_BUFFER_SIZE);
    String reuseAddress = properties.get(DBConstants.Cassandra.REUSE_ADDRESS);
    String sendBufferSize = properties.get(DBConstants.Cassandra.SEND_BUFFER_SIZE);
    String soLinger = properties.get(DBConstants.Cassandra.SO_LINGER);
    String tcpNoDelay = properties.get(DBConstants.Cassandra.TCP_NODELAY);
    SocketOptions options = new SocketOptions();
    if (connectionTimeoutMillisProp != null) {
        options.setConnectTimeoutMillis(Integer.parseInt(connectionTimeoutMillisProp));
    }
    if (keepAliveProp != null) {
        options.setKeepAlive(Boolean.parseBoolean(keepAliveProp));
    }
    if (readTimeoutMillisProp != null) {
        options.setReadTimeoutMillis(Integer.parseInt(readTimeoutMillisProp));
    }
    if (receiveBufferSizeProp != null) {
        options.setReceiveBufferSize(Integer.parseInt(receiveBufferSizeProp));
    }
    if (reuseAddress != null) {
        options.setReuseAddress(Boolean.parseBoolean(reuseAddress));
    }
    if (sendBufferSize != null) {
        options.setSendBufferSize(Integer.parseInt(sendBufferSize));
    }
    if (soLinger != null) {
        options.setSoLinger(Integer.parseInt(soLinger));
    }
    if (tcpNoDelay != null) {
        options.setTcpNoDelay(Boolean.parseBoolean(tcpNoDelay));
    }
    return builder.withSocketOptions(options);
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:37,代码来源:CassandraConfig.java

示例5: createBuilder

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
public Builder createBuilder() {
    Builder builder = Cluster.builder();
    for (String address : contactPoints) {
        builder.addContactPoint(address);
    }
    builder.withCompression(compression);
    if (username != null && password != null) {
        builder.withCredentials(username, password);
    }
 
    if (reconnectionPolicy != null) {
        builder.withReconnectionPolicy(reconnectionPolicy);
    }

    if (retryPolicy != null) {
        builder.withRetryPolicy(retryPolicy);
    }
    builder.withPort(port);

    if (!jmxEnabled) {
        builder.withoutJMXReporting();
    }

    if (!metricsEnabled) {
        builder.withoutMetrics();
    }

    if (sslOptions != null) {
        builder.withSSL(sslOptions);
    }

    copyPoolingOptions(builder);

    SocketOptions opts = new SocketOptions();
    opts.setConnectTimeoutMillis(connectTimeoutMillis);
    opts.setReadTimeoutMillis(readTimeoutMillis);

    if (receiveBufferSize != null) {
        opts.setReceiveBufferSize(receiveBufferSize);
    }
    if (sendBufferSize != null) {
        opts.setSendBufferSize(sendBufferSize);
    }
    if (soLinger != null) {
        opts.setSoLinger(soLinger);
    }
    if (keepAlive != null) {
        opts.setKeepAlive(keepAlive);
    }
    if (reuseAddress != null) {
        opts.setReuseAddress(reuseAddress);
    }
    if (tcpNoDelay != null) {
        opts.setTcpNoDelay(tcpNoDelay);
    }

    builder.withSocketOptions(opts);
    return builder;
}
 
开发者ID:pulsarIO,项目名称:realtime-analytics,代码行数:60,代码来源:CassandraConfig.java

示例6: configureSocketOptions

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
/**
 * Creates the socket options for this factory.
 * 
 * @param configuration the configuration.
 * @return the socket options for this factory.
 */
private SocketOptions configureSocketOptions(final Configuration<Map<String, Object>> configuration) {
	final SocketOptions socketOptions = new SocketOptions();

	socketOptions.setConnectTimeoutMillis(
			configuration.getParameter(
					"connect_timeout_millis",
					SocketOptions.DEFAULT_CONNECT_TIMEOUT_MILLIS));

	socketOptions.setReadTimeoutMillis(
			configuration.getParameter(
					"read_timeout_millis",
					SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS));

	final Boolean keepAlive = configuration.getParameter("keep_alive", null);
	if (keepAlive != null) {
		socketOptions.setKeepAlive(keepAlive);
	}

	final Integer soLinger = configuration.getParameter("so_linger", null);
	if (soLinger != null) {
		socketOptions.setSoLinger(soLinger);
	}

	final Integer receiveBufferSize = configuration.getParameter("receive_buffer_size", null);
	if (receiveBufferSize != null) {
		socketOptions.setReceiveBufferSize(receiveBufferSize);
	}

	final Boolean tcpNoDelay = configuration.getParameter("tcp_no_delay", null);
	if (tcpNoDelay != null) {
		socketOptions.setTcpNoDelay(tcpNoDelay);
	}

	final Boolean reuseAddress = configuration.getParameter("reuse_address", null);
	if (reuseAddress != null) {
		socketOptions.setReuseAddress(reuseAddress);
	}

	return socketOptions;
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:47,代码来源:CassandraStorageLayerFactory.java

示例7: CassandraLogEventDao

import com.datastax.driver.core.SocketOptions; //导入方法依赖的package包/类
/**
 * Instantiates a new CassandraLogEventDao.
 */
public CassandraLogEventDao(CassandraConfig configuration) throws UnknownHostException {
  if (configuration == null) {
    throw new IllegalArgumentException("Configuration shouldn't be null");
  }
  LOG.info("Init cassandra log event dao...");
  this.configuration = configuration;
  keyspaceName = configuration.getKeySpace();
  List<InetSocketAddress> clusterNodes = new ArrayList<>();
  List<CassandraServer> nodes = configuration.getCassandraServers();
  for (CassandraServer node : nodes) {
    clusterNodes.add(new InetSocketAddress(InetAddress.getByName(node.getHost()), node.getPort()));
  }

  Cluster.Builder builder = Cluster.builder().addContactPointsWithPorts(clusterNodes);
  LOG.info("Init cassandra cluster with nodes {}", Arrays.toString(clusterNodes.toArray()));

  CassandraCredential cc = configuration.getCassandraCredential();
  if (cc != null) {
    builder.withCredentials(cc.getUser(), cc.getPassword());
    LOG.trace("Init cassandra cluster with username {} and password {}", cc.getUser(), cc.getPassword());
  }

  CassandraSocketOption option = configuration.getCassandraSocketOption();
  if (option != null) {
    SocketOptions so = new SocketOptions();
    if (option.getSoLinger() != null) {
      so.setSoLinger(option.getSoLinger());
    }
    if (option.getKeepAlive() != null) {
      so.setKeepAlive(option.getKeepAlive());
    }
    if (option.getReuseAddress()) {
      so.setReuseAddress(option.getReuseAddress());
    }
    if (option.getTcpNoDelay() != null) {
      so.setTcpNoDelay(option.getTcpNoDelay());
    }
    if (option.getConnectionTimeout() != null) {
      so.setConnectTimeoutMillis(option.getConnectionTimeout());
    }
    if (option.getReadTimeout() != null) {
      so.setReadTimeoutMillis(option.getReadTimeout());
    }
    if (option.getReceiveBufferSize() != null) {
      so.setReceiveBufferSize(option.getReceiveBufferSize());
    }
    if (option.getSendBufferSize() != null) {
      so.setSendBufferSize(option.getSendBufferSize());
    }
    builder.withSocketOptions(so);
    LOG.trace("Init cassandra cluster with socket options {}", option);
  }

  CassandraWriteConsistencyLevel ccLevel = configuration.getCassandraWriteConsistencyLevel();
  if (ccLevel != null) {
    writeConsistencyLevel = ConsistencyLevel.valueOf(ccLevel.name());
    LOG.trace("Init cassandra cluster with consistency level {}", ccLevel.name());
  }
  CassandraCompression cassandraCompression = configuration.getCassandraCompression();
  if (cassandraCompression != null) {
    builder.withCompression(ProtocolOptions.Compression.valueOf(cassandraCompression.name()));
    LOG.trace("Init cassandra cluster with compression {}", cassandraCompression.name());
  }
  batchType = configuration.getCassandraBatchType();
  cluster = builder.build();
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:70,代码来源:CassandraLogEventDao.java


注:本文中的com.datastax.driver.core.SocketOptions.setReuseAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。