Search in sources :

Example 1 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project pinpoint by naver.

the class CassandraTestHelper method init.

public static void init(final String cassandraVersion) throws IOException, ConfigurationException {
    final String cassandraStorageDir = String.format("%s/data_%s", CASSANDRA_HOME, cassandraVersion);
    final String cassandraConfigFile = String.format("cassandra/cassandra_%s.yaml", cassandraVersion);
    System.setProperty("cassandra.storagedir", cassandraStorageDir);
    System.setProperty("cassandra.config", cassandraConfigFile);
    prepareEnvironment();
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService)

Example 2 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class AuditLoggerAuthTest method setup.

@BeforeClass
public static void setup() throws Exception {
    OverrideConfigurationLoader.override((config) -> {
        config.authenticator = "PasswordAuthenticator";
        config.role_manager = "CassandraRoleManager";
        config.authorizer = "CassandraAuthorizer";
        config.audit_logging_options.enabled = true;
        config.audit_logging_options.logger = new ParameterizedClass("InMemoryAuditLogger", null);
    });
    CQLTester.prepareServer();
    System.setProperty("cassandra.superuser_setup_delay_ms", "0");
    embedded = new EmbeddedCassandraService();
    embedded.start();
    executeWithCredentials(Arrays.asList(getCreateRoleCql(TEST_USER, true, false, false), getCreateRoleCql("testuser_nologin", false, false, false), "CREATE KEYSPACE testks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}", "CREATE TABLE testks.table1 (key text PRIMARY KEY, col1 int, col2 int)"), "cassandra", "cassandra", null);
}
Also used : ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 3 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class CQLMetricsTest method setup.

@BeforeClass()
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
    cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute("CREATE KEYSPACE IF NOT EXISTS junit WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
    session.execute("CREATE TABLE IF NOT EXISTS junit.metricstest (id int PRIMARY KEY, val text);");
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 4 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class BatchMetricsTest method setup.

@BeforeClass()
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    cassandra = new EmbeddedCassandraService();
    cassandra.start();
    DatabaseDescriptor.setWriteRpcTimeout(TimeUnit.SECONDS.toMillis(10));
    cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
    session.execute("USE " + KEYSPACE);
    session.execute("CREATE TABLE IF NOT EXISTS " + LOGGER_TABLE + " (id int PRIMARY KEY, val text);");
    session.execute("CREATE TABLE IF NOT EXISTS " + COUNTER_TABLE + " (id int PRIMARY KEY, val counter);");
    psLogger = session.prepare("INSERT INTO " + KEYSPACE + '.' + LOGGER_TABLE + " (id, val) VALUES (?, ?);");
    psCounter = session.prepare("UPDATE " + KEYSPACE + '.' + COUNTER_TABLE + " SET val = val + 1 WHERE id = ?;");
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 5 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class ClientRequestMetricsTest method setup.

@BeforeClass
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    cassandra = new EmbeddedCassandraService();
    cassandra.start();
    cluster = builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
    session.execute("USE " + KEYSPACE);
    session.execute("CREATE TABLE IF NOT EXISTS " + TABLE + " (id int, ord int, val text, PRIMARY KEY (id, ord));");
    writePS = session.prepare("INSERT INTO " + KEYSPACE + '.' + TABLE + " (id, ord, val) VALUES (?, ?, ?);");
    paxosPS = session.prepare("INSERT INTO " + KEYSPACE + '.' + TABLE + " (id, ord, val) VALUES (?, ?, ?) IF NOT EXISTS;");
    readPS = session.prepare("SELECT * FROM " + KEYSPACE + '.' + TABLE + " WHERE id=?;");
    readRangePS = session.prepare("SELECT * FROM " + KEYSPACE + '.' + TABLE + " WHERE id=? AND ord>=? AND ord <= ?;");
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Aggregations

EmbeddedCassandraService (org.apache.cassandra.service.EmbeddedCassandraService)15 BeforeClass (org.junit.BeforeClass)13 Cluster (com.datastax.driver.core.Cluster)2 ParameterizedClass (org.apache.cassandra.config.ParameterizedClass)2 LoggingRetryPolicy (com.datastax.driver.core.policies.LoggingRetryPolicy)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 HashMap (java.util.HashMap)1 ConfigurationException (org.apache.cassandra.config.ConfigurationException)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Test (org.junit.Test)1