Search in sources :

Example 1 with JacksonJsonCodec

use of com.datastax.driver.extras.codecs.json.JacksonJsonCodec 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

CodecRegistry (com.datastax.driver.core.CodecRegistry)1 JacksonJsonCodec (com.datastax.driver.extras.codecs.json.JacksonJsonCodec)1 DatastaxCassandraService (com.metabroadcast.common.persistence.cassandra.DatastaxCassandraService)1 Keyspace (com.netflix.astyanax.Keyspace)1 Bean (org.springframework.context.annotation.Bean)1