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


Java SeedProviderDef类代码示例

本文整理汇总了Java中org.apache.cassandra.config.SeedProviderDef的典型用法代码示例。如果您正苦于以下问题:Java SeedProviderDef类的具体用法?Java SeedProviderDef怎么用?Java SeedProviderDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SeedProviderDef类属于org.apache.cassandra.config包,在下文中一共展示了SeedProviderDef类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createServiceConfig

import org.apache.cassandra.config.SeedProviderDef; //导入依赖的package包/类
private static Config createServiceConfig(final OperationContext context, PathAddress address,
        ModelNode fullModel) throws OperationFailedException {

    final ExpressionResolver expressionResolver = new ExpressionResolver() {
        @Override
        public ModelNode resolveExpressions(ModelNode node) throws OperationFailedException {
            return context.resolveExpressions(node);
        }
    };

    // create the actual cassandra config singleton
    final Config cassandraConfig = new Config();
    cassandraConfig.cluster_name = address.getLastElement().getValue();
    cassandraConfig.num_tokens = ClusterDefinition.NUM_TOKENS.resolveModelAttribute(context, fullModel).asInt();
    cassandraConfig.hinted_handoff_enabled = ClusterDefinition.HINTED_HANDOFF_ENABLED.resolveModelAttribute(context, fullModel).asString();

    cassandraConfig.authenticator = ClusterDefinition.AUTHENTICATOR.resolveModelAttribute(context, fullModel).asString();
    cassandraConfig.authorizer = ClusterDefinition.AUTHORIZER.resolveModelAttribute(context, fullModel).asString();
    cassandraConfig.partitioner = ClusterDefinition.PARTIONER.resolveModelAttribute(context, fullModel).asString();

    // The cassandra config is a real brainfuck
    LinkedHashMap providerConfig = new LinkedHashMap();
    providerConfig.put("class_name", ClusterDefinition.SEED_PROVIDER.resolveModelAttribute(context, fullModel).asString());
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("seeds", ClusterDefinition.SEEDS.resolveModelAttribute(expressionResolver, fullModel).asString());
    ArrayList wrapper = new ArrayList();
    wrapper.add(params);
    providerConfig.put("parameters", wrapper);

    SeedProviderDef providerDef = new SeedProviderDef(providerConfig);
    cassandraConfig.seed_provider = providerDef;

    cassandraConfig.listen_address = ClusterDefinition.LISTEN_ADDRESS.resolveModelAttribute(expressionResolver, fullModel).asString();
    cassandraConfig.broadcast_address = ClusterDefinition.BROADCAST_ADDRESS.resolveModelAttribute(expressionResolver, fullModel).asString();

    cassandraConfig.start_native_transport = ClusterDefinition.START_NATIVE_TRANSPORT.resolveModelAttribute(context, fullModel).asBoolean();
    cassandraConfig.start_rpc = ClusterDefinition.START_RPC.resolveModelAttribute(context, fullModel).asBoolean();

    cassandraConfig.native_transport_port = ClusterDefinition.NATIVE_TRANSPORT_PORT.resolveModelAttribute(context, fullModel).asInt();
    cassandraConfig.rpc_port = ClusterDefinition.RPC_PORT.resolveModelAttribute(context, fullModel).asInt();

    cassandraConfig.internode_authenticator = ClusterDefinition.INTERNODE_AUTHENTICATOR.resolveModelAttribute(context, fullModel).asString();

    if (fullModel.hasDefined(CassandraModel.DATA_FILE_DIR))
        cassandraConfig.data_file_directories = new String[]{ClusterDefinition.DATA_FILE_DIR.resolveModelAttribute(context, fullModel).asString()};

    if (fullModel.hasDefined(CassandraModel.SAVED_CACHES_DIR))
        cassandraConfig.saved_caches_directory = ClusterDefinition.SAVED_CACHES_DIR.resolveModelAttribute(context, fullModel).asString();

    if (fullModel.hasDefined(CassandraModel.COMMIT_LOG_DIR))
        cassandraConfig.commitlog_directory = ClusterDefinition.COMMIT_LOG_DIR.resolveModelAttribute(context, fullModel).asString();

    cassandraConfig.commitlog_sync = Config.CommitLogSync.valueOf(ClusterDefinition.COMMIT_LOG_SYNC.resolveModelAttribute(context, fullModel).asString());
    cassandraConfig.commitlog_sync_period_in_ms = ClusterDefinition.COMMIT_LOG_SYNC_PERIOD.resolveModelAttribute(context, fullModel).asInt();

    cassandraConfig.endpoint_snitch = ClusterDefinition.ENDPOINT_SNITCH.resolveModelAttribute(context, fullModel).asString();
    cassandraConfig.request_scheduler = ClusterDefinition.REQUEST_SCHEDULER.resolveModelAttribute(context, fullModel).asString();

    // TODO: encryption options
    //cassandraConfig.server_encryption_options =
    //cassandraConfig.client_encryption_options =

    // TODO: ring delay configuration (cassandra.ring_delay_ms)

    return cassandraConfig;

}
 
开发者ID:hawkular,项目名称:wildfly-cassandra,代码行数:68,代码来源:ClusterAdd.java


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