use of com.datastax.driver.mapping.MappingManager in project zipkin by openzipkin.
the class DefaultSessionFactory method initializeUDTs.
private static void initializeUDTs(Session session) {
Schema.ensureExists(DEFAULT_KEYSPACE + "_udts", session);
MappingManager mapping = new MappingManager(session);
// The UDTs are hardcoded against the zipkin keyspace.
// If a different keyspace is being used the codecs must be re-applied to this different keyspace
TypeCodec<TraceIdUDT> traceIdCodec = mapping.udtCodec(TraceIdUDT.class);
TypeCodec<EndpointUDT> endpointCodec = mapping.udtCodec(EndpointUDT.class);
TypeCodec<AnnotationUDT> annoCodec = mapping.udtCodec(AnnotationUDT.class);
TypeCodec<BinaryAnnotationUDT> bAnnoCodec = mapping.udtCodec(BinaryAnnotationUDT.class);
KeyspaceMetadata keyspace = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());
session.getCluster().getConfiguration().getCodecRegistry().register(new TypeCodecImpl(keyspace.getUserType("trace_id"), TraceIdUDT.class, traceIdCodec)).register(new TypeCodecImpl(keyspace.getUserType("endpoint"), EndpointUDT.class, endpointCodec)).register(new TypeCodecImpl(keyspace.getUserType("annotation"), AnnotationUDT.class, annoCodec)).register(new TypeCodecImpl(keyspace.getUserType("binary_annotation"), BinaryAnnotationUDT.class, bAnnoCodec));
}
use of com.datastax.driver.mapping.MappingManager in project flink by apache.
the class CassandraPojoSink method open.
@Override
public void open(Configuration configuration) {
super.open(configuration);
try {
this.mappingManager = new MappingManager(session);
this.mapper = mappingManager.mapper(clazz);
} catch (Exception e) {
throw new RuntimeException("Cannot create CassandraPojoSink with input: " + clazz.getSimpleName(), e);
}
}
Aggregations