/** * Add field use_raw_configuration_schema to endpointProfile that used to support devices using * SDK version 0.9.0 */ public void transform() { //mongo MongoClient client = new MongoClient(host); MongoDatabase database = client.getDatabase(dbName); MongoCollection<Document> endpointProfile = database.getCollection("endpoint_profile"); endpointProfile.updateMany(new Document(), eq("$set", eq("use_raw_schema", false))); //cassandra Cluster cluster = Cluster.builder().addContactPoint(host).build(); Session session = cluster.connect(dbName); session.execute("ALTER TABLE ep_profile ADD use_raw_schema boolean"); session.close(); cluster.close(); } }
@Override public Cluster get() { String host = configuration.getHostAddress(); int port = configuration.getPort(); LOGGER.info("Connecting to cassandra cluster with host:{}, port:{}", host, port); Cluster cluster = Cluster.builder() .addContactPoint(host) .withPort(port) .build(); Metadata metadata = cluster.getMetadata(); LOGGER.info("Connected to cluster: {}", metadata.getClusterName()); metadata.getAllHosts().forEach(h -> { LOGGER.info("Datacenter:{}, host:{}, rack: {}", h.getDatacenter(), h.getAddress(), h.getRack()); }); return cluster; } }
@Override protected void before() throws Throwable { dependency.before(); Cluster cluster = Cluster.builder().addContactPoint(getHost()).withPort(getPort()) .withNettyOptions(new NettyOptions() { @Override public void onClusterClose(EventLoopGroup eventLoopGroup) { eventLoopGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).syncUninterruptibly(); } }).build(); Session session = cluster.newSession(); try { if (requiredVersion != null) { Version cassandraReleaseVersion = CassandraVersion.getReleaseVersion(session); if (cassandraReleaseVersion.isLessThan(requiredVersion)) { throw new AssumptionViolatedException( String.format("Cassandra at %s:%s runs in Version %s but we require at least %s", getHost(), getPort(), cassandraReleaseVersion, requiredVersion)); } } session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s \n" + "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", keyspaceName)); } finally { session.close(); cluster.close(); } }
/** * Set a list of hosts, where some of cluster nodes is located. * * @param contactPoints the list of hosts * @return a reference to this, so the API can be used fluently */ public CassandraClientOptions setContactPoints(List<String> contactPoints) { for (String contactPoint : contactPoints) { builder.addContactPoint(contactPoint); } return this; }
public CassandraTweetRepository(String cassandraHost, int cassandraPort, String keyspaceName) { m_cassandraHost = cassandraHost; m_cassandraPort = cassandraPort; m_keyspaceName = keyspaceName; LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort); cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(m_cassandraHost).build(); session = cluster.connect(m_keyspaceName); LOG.info("Connected."); }
public RegisterConsumer(String host, String keyspace) { Cluster cluster = Cluster.builder().addContactPoint(host).build(); session = cluster.connect(keyspace); session.execute(CREATE_TABLE_IF_EXIST); }
@Provides @Singleton Cluster provideCassandraCluster(ReconnectionPolicy reconnectionPolicy) { return Cluster.builder() .addContactPoint("cassandra-02.dev.redroma.tech") .withPort(9042) .withCredentials("cassandra", "cassandra") .withReconnectionPolicy(reconnectionPolicy) .build(); }
public CassandraQueryExecutor(Configuration configuration) { cluster = Cluster.builder() .addContactPoint(configuration.getStringMandatory("databases.cassandra.host")) .withPort(configuration.getIntMandatory("databases.cassandra.port")) .build(); }
connectionBuilder.addContactPoint(host.getHost()).withPort(host.getPort()); if (host.getUser() != null)
.addContactPoint(TestUtils.ipOfNode(1)) .withPort(scassandra.getBinaryPort()) .withPoolingOptions(
public Builder createBuilder() { Builder builder = Cluster.builder(); for (String address : contactPoints) { builder.addContactPoint(address);
/** * Adds contact points. * * <p>See {@link Builder#addContactPoint} for more details on contact points. * * <p>Note that all contact points must be resolvable; if <em>any</em> of them cannot be * resolved, this method will fail. * * @param addresses addresses of the nodes to add as contact points. * @return this Builder. * @throws IllegalArgumentException if any of the given {@code addresses} could not be resolved. * @throws SecurityException if a security manager is present and permission to resolve the host * name is denied. * @see Builder#addContactPoint */ public Builder addContactPoints(String... addresses) { for (String address : addresses) addContactPoint(address); return this; }
/** @jira_ticket JAVA-1209 */ @Test(groups = "unit") public void getProtocolVersion_should_return_null_if_not_connected() { Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build(); assertThat(cluster.getConfiguration().getProtocolOptions().getProtocolVersion()).isNull(); }
builder.addContactPoint(hostPort.getKey()) .withPort(hostPort.getValue());
/** * Create entity that responsible for data migration from old tables notification to * new ctl based ones. * * @param connection the connection to relational database * @param options the options for configuring NoSQL databases */ public CtlNotificationMigration(Connection connection, Options options) { super(connection); client = new MongoClient(options.getHost()); cluster = Cluster.builder() .addContactPoint(options.getHost()) .build(); dbName = options.getDbName(); this.nosql = options.getDbName(); }
/** * Create a new instance of UpdateUuidsMigration. * * @param connection the connection to relational database * @param options the options for configuring NoSQL databases */ public UpdateUuidsMigration(Connection connection, Options options) { this.connection = connection; client = new MongoClient(options.getHost()); cluster = Cluster.builder() .addContactPoint(options.getHost()) .build(); dbName = options.getDbName(); this.nosql = options.getNoSql(); }
/** * Creates new EndpointSpecificConfigurationMigration instance. */ public EndpointSpecificConfigurationMigration(String host, String db, String nosql) { cluster = Cluster.builder() .addContactPoint(host) .build(); dbName = db; this.nosql = nosql; }
public static Cluster getCluster(ContainerState containerState) { return Cluster.builder() .addContactPoint(containerState.getContainerIpAddress()) .withPort(containerState.getMappedPort(CQL_PORT)) .build(); }
private ResultSet performQuery(CassandraContainer cassandraContainer, String cql) { Cluster explicitCluster = Cluster.builder() .addContactPoint(cassandraContainer.getContainerIpAddress()) .withPort(cassandraContainer.getMappedPort(CassandraContainer.CQL_PORT)) .build(); return performQuery(explicitCluster, cql); }
@Override protected Cluster buildCluster(Cluster.Builder builder) { return builder.addContactPoint(host).withPort(port).build(); } };