Search in sources :

Example 1 with MappingManager

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));
}
Also used : EndpointUDT(zipkin.storage.cassandra3.Schema.EndpointUDT) TypeCodecImpl(zipkin.storage.cassandra3.Schema.TypeCodecImpl) MappingManager(com.datastax.driver.mapping.MappingManager) BinaryAnnotationUDT(zipkin.storage.cassandra3.Schema.BinaryAnnotationUDT) AnnotationUDT(zipkin.storage.cassandra3.Schema.AnnotationUDT) BinaryAnnotationUDT(zipkin.storage.cassandra3.Schema.BinaryAnnotationUDT) KeyspaceMetadata(com.datastax.driver.core.KeyspaceMetadata) TraceIdUDT(zipkin.storage.cassandra3.Schema.TraceIdUDT)

Example 2 with MappingManager

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);
    }
}
Also used : MappingManager(com.datastax.driver.mapping.MappingManager)

Aggregations

MappingManager (com.datastax.driver.mapping.MappingManager)2 KeyspaceMetadata (com.datastax.driver.core.KeyspaceMetadata)1 AnnotationUDT (zipkin.storage.cassandra3.Schema.AnnotationUDT)1 BinaryAnnotationUDT (zipkin.storage.cassandra3.Schema.BinaryAnnotationUDT)1 EndpointUDT (zipkin.storage.cassandra3.Schema.EndpointUDT)1 TraceIdUDT (zipkin.storage.cassandra3.Schema.TraceIdUDT)1 TypeCodecImpl (zipkin.storage.cassandra3.Schema.TypeCodecImpl)1