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


Java ProtocolOptions类代码示例

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


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

示例1: configureHosts

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
private void configureHosts() {
    final String hostConfiguration = (String) configuration.get(TRIDENT_CASSANDRA_CQL_HOSTS);
    final String[] hosts = hostConfiguration.split(",");
    final List<InetSocketAddress> sockets = new ArrayList<InetSocketAddress>();
    for (final String host : hosts) {
        if(StringUtils.contains(host, ":")) {
            final String hostParts [] = StringUtils.split(host, ":");
            sockets.add(new InetSocketAddress(hostParts[0], Integer.valueOf(hostParts[1])));
            LOG.debug("Configuring [" + host + "] with port [" + hostParts[1] + "]");
        } else {
            sockets.add(new InetSocketAddress(host, ProtocolOptions.DEFAULT_PORT));
            LOG.debug("Configuring [" + host + "] with port [" + ProtocolOptions.DEFAULT_PORT + "]");
        }
    }
    builder = builder.addContactPointsWithPorts(sockets);
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:17,代码来源:MapConfiguredCqlClientFactory.java

示例2: testSaveToCassandra

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
@Test
public void testSaveToCassandra() throws Exception {
    LOGGER.debug("Connecting to Cassandra Quorum: " + conf.getStringList("cassandra.hosts").toString());

    SaveToCassandraActionExecutionFunction func = new SaveToCassandraActionExecutionFunction(
            getHostsStringFromList(conf.getStringList("cassandra.hosts")), ProtocolOptions.DEFAULT_PORT, 50,  BatchStatement.Type.UNLOGGED);

    List<StratioStreamingMessage> list = new ArrayList<StratioStreamingMessage>();
    message.setColumns(StreamsHelper.COLUMNS3);
    list.add(message);

    Exception ex = null;
    try {
        func.process(list);

    } catch (Exception e) {
        ex = e;
        ex.printStackTrace();
    }

    assertNull("Expected null value", ex);
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:23,代码来源:FunctionsTestIT.java

示例3: setCompression

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
/**
 * Sets compression algorithm to use for the transport.
 *
 * @param compression Compression algorithm.
 */
@SuppressWarnings("UnusedDeclaration")
public void setCompression(String compression) {
    this.compression = compression == null || compression.trim().isEmpty() ? null : compression.trim();
    try {
        if (this.compression != null) {
            ProtocolOptions.Compression.valueOf(this.compression);
        }
    }
    catch (Throwable e) {
        throw new IgniteException("Incorrect compression '" + compression + "' specified for Cassandra connection", e);
    }
    invalidate();
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:19,代码来源:DataSource.java

示例4: CassandraConfiguration

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
protected CassandraConfiguration()  {
	

try {
	seed = JavaConversions.asScalaBuffer(Arrays.asList(InetAddress.getByName("localhost")));
} catch (UnknownHostException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
	
CassandraCluster cc =  new CassandraCluster(seed, 9042,null, 8000, 120000, 1000,6000, 
		new ProtocolOptions().getCompression().LZ4, ConsistencyLevel.ONE);
session = cc.session();

}
 
开发者ID:boontadata,项目名称:boontadata-streams,代码行数:16,代码来源:CassandraConfiguration.java

示例5: getInputCluster

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public static Cluster getInputCluster(String[] hosts, Configuration conf)
{
    int port = getInputNativePort(conf);
    Optional<AuthProvider> authProvider = getAuthProvider(conf);
    Optional<SSLOptions> sslOptions = getSSLOptions(conf);
    Optional<Integer> protocolVersion = getProtocolVersion(conf);
    LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(conf, hosts);
    SocketOptions socketOptions = getReadSocketOptions(conf);
    QueryOptions queryOptions = getReadQueryOptions(conf);
    PoolingOptions poolingOptions = getReadPoolingOptions(conf);
    
    Cluster.Builder builder = Cluster.builder()
                                     .addContactPoints(hosts)
                                     .withPort(port)
                                     .withCompression(ProtocolOptions.Compression.NONE);

    if (authProvider.isPresent())
        builder.withAuthProvider(authProvider.get());
    if (sslOptions.isPresent())
        builder.withSSL(sslOptions.get());

    if (protocolVersion.isPresent()) {
        builder.withProtocolVersion(protocolVersion.get());
    }
    builder.withLoadBalancingPolicy(loadBalancingPolicy)
           .withSocketOptions(socketOptions)
           .withQueryOptions(queryOptions)
           .withPoolingOptions(poolingOptions);

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

示例6: ConstructorConfiguredCqlClientFactory

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public ConstructorConfiguredCqlClientFactory(String hosts, String clusterName, ConsistencyLevel clusterConsistency,
                        ConsistencyLevel conditionalUpdateConsistency, ProtocolOptions.Compression compression) {
    this.hosts = hosts.split(",");
    this.clusterConsistencyLevel = clusterConsistency;
    if (conditionalUpdateConsistency != null){
        this.serialConsistencyLevel = conditionalUpdateConsistency;
    }
    if (clusterName != null) {
        this.clusterName = clusterName;
    }
    this.compression = compression;
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:13,代码来源:ConstructorConfiguredCqlClientFactory.java

示例7: getClusterBuilder

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public Cluster.Builder getClusterBuilder() {

        final List<InetSocketAddress> sockets = new ArrayList<InetSocketAddress>();
        for (String host : hosts) {
            if(StringUtils.contains(host, ":")) {
                String hostParts [] = StringUtils.split(host, ":");
                sockets.add(new InetSocketAddress(hostParts[0], Integer.valueOf(hostParts[1])));
                LOG.debug("Connecting to [" + host + "] with port [" + hostParts[1] + "]");
            } else {
                sockets.add(new InetSocketAddress(host, ProtocolOptions.DEFAULT_PORT));
                LOG.debug("Connecting to [" + host + "] with port [" + ProtocolOptions.DEFAULT_PORT + "]");
            }
        }

        Cluster.Builder builder = Cluster.builder().addContactPointsWithPorts(sockets).withCompression(compression);
        QueryOptions queryOptions = new QueryOptions();
        queryOptions.setConsistencyLevel(clusterConsistencyLevel);
        queryOptions.setSerialConsistencyLevel(serialConsistencyLevel);
        builder = builder.withQueryOptions(queryOptions);

        if (StringUtils.isNotEmpty(clusterName)) {
            builder = builder.withClusterName(clusterName);
        }

        return builder;

    }
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:28,代码来源:ConstructorConfiguredCqlClientFactory.java

示例8: testGetClusterBuilder

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
@Test
public void testGetClusterBuilder() throws Exception {
    final Map<Object, Object> configuration = new HashMap<Object,Object>();
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CQL_HOSTS, HOSTS);
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CLUSTER_NAME, CLUSTER_NAME);
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_READ_TIMEOUT, READ_TIMEOUT);
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CONNECT_TIMEOUT, CONNECT_TIMEOUT);
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_LOCAL_DATA_CENTER_NAME, DATA_CENTER_NAME);
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CONSISTENCY, DEFAULT_CONSISTENCY_LEVEL.name());
    configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_SERIAL_CONSISTENCY, DEFAULT_SERIAL_CONSISTENCY_LEVEL.name());

    final CqlClientFactory factory =
            new MapConfiguredCqlClientFactory(configuration);

    final Cluster.Builder clusterBuilder = factory.getClusterBuilder();
    Assert.assertEquals(CLUSTER_NAME, clusterBuilder.getClusterName());
    final InetSocketAddress first = clusterBuilder.getContactPoints().get(0);
    final InetSocketAddress second = clusterBuilder.getContactPoints().get(1);
    Assert.assertEquals("localhost", first.getHostName());
    Assert.assertEquals(9042, first.getPort());
    Assert.assertEquals("remotehost", second.getHostName());
    Assert.assertEquals(1234, second.getPort());
    Assert.assertEquals(Integer.parseInt(CONNECT_TIMEOUT), clusterBuilder.getConfiguration().getSocketOptions().getConnectTimeoutMillis());
    Assert.assertEquals(Integer.parseInt(READ_TIMEOUT), clusterBuilder.getConfiguration().getSocketOptions().getReadTimeoutMillis());
    Assert.assertEquals(DEFAULT_CONSISTENCY_LEVEL, clusterBuilder.getConfiguration().getQueryOptions().getConsistencyLevel());
    Assert.assertEquals(DEFAULT_SERIAL_CONSISTENCY_LEVEL, clusterBuilder.getConfiguration().getQueryOptions().getSerialConsistencyLevel());
    Assert.assertEquals(ProtocolOptions.Compression.NONE, clusterBuilder.getConfiguration().getProtocolOptions().getCompression());
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:29,代码来源:MapConfiguredCqlClientFactoryTest.java

