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); }
@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); }
/** * 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(); }
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(); }
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(); }
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; }
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; }
@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()); }
/** * 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(); }
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(); }
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<>(); }
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(); }
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(); }
/** * 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; } }
@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())); }
/** * 描述: 初始化配置 * 时间: 2017年11月15日 上午11:25:07 * @author yi.zhang * @param servers 服务地址 * @param keyspace 命名空间 * @param username 账号 * @param password 密码 */ public void init(String servers,String keyspace,String username,String password) { try { // socket 链接配置 SocketOptions socket = new SocketOptions(); socket.setKeepAlive(true); socket.setReceiveBufferSize(1024* 1024); socket.setSendBufferSize(1024* 1024); socket.setConnectTimeoutMillis(5 * 1000); socket.setReadTimeoutMillis(1000); //设置连接池 PoolingOptions pool = new PoolingOptions(); // pool.setMaxRequestsPerConnection(HostDistance.LOCAL, 32); // pool.setMaxRequestsPerConnection(HostDistance.REMOTE, 32); // pool.setCoreConnectionsPerHost(HostDistance.LOCAL, 2); // pool.setCoreConnectionsPerHost(HostDistance.REMOTE, 2); // pool.setMaxConnectionsPerHost(HostDistance.LOCAL, 4); // pool.setMaxConnectionsPerHost(HostDistance.REMOTE, 4); pool.setHeartbeatIntervalSeconds(60); pool.setIdleTimeoutSeconds(120); pool.setPoolTimeoutMillis(5 * 1000); List<InetSocketAddress> saddress = new ArrayList<InetSocketAddress>(); if (servers != null && !"".equals(servers)) { for (String server : servers.split(",")) { String[] address = server.split(":"); String ip = address[0]; int port = 9042; if (address != null && address.length > 1) { port = Integer.valueOf(address[1]); } saddress.add(new InetSocketAddress(ip, port)); } } InetSocketAddress[] addresses = new InetSocketAddress[saddress.size()]; saddress.toArray(addresses); Builder builder = Cluster.builder(); builder.withSocketOptions(socket); // 设置压缩方式 builder.withCompression(ProtocolOptions.Compression.LZ4); // 负载策略 // DCAwareRoundRobinPolicy loadBalance = DCAwareRoundRobinPolicy.builder().withLocalDc("localDc").withUsedHostsPerRemoteDc(2).allowRemoteDCsForLocalConsistencyLevel().build(); // builder.withLoadBalancingPolicy(loadBalance); // 重试策略 builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE); builder.withPoolingOptions(pool); builder.addContactPointsWithPorts(addresses); builder.withCredentials(username, password); Cluster cluster = builder.build(); if (keyspace != null && !"".equals(keyspace)) { session = cluster.connect(keyspace); } else { session = cluster.connect(); } mapping = new MappingManager(session); } catch (Exception e) { logger.error("-----Cassandra Config init Error-----", e); } }
public ProtocolOptions.Compression compression() { return ProtocolOptions.Compression.valueOf(compression); }
@Override public CompletableFuture<CassandraMessageStore> open() { CompletableFuture<CassandraMessageStore> future = new CompletableFuture<>(); executor.execute(() -> { try { // Create session to hosts // PoolingOptions pools = new PoolingOptions(); // pools.setMaxSimultaneousRequestsPerConnectionThreshold( // HostDistance.LOCAL, maxSimultaneousRequests); // int maxConnections = 1; // pools.setCoreConnectionsPerHost(HostDistance.LOCAL, // maxConnections); // pools.setMaxConnectionsPerHost(HostDistance.LOCAL, // maxConnections); // pools.setCoreConnectionsPerHost(HostDistance.REMOTE, // maxConnections); // pools.setMaxConnectionsPerHost(HostDistance.REMOTE, // maxConnections); cluster = new Cluster.Builder().addContactPoints(contactPoints) // .withPoolingOptions(pools) .withSocketOptions(new SocketOptions().setTcpNoDelay(true)).build(); cluster.getConfiguration().getProtocolOptions() .setCompression(ProtocolOptions.Compression.LZ4); session = cluster.connect("system"); Metadata metadata = cluster.getMetadata(); System.out.println(String.format("Connected to cluster '%s' on %s.", metadata.getClusterName(), metadata.getAllHosts())); // if (!schemaExists()) { buildSchema(); // } session.execute(new SimpleStatement("USE " + KEYSPACE_NAME)); System.out.format("Using keyspace %s\n", KEYSPACE_NAME); boundInsertStatement = prepareInsertStatement(); boundSelectStatement = prepareSelectStatement(); boundSelectMaxStatement = prepareSelectMaxStatement(); } catch (DriverException | StoreException ex) { future.completeExceptionally(ex); } }); return future; }
public ConstructorConfiguredCqlClientFactory(String hosts) { this(hosts, null, ConsistencyLevel.QUORUM, QueryOptions.DEFAULT_SERIAL_CONSISTENCY_LEVEL, ProtocolOptions.Compression.NONE); }
public ConstructorConfiguredCqlClientFactory(String hosts, ConsistencyLevel clusterConsistency) { this(hosts, null, clusterConsistency, QueryOptions.DEFAULT_SERIAL_CONSISTENCY_LEVEL, ProtocolOptions.Compression.NONE); }
private void configureCompression() { final String compressionConfiguration = (String) configuration.get(TRIDENT_CASSANDRA_COMPRESSION); if (StringUtils.isNotEmpty(compressionConfiguration)) { builder = builder.withCompression(ProtocolOptions.Compression.valueOf(compressionConfiguration)); } }
public ProtocolOptions.Compression getCompression() { return compression; }
public void setCompression(ProtocolOptions.Compression compression) { this.compression = compression; }
public ProtocolOptions getProtocolOptions() { return cluster.getConfiguration().getProtocolOptions(); }
/** * @return the protocolOptions */ public ProtocolOptions getProtocolOptions() { return protocolOptions; }
/** * 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(); }
public Integer getCassandraPort() { if (cassandraPort != null) return cassandraPort; else return ProtocolOptions.DEFAULT_PORT; }
private Cluster.Builder populateSettings(Cluster.Builder builder, Properties properties) { String serversParam = properties.getProperty(CassandraStoreParameters.CASSANDRA_SERVERS); String[] servers = serversParam.split(","); for (String server : servers) { builder = builder.addContactPoint(server); } String portProp = properties.getProperty(CassandraStoreParameters.PORT); if (portProp != null) { builder = builder.withPort(Integer.parseInt(portProp)); } String clusterNameProp = properties.getProperty(CassandraStoreParameters.CLUSTER_NAME); if (clusterNameProp != null) { builder = builder.withClusterName(clusterNameProp); } String compressionProp = properties.getProperty(CassandraStoreParameters.COMPRESSION); if (compressionProp != null) { builder = builder.withCompression(ProtocolOptions.Compression.valueOf(compressionProp)); } builder = this.populateCredentials(properties, builder); builder = this.populateLoadBalancingProp(properties, builder); String enableJMXProp = properties.getProperty(CassandraStoreParameters.ENABLE_JMX_REPORTING); if (!Boolean.parseBoolean(enableJMXProp)) { builder = builder.withoutJMXReporting(); } String enableMetricsProp = properties.getProperty(CassandraStoreParameters.ENABLE_METRICS); if (!Boolean.parseBoolean(enableMetricsProp)) { builder = builder.withoutMetrics(); } builder = this.populatePoolingSettings(properties, builder); String versionProp = properties.getProperty(CassandraStoreParameters.PROTOCOL_VERSION); if (versionProp != null) { builder = builder.withProtocolVersion(ProtocolVersion.fromInt(Integer.parseInt(versionProp))); } builder = this.populateQueryOptions(properties, builder); builder = this.populateReconnectPolicy(properties, builder); builder = this.populateRetrytPolicy(properties, builder); builder = this.populateSocketOptions(properties, builder); String enableSSLProp = properties.getProperty(CassandraStoreParameters.ENABLE_SSL); if (enableSSLProp != null) { if (Boolean.parseBoolean(enableSSLProp)) { builder = builder.withSSL(); } } return builder; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Element optionsElement = DomUtils.getChildElementByTagName(element, ELEMENT_CASSANDRA_OPTIONS); BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder .genericBeanDefinition(CassandraClusterConfig.class.getName()); if (optionsElement != null) { String compressionString = optionsElement.getAttribute(COMPRESSION_ATTRIBUTE); if (!StringUtils.isEmpty(compressionString)) { ProtocolOptions.Compression compression = ProtocolOptions.Compression .valueOf(compressionString); beanBuilder.addPropertyValue("compression", compression); } String retryPolicyString = optionsElement .getAttribute(RETRY_POLICY_ATTRIBUTE); if (!StringUtils.isEmpty(retryPolicyString)) { beanBuilder.addPropertyReference("retryPolicy", retryPolicyString); } String loadBalancingPolicyString = optionsElement .getAttribute(LOAD_BALANCING_POLICY_ATTRIBUTE); if (!StringUtils.isEmpty(loadBalancingPolicyString)) { beanBuilder.addPropertyReference("loadBalancingPolicy", loadBalancingPolicyString); } String socketOptionsString = optionsElement .getAttribute(SOCKET_OPTIONS_ATTRIBUTE); if (!StringUtils.isEmpty(socketOptionsString)) { beanBuilder.addPropertyReference("socketOptions", socketOptionsString); } String reconnectionPolicyString = optionsElement .getAttribute(RECONNECTION_POLICY_ATTRIBUTE); if (!StringUtils.isEmpty(reconnectionPolicyString)) { beanBuilder.addPropertyReference("reconnectionPolicy", reconnectionPolicyString); } } builder.addConstructorArgValue(beanBuilder.getBeanDefinition()); }
/** * Create a {@link CassandraKeyspace} test rule to provide a running Cassandra instance on {@code localhost:9042} with * a keyspace {@code example}. Reuses a running Cassandra instance if available or starts an embedded instance. * * @return the {@link CassandraKeyspace} rule. */ public static CassandraKeyspace onLocalhost() { return new CassandraKeyspace("localhost", ProtocolOptions.DEFAULT_PORT, "example", Cassandra.embeddedIfNotRunning("localhost", ProtocolOptions.DEFAULT_PORT), new Version(0, 0, 0)); }
/** * @param protocolOptions * the protocolOptions to set */ public void setProtocolOptions(ProtocolOptions protocolOptions) { this.protocolOptions = protocolOptions; }