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