Search in sources :

Example 26 with Cluster

use of com.datastax.driver.core.Cluster in project zipkin by openzipkin.

the class Schema method getKeyspaceMetadata.

static KeyspaceMetadata getKeyspaceMetadata(Session session) {
    String keyspace = session.getLoggedKeyspace();
    Cluster cluster = session.getCluster();
    KeyspaceMetadata keyspaceMetadata = cluster.getMetadata().getKeyspace(keyspace);
    if (keyspaceMetadata == null) {
        throw new IllegalStateException(String.format("Cannot read keyspace metadata for give keyspace: %s and cluster: %s", keyspace, cluster.getClusterName()));
    }
    return keyspaceMetadata;
}
Also used : Cluster(com.datastax.driver.core.Cluster) KeyspaceMetadata(com.datastax.driver.core.KeyspaceMetadata)

Example 27 with Cluster

use of com.datastax.driver.core.Cluster in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method customizerOverridesAutoConfig.

@Test
public void customizerOverridesAutoConfig() {
    load(SimpleCustomizerConfig.class, "spring.data.cassandra.cluster-name=testcluster");
    assertThat(this.context.getBeanNamesForType(Cluster.class).length).isEqualTo(1);
    Cluster cluster = this.context.getBean(Cluster.class);
    assertThat(cluster.getClusterName()).isEqualTo("overridden-name");
}
Also used : Cluster(com.datastax.driver.core.Cluster) Test(org.junit.Test)

Example 28 with Cluster

use of com.datastax.driver.core.Cluster in project spring-boot by spring-projects.

the class CassandraTestServer method newCluster.

private Cluster newCluster() {
    Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
    testCluster(cluster);
    return cluster;
}
Also used : Cluster(com.datastax.driver.core.Cluster)

Example 29 with Cluster

use of com.datastax.driver.core.Cluster in project presto by prestodb.

the class EmbeddedCassandra method start.

public static synchronized void start() throws Exception {
    if (initialized) {
        return;
    }
    log.info("Starting cassandra...");
    System.setProperty("cassandra.config", "file:" + prepareCassandraYaml());
    System.setProperty("cassandra-foreground", "true");
    System.setProperty("cassandra.native.epoll.enabled", "false");
    CassandraDaemon cassandraDaemon = new CassandraDaemon();
    cassandraDaemon.activate();
    Cluster cluster = Cluster.builder().withProtocolVersion(V3).withClusterName("TestCluster").addContactPointsWithPorts(ImmutableList.of(new InetSocketAddress(HOST, PORT))).build();
    CassandraSession session = new NativeCassandraSession("EmbeddedCassandra", JsonCodec.listJsonCodec(ExtraColumnMetadata.class), cluster, new Duration(1, MINUTES));
    try {
        checkConnectivity(session);
    } catch (RuntimeException e) {
        cluster.close();
        cassandraDaemon.deactivate();
        throw e;
    }
    EmbeddedCassandra.session = session;
    initialized = true;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Cluster(com.datastax.driver.core.Cluster) Duration(io.airlift.units.Duration) CassandraDaemon(org.apache.cassandra.service.CassandraDaemon)

Example 30 with Cluster

use of com.datastax.driver.core.Cluster in project camel by apache.

the class CassandraComponentBeanRefTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    if (canTest()) {
        Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
        registry.bind("cassandraCluster", cluster);
        registry.bind("cassandraSession", cluster.connect("camel_ks"));
        registry.bind("insertCql", CQL);
    }
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Cluster(com.datastax.driver.core.Cluster)

Aggregations

Cluster (com.datastax.driver.core.Cluster)41 Session (com.datastax.driver.core.Session)17 Test (org.junit.Test)17 ResultSet (com.datastax.driver.core.ResultSet)11 Row (com.datastax.driver.core.Row)9 KeyspaceMetadata (com.datastax.driver.core.KeyspaceMetadata)6 ArrayList (java.util.ArrayList)5 PoolingOptions (com.datastax.driver.core.PoolingOptions)4 ReconnectionPolicy (com.datastax.driver.core.policies.ReconnectionPolicy)4 TokenAwarePolicy (com.datastax.driver.core.policies.TokenAwarePolicy)4 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)4 QueryOptions (com.datastax.driver.core.QueryOptions)3 TableMetadata (com.datastax.driver.core.TableMetadata)3 DCAwareRoundRobinPolicy (com.datastax.driver.core.policies.DCAwareRoundRobinPolicy)3 Update (com.datastax.driver.core.querybuilder.Update)3 InetSocketAddress (java.net.InetSocketAddress)3 Host (com.datastax.driver.core.Host)2 JdkSSLOptions (com.datastax.driver.core.JdkSSLOptions)2 Metadata (com.datastax.driver.core.Metadata)2 PlainTextAuthProvider (com.datastax.driver.core.PlainTextAuthProvider)2