当前位置: 首页>>代码示例>>Java>>正文


Java CodecRegistry类代码示例

本文整理汇总了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;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:17,代码来源:CassandraAbstractDao.java

示例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();
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:17,代码来源:CassandraStorage.java

示例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<>();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:AbstractUpsertOutputOperator.java

示例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;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:UserUpsertOperator.java

示例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();
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:20,代码来源:CassandraInit.java

示例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;
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:33,代码来源:CassandraConfiguration.java

示例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);
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:8,代码来源:CassandraAbstractDao.java

示例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;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:10,代码来源:CqlDeltaIterator.java

示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:11,代码来源:CassandraTarget.java

示例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<>();
}
 
开发者ID:openstack,项目名称:monasca-persister,代码行数:16,代码来源:CassandraMetricBatch.java

示例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);
   }
 
开发者ID:1and1,项目名称:Troilus,代码行数:13,代码来源:UDTValueMapper.java

示例12: getCodecRegistry

import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
@Override
public CodecRegistry getCodecRegistry() {
    return preparedStatement.getCodecRegistry();
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:5,代码来源:ProfiledPreparedStatement.java

示例13: codecRegistry

import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private static CodecRegistry codecRegistry() {
    CodecRegistry registry = new CodecRegistry();
    registry.register(LocalDateCodec.instance);
    return registry;
}
 
开发者ID:lesfurets,项目名称:dOOv,代码行数:6,代码来源:CassandraQueryBuilderTest.java

示例14: codecRegistry

import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
private static CodecRegistry codecRegistry() {
    final CodecRegistry registry = new CodecRegistry();
    registry.register(LocalDateCodec.instance);
    return registry;
}
 
开发者ID:lesfurets,项目名称:dOOv,代码行数:6,代码来源:LiveCode.java

示例15: getCodecRegistry

import com.datastax.driver.core.CodecRegistry; //导入依赖的package包/类
public CodecRegistry getCodecRegistry() {
  return cluster.getConfiguration().getCodecRegistry();
}
 
开发者ID:openstack,项目名称:monasca-persister,代码行数:4,代码来源:CassandraCluster.java


注:本文中的com.datastax.driver.core.CodecRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。