@Bean public CassandraClusterFactoryBean cluster() { CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); cluster.setContactPoints(environment.getProperty("com.iot.app.cassandra.host")); cluster.setPort(Integer.parseInt(environment.getProperty("com.iot.app.cassandra.port"))); return cluster; }
/** * Returns the initialized {@link Cluster} instance. * * @return the {@link Cluster}. * @throws IllegalStateException if the cluster factory is not initialized. */ protected Cluster getRequiredCluster() { CassandraClusterFactoryBean factoryBean = cluster(); Assert.state(factoryBean.getObject() != null, "Cluster factory not initialized"); return factoryBean.getObject(); }
@Override public void destroy() { if (cluster != null) { executeSpecsAndScripts(keyspaceDrops, shutdownScripts, cluster); cluster.close(); } }
public CassandraClusterFactoryBean cluster() { CassandraClusterFactoryBean bean = new CassandraClusterFactoryBean(); bean.setAddressTranslator(getAddressTranslator()); bean.setAuthProvider(getAuthProvider()); bean.setClusterBuilderConfigurer(getClusterBuilderConfigurer()); bean.setClusterName(getClusterName()); bean.setCompressionType(getCompressionType()); bean.setContactPoints(getContactPoints()); bean.setLoadBalancingPolicy(getLoadBalancingPolicy()); bean.setMaxSchemaAgreementWaitSeconds(getMaxSchemaAgreementWaitSeconds()); bean.setMetricsEnabled(getMetricsEnabled()); bean.setNettyOptions(getNettyOptions()); bean.setPoolingOptions(getPoolingOptions()); bean.setPort(getPort()); bean.setProtocolVersion(getProtocolVersion()); bean.setQueryOptions(getQueryOptions()); bean.setReconnectionPolicy(getReconnectionPolicy()); bean.setRetryPolicy(getRetryPolicy()); bean.setSpeculativeExecutionPolicy(getSpeculativeExecutionPolicy()); bean.setSocketOptions(getSocketOptions()); bean.setTimestampGenerator(getTimestampGenerator()); bean.setKeyspaceCreations(getKeyspaceCreations()); bean.setKeyspaceDrops(getKeyspaceDrops()); bean.setStartupScripts(getStartupScripts()); bean.setShutdownScripts(getShutdownScripts());
Cluster.Builder clusterBuilder = newClusterBuilder(); Optional.ofNullable(resolveClusterName()).filter(StringUtils::hasText).ifPresent(clusterBuilder::withClusterName); Optional.ofNullable(latencyTracker).ifPresent(cluster::register); generateSpecificationsFromFactoryBeans(); startup.addAll(keyspaceAlterations); executeSpecsAndScripts(startup, startupScripts, cluster);
/** * Examines the contents of all the KeyspaceSpecificationFactoryBeans and generates the proper KeyspaceSpecification * from them. */ private void generateSpecificationsFromFactoryBeans() { generateSpecifications(keyspaceSpecifications); keyspaceActions.forEach(actions -> generateSpecifications(actions.getActions())); }
@Bean public CassandraClusterFactoryBean cluster() { CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); cluster.setContactPoints(properties.getCassandra().getContactpoints()); cluster.setPort(properties.getCassandra().getPort()); return cluster; }
@Bean public CassandraSessionFactoryBean session() throws Exception { CassandraSessionFactoryBean session = new CassandraSessionFactoryBean(); session.setCluster(cluster().getObject()); session.setKeyspaceName(properties.getCassandra().getKeyspace()); session.setConverter(converter()); session.setSchemaAction(SchemaAction.NONE); return session; }