本文整理汇总了Java中com.datastax.driver.core.CodecRegistry类的典型用法代码示例。如果您正苦于以下问题:Java CodecRegistry类的具体用法?Java CodecRegistry怎么用?Java CodecRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodecRegistry类属于com.datastax.driver.core包,在下文中一共展示了CodecRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSession
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
protected Session getSession() {
if (session == null) {
session = cluster.getSession();
defaultReadLevel = cluster.getDefaultReadConsistencyLevel();
defaultWriteLevel = cluster.getDefaultWriteConsistencyLevel();
CodecRegistry registry = session.getCluster().getConfiguration().getCodecRegistry();
registerCodecIfNotFound(registry, new JsonCodec());
registerCodecIfNotFound(registry, new DeviceCredentialsTypeCodec());
registerCodecIfNotFound(registry, new AuthorityCodec());
registerCodecIfNotFound(registry, new ComponentLifecycleStateCodec());
registerCodecIfNotFound(registry, new ComponentTypeCodec());
registerCodecIfNotFound(registry, new ComponentScopeCodec());
registerCodecIfNotFound(registry, new EntityTypeCodec());
}
return session;
}
示例2: CassandraStorage
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public CassandraStorage(ReaperApplicationConfiguration config, Environment environment) {
CassandraFactory cassandraFactory = config.getCassandraFactory();
overrideQueryOptions(cassandraFactory);
overrideRetryPolicy(cassandraFactory);
overridePoolingOptions(cassandraFactory);
cassandra = cassandraFactory.build(environment);
if (config.getActivateQueryLogger()) {
cassandra.register(QueryLogger.builder().build());
}
CodecRegistry codecRegistry = cassandra.getConfiguration().getCodecRegistry();
codecRegistry.register(new DateTimeCodec());
session = cassandra.connect(config.getCassandraFactory().getKeyspace());
initializeAndUpgradeSchema(cassandra, session, config.getCassandraFactory().getKeyspace());
prepareStatements();
}
示例3: registerCodecs
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private void registerCodecs()
{
complexTypeCodecs = getCodecsForUserDefinedTypes();
if (complexTypeCodecs != null) {
CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();
if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion().toInt() < 4) {
LOG.error("Custom codecs are not supported for protocol version < 4");
throw new RuntimeException("Custom codecs are not supported for protocol version < 4");
}
for (String typeCodecStr : complexTypeCodecs.keySet()) {
TypeCodec codec = complexTypeCodecs.get(typeCodecStr);
registry.register(codec);
userDefinedTypesClass.put(typeCodecStr, codec.getJavaType().getRawType());
}
} else {
complexTypeCodecs = new HashMap<>();
}
}
示例4: getCodecsForUserDefinedTypes
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
@Override
public Map<String, TypeCodec> getCodecsForUserDefinedTypes()
{
Map<String, TypeCodec> allCodecs = new HashMap<>();
CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();
UserType addressType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName())
.getUserType("address");
TypeCodec<UDTValue> addressTypeCodec = codecRegistry.codecFor(addressType);
AddressCodec addressCodec = new AddressCodec(addressTypeCodec, Address.class);
allCodecs.put("currentaddress", addressCodec);
UserType userFullNameType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName())
.getUserType("fullname");
TypeCodec<UDTValue> userFullNameTypeCodec = codecRegistry.codecFor(userFullNameType);
FullNameCodec fullNameCodec = new FullNameCodec(userFullNameTypeCodec, FullName.class);
allCodecs.put("username", fullNameCodec);
return allCodecs;
}
示例5: datastaxCassandraService
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public static DatastaxCassandraService datastaxCassandraService() {
return DatastaxCassandraService.builder()
.withNodes(SEEDS)
.withConnectionsPerHostLocal(8)
.withConnectionsPerHostRemote(2)
.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
))
)
.build();
}
示例6: doCreateCluster
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private Cluster doCreateCluster(CassandraProperties properties) {
Cluster cluster = Cluster.builder()
.withClusterName(properties.getCluster())
.withPort(properties.getPort())
.addContactPoints(properties.getContactPoints())
.withTimestampGenerator(getTimestampGenerator())
.withPoolingOptions(
//TODO some default options - move to config
new PoolingOptions()
.setConnectionsPerHost(HostDistance.LOCAL, 4, 4)
.setConnectionsPerHost(HostDistance.REMOTE, 2, 2)
.setMaxRequestsPerConnection(HostDistance.LOCAL, 1024)
.setMaxRequestsPerConnection(HostDistance.REMOTE, 256)
)
.build();
//almost all queries are idempotent except counter updates, so it's easier to mark them as idempotent
cluster.getConfiguration().getQueryOptions().setDefaultIdempotence(true);
CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();
TupleType tupleType = cluster.getMetadata()
.newTupleType(DataType.timestamp(), DataType.varchar());
codecRegistry.register(new ZonedDateTimeCodec(tupleType));
QueryLogger queryLogger = QueryLogger.builder()
.withConstantThreshold(100)
.withMaxQueryStringLength(200)
.build();
cluster.register(queryLogger);
return cluster;
}
示例7: registerCodecIfNotFound
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private void registerCodecIfNotFound(CodecRegistry registry, TypeCodec<?> codec) {
try {
registry.codecFor(codec.getCqlType(), codec.getJavaType());
} catch (CodecNotFoundException e) {
registry.register(codec);
}
}
示例8: CqlDeltaIterator
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public CqlDeltaIterator(Iterator<Row> iterator, final int blockIndex, final int changeIdIndex, final int contentIndex, boolean reversed, int prefixLength,
ProtocolVersion protocolVersion, CodecRegistry codecRegistry) {
super(iterator, reversed, prefixLength);
_blockIndex = blockIndex;
_changeIdIndex = changeIdIndex;
_contentIndex = contentIndex;
_protocolVersion = protocolVersion;
_codecRegistry = codecRegistry;
}
示例9: getCluster
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private Cluster getCluster() throws StageException {
return Cluster.builder()
.addContactPoints(contactPoints)
// If authentication is disabled on the C* cluster, this method has no effect.
.withAuthProvider(getAuthProvider())
.withProtocolVersion(conf.protocolVersion)
.withPort(conf.port)
.withCodecRegistry(new CodecRegistry().register(SDC_CODECS))
.build();
}
示例10: CassandraMetricBatch
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public CassandraMetricBatch(Metadata metadata, ProtocolOptions protocol, CodecRegistry codec,
TokenAwarePolicy lbPolicy, int batchLimit) {
this.protocol = protocol;
this.codec = codec;
this.metadata = metadata;
this.policy = lbPolicy;
metricQueries = new HashMap<>();
this.batchLimit = batchLimit;
metricQueries = new HashMap<>();
dimensionQueries = new HashMap<>();
dimensionMetricQueries = new HashMap<>();
metricDimensionQueries = new HashMap<>();
measurementQueries = new HashMap<>();
}
示例11: serialize
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
/**
* Serialize a field using the data type passed.
* @param dataType
* @param value
* @return
*/
@SuppressWarnings("unchecked")
public <T> ByteBuffer serialize(DataType dataType, Object value) {
final CodecRegistry codecRegistry = getCodecRegistry();
final TypeCodec<T> typeCodec = codecRegistry.codecFor(dataType);
return typeCodec.serialize((T)value, protocolVersion);
}
示例12: getCodecRegistry
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
@Override
public CodecRegistry getCodecRegistry() {
return preparedStatement.getCodecRegistry();
}
示例13: codecRegistry
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private static CodecRegistry codecRegistry() {
CodecRegistry registry = new CodecRegistry();
registry.register(LocalDateCodec.instance);
return registry;
}
示例14: codecRegistry
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private static CodecRegistry codecRegistry() {
final CodecRegistry registry = new CodecRegistry();
registry.register(LocalDateCodec.instance);
return registry;
}
示例15: getCodecRegistry
import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public CodecRegistry getCodecRegistry() {
return cluster.getConfiguration().getCodecRegistry();
}