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


Java Keyspace.createKeyspace方法代码示例

本文整理汇总了Java中com.netflix.astyanax.Keyspace.createKeyspace方法的典型用法代码示例。如果您正苦于以下问题:Java Keyspace.createKeyspace方法的具体用法?Java Keyspace.createKeyspace怎么用?Java Keyspace.createKeyspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.astyanax.Keyspace的用法示例。


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

示例1: setupCassandraKeySpace

import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
public static void setupCassandraKeySpace(String cassandraConnectionString, String keySpaceName,
                                          String columnFamily) throws ConnectionException {

    try {
        AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                .forCluster("ClusterName")
                .forKeyspace(keySpaceName)
                .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                                .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
                )
                .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
                                .setMaxConnsPerHost(1)
                                .setSeeds(cassandraConnectionString)
                )
                .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
                .buildKeyspace(ThriftFamilyFactory.getInstance());

        context.start();
        Keyspace keyspace = context.getClient();

        // Using simple strategy
        keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
                        .put("strategy_options", ImmutableMap.<String, Object>builder()
                                .put("replication_factor", "1")
                                .build())
                        .put("strategy_class", "SimpleStrategy")
                        .build()
        );

        ColumnFamily<String, String> CF_STANDARD1 = ColumnFamily.newColumnFamily(columnFamily,
                StringSerializer.get(), StringSerializer.get());

        keyspace.createColumnFamily(CF_STANDARD1, null);
        context.shutdown();
    } catch(BadRequestException e) {
        LOG.warn("could not setup cassandra keyspace , assuming keyspace already exists.", e);
    }
}
 
开发者ID:Parth-Brahmbhatt,项目名称:storm-smoke-test,代码行数:39,代码来源:SetupUtils.java

示例2: initKeyspace

import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
@Override
public void initKeyspace(Keyspace keyspace) throws ConnectionException {
    try {
        keyspace.describeKeyspace();
    } catch (ConnectionException e) {
        Map<String, Object> options = ImmutableMap.<String, Object>builder()
            .put("name", keyspace.getKeyspaceName())
            .put("strategy_class", "SimpleStrategy")
            .put("strategy_options", ImmutableMap.of("replication_factor", "1"))
            .build();
        keyspace.createKeyspace(options);
    }
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:14,代码来源:AstyanaxComponents.java

示例3: createModel

import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
public static void createModel() throws ConnectionException {
    final Keyspace keyspace = CassandraUtils.getConnection();

    //    CREATE COLUMN FAMILY storage WITH comparator = UTF8Type AND key_validation_class=UTF8Type

    keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
            .put("strategy_options", ImmutableMap.<String, Object>builder()
                    .put("replication_factor", "1")
                    .build())
            .put("strategy_class", "SimpleStrategy")
            .build()
    );

    keyspace
            .prepareQuery(CassandraUtils.CQL3_CF)
            .withCql("CREATE TABLE directory(pathId uuid, child varchar, childId uuid, PRIMARY KEY (pathId, child)) WITH COMPACT STORAGE;")
            .asPreparedStatement()
            .execute();

    keyspace
            .prepareQuery(CassandraUtils.CQL3_CF)
            .withCql("CREATE TABLE file(file uuid PRIMARY KEY, size bigint, storageType varchar, storageData varchar);")
            .asPreparedStatement()
            .execute();

    keyspace
            .prepareQuery(CassandraUtils.CQL3_CF)
            .withCql("insert into directory(pathid, child, childid) VALUES (?, '.', ?);")
            .asPreparedStatement()
            .withUUIDValue(CassandraUtils.ROOT_UUID)
            .withUUIDValue(CassandraUtils.ROOT_UUID)
            .execute();

    final ColumnFamily<String, String> cf = ColumnFamily.newColumnFamily("storage", StringSerializer.get(), StringSerializer.get());
    keyspace.createColumnFamily(cf, ImmutableMap.<String, Object>builder()
            .put("key_validation_class", "UTF8Type")
            .put("comparator", "UTF8Type")
            .build());
}
 
开发者ID:Benky,项目名称:webdav-cassandra,代码行数:40,代码来源:WebdavServer.java

示例4: createKeyspace

import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
public static void createKeyspace(String keyspacename) throws ConnectionException {
	AstyanaxContext<Keyspace> ctx = builder.forKeyspace(keyspacename).buildKeyspace(ThriftFamilyFactory.getInstance());
	ctx.start();
	Keyspace keyspace = ctx.getClient();
	
	keyspace.createKeyspace(ImmutableMap.<String, Object> builder()
			.put("strategy_options",
					ImmutableMap.<String, Object> builder().put("replication_factor", String.valueOf(Configuration.global.getValue("cassandra", "default_replication_factor", 1))).build())
			.put("strategy_class", "SimpleStrategy").build());
	
	cluster.getKeyspace(keyspacename).describeKeyspace();
	Loggers.Cassandra.info("Create Keyspace " + keyspacename);
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:14,代码来源:CassandraDb.java


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