use of com.datastax.driver.core.Session in project pinpoint by naver.
the class CassandraDatastaxITBase method initializeCluster.
public static void initializeCluster(String cassandraVersion) throws Exception {
CassandraTestHelper.init(cassandraVersion);
HOST = CassandraTestHelper.getHost();
PORT = CassandraTestHelper.getNativeTransportPort();
CASSANDRA_ADDRESS = HOST + ":" + PORT;
cluster = Cluster.builder().addContactPoint(HOST).withPort(PORT).withoutMetrics().build();
// Create KeySpace
Session emptySession = null;
try {
emptySession = cluster.connect();
emptySession.execute(CQL_CREATE_KEYSPACE);
} finally {
closeSession(emptySession);
}
// Create Table
Session myKeyspaceSession = null;
try {
myKeyspaceSession = cluster.connect(TEST_KEYSPACE);
myKeyspaceSession.execute(CQL_CREATE_TABLE);
} finally {
closeSession(myKeyspaceSession);
}
}
use of com.datastax.driver.core.Session in project aroma-data-operations by RedRoma.
the class ModuleCassandraDevClusterTest method testModule.
@Test
public void testModule() {
Injector injector = Guice.createInjector(instance);
Cluster cluster = injector.getInstance(Cluster.class);
assertThat(cluster, notNullValue());
Session session = injector.getInstance(Session.class);
assertThat(session, notNullValue());
}
use of com.datastax.driver.core.Session in project aroma-data-operations by RedRoma.
the class ModuleCassandraDevClusterTest method testProvideCassandraSession.
@Test
public void testProvideCassandraSession() {
ReconnectionPolicy policy = instance.provideReconnectPolicy();
Cluster cluster = instance.provideCassandraCluster(policy);
Session session = instance.provideCassandraSession(cluster);
assertThat(session, notNullValue());
}
use of com.datastax.driver.core.Session in project logging-log4j2 by apache.
the class CassandraAppenderIT method appendManyEvents.
@Test
public void appendManyEvents() throws Exception {
final Logger logger = CTX.getLogger();
ThreadContext.put("test", "mdc");
ThreadContext.push("ndc");
for (int i = 0; i < 20; i++) {
logger.info(MarkerManager.getMarker("MARKER"), "Test log message");
}
ThreadContext.clearAll();
TimeUnit.SECONDS.sleep(3);
int i = 0;
try (final Session session = CASSANDRA.connect()) {
for (final Row row : session.execute("SELECT * FROM logs")) {
assertNotNull(row.get("id", UUID.class));
assertNotNull(row.get("timeid", UUID.class));
assertNotNull(row.get("timestamp", Date.class));
assertEquals("Test log message", row.getString("message"));
assertEquals("MARKER", row.getString("marker"));
assertEquals("INFO", row.getString("level"));
assertEquals(getClass().getName(), row.getString("logger"));
final Map<String, String> mdc = row.getMap("mdc", String.class, String.class);
assertEquals(1, mdc.size());
assertEquals("mdc", mdc.get("test"));
final List<String> ndc = row.getList("ndc", String.class);
assertEquals(1, ndc.size());
assertEquals("ndc", ndc.get(0));
++i;
}
}
assertEquals(20, i);
}
use of com.datastax.driver.core.Session in project logging-log4j2 by apache.
the class CassandraRule method before.
@Override
protected void before() throws Throwable {
final Path root = Files.createTempDirectory("cassandra");
Files.createDirectories(root.resolve("data"));
final Path config = root.resolve("cassandra.yml");
Files.copy(getClass().getResourceAsStream("/cassandra.yaml"), config);
System.setProperty("cassandra.config", "file:" + config.toString());
System.setProperty("cassandra.storagedir", root.toString());
// prevents Cassandra from closing stdout/stderr
System.setProperty("cassandra-foreground", "true");
THREAD_FACTORY.newThread(embeddedCassandra).start();
latch.await();
cluster = Cluster.builder().addContactPoints(InetAddress.getLoopbackAddress()).build();
try (final Session session = cluster.connect()) {
session.execute("CREATE KEYSPACE " + keyspace + " WITH REPLICATION = " + "{ 'class': 'SimpleStrategy', 'replication_factor': 2 };");
}
try (final Session session = connect()) {
session.execute(tableDdl);
}
}
Aggregations