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();
}
Aggregations