Search in sources :

Example 1 with CQLDataLoader

use of org.cassandraunit.CQLDataLoader in project camel by apache.

the class CassandraUnitUtils method loadCQLDataSet.

public static void loadCQLDataSet(Session session, String dataSetCql) {
    if (canTest()) {
        CQLDataLoader loader = new CQLDataLoader(session);
        loader.load(cqlDataSet(dataSetCql));
    }
}
Also used : CQLDataLoader(org.cassandraunit.CQLDataLoader)

Example 2 with CQLDataLoader

use of org.cassandraunit.CQLDataLoader in project thingsboard by thingsboard.

the class CustomCassandraCQLUnit method load.

@Override
protected void load() {
    String hostIp = EmbeddedCassandraServerHelper.getHost();
    int port = EmbeddedCassandraServerHelper.getNativeTransportPort();
    cluster = new Cluster.Builder().addContactPoints(hostIp).withPort(port).withSocketOptions(getSocketOptions()).build();
    session = cluster.connect();
    CQLDataLoader dataLoader = new CQLDataLoader(session);
    dataSets.forEach(dataLoader::load);
    session = dataLoader.getSession();
}
Also used : Cluster(com.datastax.driver.core.Cluster) CQLDataLoader(org.cassandraunit.CQLDataLoader)

Example 3 with CQLDataLoader

use of org.cassandraunit.CQLDataLoader in project zeppelin by apache.

the class CassandraInterpreterTest method setUp.

@BeforeClass
public static synchronized void setUp() throws IOException, InterruptedException {
    System.setProperty("cassandra.skip_wait_for_gossip_to_settle", "0");
    System.setProperty("cassandra.load_ring_state", "false");
    System.setProperty("cassandra.initial_token", "0");
    System.setProperty("cassandra.num_tokens", "nil");
    System.setProperty("cassandra.allocate_tokens_for_local_replication_factor", "nil");
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    CqlSession session = EmbeddedCassandraServerHelper.getSession();
    new CQLDataLoader(session).load(new ClassPathCQLDataSet("prepare_all.cql", "zeppelin"));
    Properties properties = new Properties();
    properties.setProperty(CASSANDRA_CLUSTER_NAME, EmbeddedCassandraServerHelper.getClusterName());
    properties.setProperty(CASSANDRA_COMPRESSION_PROTOCOL, "NONE");
    properties.setProperty(CASSANDRA_CREDENTIALS_USERNAME, "none");
    properties.setProperty(CASSANDRA_CREDENTIALS_PASSWORD, "none");
    properties.setProperty(CASSANDRA_LOAD_BALANCING_POLICY, "DEFAULT");
    properties.setProperty(CASSANDRA_RETRY_POLICY, "DEFAULT");
    properties.setProperty(CASSANDRA_RECONNECTION_POLICY, "DEFAULT");
    properties.setProperty(CASSANDRA_SPECULATIVE_EXECUTION_POLICY, "DEFAULT");
    properties.setProperty(CASSANDRA_POOLING_CONNECTION_PER_HOST_LOCAL, "2");
    properties.setProperty(CASSANDRA_POOLING_CONNECTION_PER_HOST_REMOTE, "1");
    properties.setProperty(CASSANDRA_POOLING_MAX_REQUESTS_PER_CONNECTION, "1024");
    properties.setProperty(CASSANDRA_POOLING_POOL_TIMEOUT_MILLIS, "5000");
    properties.setProperty(CASSANDRA_POOLING_HEARTBEAT_INTERVAL_SECONDS, "30");
    properties.setProperty(CASSANDRA_QUERY_DEFAULT_CONSISTENCY, "ONE");
    properties.setProperty(CASSANDRA_QUERY_DEFAULT_SERIAL_CONSISTENCY, "SERIAL");
    properties.setProperty(CASSANDRA_QUERY_DEFAULT_FETCH_SIZE, "5000");
    properties.setProperty(CASSANDRA_SOCKET_CONNECTION_TIMEOUT_MILLIS, "5000");
    properties.setProperty(CASSANDRA_SOCKET_READ_TIMEOUT_MILLIS, "12000");
    properties.setProperty(CASSANDRA_SOCKET_TCP_NO_DELAY, "true");
    properties.setProperty(CASSANDRA_HOSTS, EmbeddedCassandraServerHelper.getHost());
    properties.setProperty(CASSANDRA_PORT, Integer.toString(EmbeddedCassandraServerHelper.getNativeTransportPort()));
    properties.setProperty("datastax-java-driver.advanced.connection.pool.local.size", "1");
    interpreter = new CassandraInterpreter(properties);
    interpreter.open();
}
Also used : Properties(java.util.Properties) CqlSession(com.datastax.oss.driver.api.core.CqlSession) ClassPathCQLDataSet(org.cassandraunit.dataset.cql.ClassPathCQLDataSet) CQLDataLoader(org.cassandraunit.CQLDataLoader) BeforeClass(org.junit.BeforeClass)

Example 4 with CQLDataLoader

use of org.cassandraunit.CQLDataLoader in project jhipster-sample-app-cassandra by jhipster.

the class AbstractCassandraTest method startServer.

@BeforeClass
public static void startServer() throws TTransportException, ConfigurationException, IOException, URISyntaxException {
    if (!started) {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT);
        Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(getNativeTransportPort()).build();
        Session session = cluster.connect();
        String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
        session.execute(createQuery);
        String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE;
        session.execute(useKeyspaceQuery);
        CQLDataLoader dataLoader = new CQLDataLoader(session);
        applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
        started = true;
    }
}
Also used : Cluster(com.datastax.driver.core.Cluster) Session(com.datastax.driver.core.Session) CQLDataLoader(org.cassandraunit.CQLDataLoader) BeforeClass(org.junit.BeforeClass)

Aggregations

CQLDataLoader (org.cassandraunit.CQLDataLoader)4 Cluster (com.datastax.driver.core.Cluster)2 BeforeClass (org.junit.BeforeClass)2 Session (com.datastax.driver.core.Session)1 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 Properties (java.util.Properties)1 ClassPathCQLDataSet (org.cassandraunit.dataset.cql.ClassPathCQLDataSet)1