Search in sources :

Example 1 with UdtValue

use of com.datastax.oss.driver.api.core.data.UdtValue in project zipkin by openzipkin.

the class DefaultSessionFactory method initializeUDTs.

static void initializeUDTs(CqlSession session, String keyspace) {
    KeyspaceMetadata ks = session.getMetadata().getKeyspace(keyspace).get();
    MutableCodecRegistry codecRegistry = (MutableCodecRegistry) session.getContext().getCodecRegistry();
    TypeCodec<UdtValue> annotationUDTCodec = codecRegistry.codecFor(ks.getUserDefinedType("annotation").get());
    codecRegistry.register(new AnnotationCodec(annotationUDTCodec));
    LOG.debug("Registering endpoint and annotation UDTs to keyspace {}", keyspace);
    TypeCodec<UdtValue> endpointUDTCodec = codecRegistry.codecFor(ks.getUserDefinedType("endpoint").get());
    codecRegistry.register(new EndpointCodec(endpointUDTCodec));
}
Also used : UdtValue(com.datastax.oss.driver.api.core.data.UdtValue) MutableCodecRegistry(com.datastax.oss.driver.api.core.type.codec.registry.MutableCodecRegistry) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)

Example 2 with UdtValue

use of com.datastax.oss.driver.api.core.data.UdtValue in project zipkin by openzipkin.

the class EndpointCodec method outerToInner.

@Nullable
@Override
protected UdtValue outerToInner(@Nullable Endpoint endpoint) {
    if (endpoint == null)
        return null;
    UdtValue result = getCqlType().newValue();
    result.setString("service", endpoint.serviceName());
    result.setInetAddress("ipv4", inetAddressOrNull(endpoint.ipv4(), endpoint.ipv4Bytes()));
    result.setInetAddress("ipv6", inetAddressOrNull(endpoint.ipv6(), endpoint.ipv6Bytes()));
    result.setInt("port", endpoint.portAsInt());
    return result;
}
Also used : UdtValue(com.datastax.oss.driver.api.core.data.UdtValue) Nullable(zipkin2.internal.Nullable)

Aggregations

UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)2 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)1 MutableCodecRegistry (com.datastax.oss.driver.api.core.type.codec.registry.MutableCodecRegistry)1 Nullable (zipkin2.internal.Nullable)1