Search in sources :

Example 1 with DatastaxCassandraService

use of com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService in project atlas-deer by atlasapi.

the class CassandraContentStoreIT method setup.

@BeforeClass
public static void setup() throws Exception {
    root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
    root.setLevel(Level.WARN);
    context.start();
    DatastaxCassandraService cassandraService = CassandraInit.datastaxCassandraService();
    cassandraService.startAsync().awaitRunning();
    Cluster cluster = cassandraService.getCluster();
    session = cluster.connect();
    CassandraInit.createTables(session, context);
    CassandraInit.truncate(session, context);
    session.close();
    session = cluster.connect(KEYSPACE);
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) DatastaxCassandraService(com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService) PatternLayout(org.apache.log4j.PatternLayout) Cluster(com.datastax.driver.core.Cluster) BeforeClass(org.junit.BeforeClass)

Example 2 with DatastaxCassandraService

use of com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService in project atlas-deer by atlasapi.

the class DatastaxCassandraEventStoreIT method init.

@BeforeClass
public static void init() throws Exception {
    // Thrift init
    context.start();
    // CQL init
    DatastaxCassandraService cassandraService = new DatastaxCassandraService(seeds, 8, 2);
    cassandraService.startAsync().awaitRunning();
    session = cassandraService.getCluster().connect();
    CassandraInit.createTables(session, context);
    CassandraInit.truncate(session, context);
    session = cassandraService.getCluster().connect(keyspace);
}
Also used : DatastaxCassandraService(com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService) BeforeClass(org.junit.BeforeClass)

Example 3 with DatastaxCassandraService

use of com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService in project atlas-deer by atlasapi.

the class OrganisationUriStoreIT method init.

@BeforeClass
public static void init() throws Exception {
    // Thrift init
    context.start();
    CassandraHelper.createKeyspace(context);
    // CQL init
    DatastaxCassandraService cassandraService = new DatastaxCassandraService(seeds, 8, 2);
    cassandraService.startAsync().awaitRunning();
    session = cassandraService.getCluster().connect(keyspace);
    session.execute(IOUtils.toString(DatastaxCassandraOrganizationStoreTest.class.getResourceAsStream("/atlas_organisation.schema")));
    session.execute(IOUtils.toString(DatastaxCassandraOrganizationStoreTest.class.getResourceAsStream("/atlas_organisation_uri.schema")));
}
Also used : DatastaxCassandraService(com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService) BeforeClass(org.junit.BeforeClass)

Example 4 with DatastaxCassandraService

use of com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService in project atlas-deer by atlasapi.

the class CassandraTopicStoreIT method setup.

@BeforeClass
public static void setup() throws ConnectionException, IOException {
    context.start();
    DatastaxCassandraService service = CassandraInit.datastaxCassandraService();
    service.startAsync().awaitRunning();
    Cluster cluster = service.getCluster();
    Session session = cluster.connect();
    CassandraInit.createTables(session, context);
    CassandraInit.truncate(session, context);
    session.close();
}
Also used : DatastaxCassandraService(com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService) Cluster(com.datastax.driver.core.Cluster) Session(com.datastax.driver.core.Session) BeforeClass(org.junit.BeforeClass)

Example 5 with DatastaxCassandraService

use of com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService in project atlas-deer by atlasapi.

the class AtlasPersistenceModule method persistenceModule.

@Bean
public CassandraPersistenceModule persistenceModule() {
    Iterable<String> seeds = Splitter.on(",").split(cassandraSeeds);
    ConfiguredAstyanaxContext contextSupplier = new ConfiguredAstyanaxContext(cassandraCluster, cassandraKeyspace, seeds, Integer.parseInt(cassandraPort), Integer.parseInt(cassandraClientThreads), Integer.parseInt(cassandraConnectionTimeout), metricsModule.metrics());
    AstyanaxContext<Keyspace> context = contextSupplier.get();
    context.start();
    DatastaxCassandraService cassandraService = DatastaxCassandraService.builder().withNodes(seeds).withConnectionsPerHostLocal(cassandraConnectionsPerHostLocal).withConnectionsPerHostRemote(cassandraConnectionsPerHostRemote).withCodecRegistry(new CodecRegistry().register(InstantCodec.instance).register(LocalDateCodec.instance).register(new JacksonJsonCodec<>(org.atlasapi.content.v2.model.Clip.Wrapper.class, MAPPER)).register(new JacksonJsonCodec<>(org.atlasapi.content.v2.model.Encoding.Wrapper.class, MAPPER))).withConnectTimeoutMillis(cassandraDatastaxConnectionTimeout).withReadTimeoutMillis(cassandraDatastaxReadTimeout).build();
    cassandraService.startAsync().awaitRunning();
    return CassandraPersistenceModule.builder().withBrokerFactory(deerBrokerFactory).withAstyanaxContext(context).withDatastaxCassandraService(cassandraService).withKeyspace(cassandraKeyspace).withIdGeneratorBuilder(idGeneratorBuilder()).withContentHasher(ContentHashGenerator.create(HashGenerator.create(), UTIL_METRIC_PREFIX, metricsModule.metrics())).withEventHasher(eventV2 -> UUID.randomUUID().toString()).withMetrics(metricsModule.metrics()).build();
}
Also used : DatastaxCassandraService(com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService) JacksonJsonCodec(com.datastax.driver.extras.codecs.json.JacksonJsonCodec) Keyspace(com.netflix.astyanax.Keyspace) CodecRegistry(com.datastax.driver.core.CodecRegistry) Bean(org.springframework.context.annotation.Bean)

Aggregations

DatastaxCassandraService (com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService)8 BeforeClass (org.junit.BeforeClass)6 Cluster (com.datastax.driver.core.Cluster)2 CodecRegistry (com.datastax.driver.core.CodecRegistry)1 Session (com.datastax.driver.core.Session)1 JacksonJsonCodec (com.datastax.driver.extras.codecs.json.JacksonJsonCodec)1 Keyspace (com.netflix.astyanax.Keyspace)1 ConsoleAppender (org.apache.log4j.ConsoleAppender)1 PatternLayout (org.apache.log4j.PatternLayout)1 Bean (org.springframework.context.annotation.Bean)1