示例9: setCompression

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
/**
 * Sets compression algorithm to use for the transport.
 *
 * @param compression Compression algorithm.
 */
@SuppressWarnings("UnusedDeclaration")
public void setCompression(String compression) {
    this.compression = compression == null || compression.trim().isEmpty() ? null : compression.trim();

    try {
        if (this.compression != null)
            ProtocolOptions.Compression.valueOf(this.compression);
    }
    catch (Throwable e) {
        throw new IgniteException("Incorrect compression '" + compression + "' specified for Cassandra connection", e);
    }

    invalidate();
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:DataSource.java

示例10: getCluster

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public static Cluster getCluster(String[] hosts, Configuration conf, int port)
{
    Optional<AuthProvider> authProvider = getAuthProvider(conf);
    Optional<SSLOptions> sslOptions = getSSLOptions(conf);
    Optional<Integer> protocolVersion = getProtocolVersion(conf);
    LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(hosts);
    SocketOptions socketOptions = getReadSocketOptions(conf);
    QueryOptions queryOptions = getReadQueryOptions(conf);
    PoolingOptions poolingOptions = getReadPoolingOptions(conf);

    Cluster.Builder builder = Cluster.builder()
            .addContactPoints(hosts)
            .withPort(port)
            .withCompression(ProtocolOptions.Compression.NONE);

    if (authProvider.isPresent())
        builder.withAuthProvider(authProvider.get());
    if (sslOptions.isPresent())
        builder.withSSL(sslOptions.get());

    if (protocolVersion.isPresent()) {
        builder.withProtocolVersion(ProtocolVersion.fromInt(protocolVersion.get()));
    }
    builder.withLoadBalancingPolicy(loadBalancingPolicy)
            .withSocketOptions(socketOptions)
            .withQueryOptions(queryOptions)
            .withPoolingOptions(poolingOptions);

    return builder.build();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:CqlConfigHelper.java

示例11: CassandraMetricBatch

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public CassandraMetricBatch(Metadata metadata, ProtocolOptions protocol, CodecRegistry codec,
    TokenAwarePolicy lbPolicy, int batchLimit) {
  this.protocol = protocol;
  this.codec = codec;
  this.metadata = metadata;
  this.policy = lbPolicy;
  metricQueries = new HashMap<>();
  this.batchLimit = batchLimit;

  metricQueries = new HashMap<>();
  dimensionQueries = new HashMap<>();
  dimensionMetricQueries = new HashMap<>();
  metricDimensionQueries = new HashMap<>();
  measurementQueries = new HashMap<>();
}
 
开发者ID:openstack,项目名称:monasca-persister,代码行数:16,代码来源:CassandraMetricBatch.java

示例12: getInputCluster

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public static Cluster getInputCluster(String[] hosts, Configuration conf)
{
    int port = getInputNativePort(conf);
    Optional<AuthProvider> authProvider = getAuthProvider(conf);
    Optional<SSLOptions> sslOptions = getSSLOptions(conf);
    LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(conf, hosts);
    SocketOptions socketOptions = getReadSocketOptions(conf);
    QueryOptions queryOptions = getReadQueryOptions(conf);
    PoolingOptions poolingOptions = getReadPoolingOptions(conf);
    
    Cluster.Builder builder = Cluster.builder()
                                     .addContactPoints(hosts)
                                     .withPort(port)
                                     .withCompression(ProtocolOptions.Compression.NONE);

    if (authProvider.isPresent())
        builder.withAuthProvider(authProvider.get());
    if (sslOptions.isPresent())
        builder.withSSL(sslOptions.get());

    builder.withLoadBalancingPolicy(loadBalancingPolicy)
           .withSocketOptions(socketOptions)
           .withQueryOptions(queryOptions)
           .withPoolingOptions(poolingOptions);

    return builder.build();
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:28,代码来源:CqlConfigHelper.java

示例13: getInputCluster

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
public static Cluster getInputCluster(String host, Configuration conf)
{
    int port = getInputNativePort(conf);
    Optional<AuthProvider> authProvider = getAuthProvider(conf);
    Optional<SSLOptions> sslOptions = getSSLOptions(conf);
    LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(conf, host);
    SocketOptions socketOptions = getReadSocketOptions(conf);
    QueryOptions queryOptions = getReadQueryOptions(conf);
    PoolingOptions poolingOptions = getReadPoolingOptions(conf);
    
    Cluster.Builder builder = Cluster.builder()
                                     .addContactPoint(host)
                                     .withPort(port)
                                     .withCompression(ProtocolOptions.Compression.NONE);

    if (authProvider.isPresent())
        builder.withAuthProvider(authProvider.get());
    if (sslOptions.isPresent())
        builder.withSSL(sslOptions.get());

    builder.withLoadBalancingPolicy(loadBalancingPolicy)
           .withSocketOptions(socketOptions)
           .withQueryOptions(queryOptions)
           .withPoolingOptions(poolingOptions);

    return builder.build();
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:28,代码来源:CqlConfigHelper.java

示例14: setCompression

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
/**
 * Derive the compression option from the enum based on the given string. Defaults to NONE.
 * 
 * @param compression
 *            The name of the compression chosen (either NONE, SNAPPY or LZ4)
 */
public void setCompression(String compression) {
	try {
		this.compression = ProtocolOptions.Compression.valueOf(compression);
	} catch(Exception e) {
		this.compression = ProtocolOptions.Compression.NONE;
	}
}
 
开发者ID:nea,项目名称:vertx-mod-cassandra-persistor,代码行数:14,代码来源:CassandraPersistor.java

示例15: shouldCreateClusterWithConfig

import com.datastax.driver.core.ProtocolOptions; //导入依赖的package包/类
@Test
public void shouldCreateClusterWithConfig() throws Exception {

	CassandraServiceInfo info = new CassandraServiceInfo("local",
			Collections.singletonList("127.0.0.1"), 9142);

	CassandraClusterConfig config = new CassandraClusterConfig();
	config.setCompression(ProtocolOptions.Compression.NONE);
	config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234));
	config.setQueryOptions(new QueryOptions());
	config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
	config.setLoadBalancingPolicy(new RoundRobinPolicy());
	config.setReconnectionPolicy(new ConstantReconnectionPolicy(1));
	config.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
	config.setSocketOptions(new SocketOptions());

	Cluster cluster = creator.create(info, config);

	Configuration configuration = cluster.getConfiguration();

	assertThat(configuration.getProtocolOptions().getCompression(),
			is(config.getCompression()));
	assertThat(configuration.getQueryOptions(), is(config.getQueryOptions()));
	assertThat(configuration.getSocketOptions(), is(config.getSocketOptions()));

	Policies policies = configuration.getPolicies();
	assertThat(policies.getLoadBalancingPolicy(),
			is(config.getLoadBalancingPolicy()));
	assertThat(policies.getReconnectionPolicy(), is(config.getReconnectionPolicy()));
	assertThat(policies.getRetryPolicy(), is(config.getRetryPolicy()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:32,代码来源:CassandraClusterCreatorTest.java


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