• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SimpleStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testToStringHasStrategyOptions

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void testToStringHasStrategyOptions() throws Exception
{
    Map<String, String> options = new HashMap<String, String>();
    options.put("key1", "value1");
    options.put("key2", "value2");
    options.put("key3", "value3");

    KSMetaData ksMeta = new KSMetaData("test",
                                        SimpleStrategy.class,
                                        options,
                                        true,
                                        Collections.<CFMetaData>emptyList());

    assertTrue(ksMeta.toString().contains(options.toString()));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:KSMetaDataTest.java


示例2: newKsContainsCfWithTrigger

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void newKsContainsCfWithTrigger() throws Exception
{
    TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    cfm1.addTriggerDefinition(td);
    KSMetaData ksm = KSMetaData.newKeyspace(ksName,
                                            SimpleStrategy.class,
                                            Collections.singletonMap("replication_factor", "1"),
                                            true,
                                            Collections.singletonList(cfm1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName);
    assertFalse(cfm2.getTriggers().isEmpty());
    assertEquals(1, cfm2.getTriggers().size());
    assertEquals(td, cfm2.getTriggers().get(triggerName));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:TriggersSchemaTest.java


示例3: addNewCfWithTriggerToKs

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void addNewCfWithTriggerToKs() throws Exception
{
    KSMetaData ksm = KSMetaData.newKeyspace(ksName,
                                            SimpleStrategy.class,
                                            Collections.singletonMap("replication_factor", "1"),
                                            true,
                                            Collections.EMPTY_LIST);
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
    cfm1.addTriggerDefinition(td);

    MigrationManager.announceNewColumnFamily(cfm1);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName);
    assertFalse(cfm2.getTriggers().isEmpty());
    assertEquals(1, cfm2.getTriggers().size());
    assertEquals(td, cfm2.getTriggers().get(triggerName));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:TriggersSchemaTest.java


示例4: addTriggerToCf

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void addTriggerToCf() throws Exception
{
    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    KSMetaData ksm = KSMetaData.newKeyspace(ksName,
                                            SimpleStrategy.class,
                                            Collections.singletonMap("replication_factor", "1"),
                                            true,
                                            Collections.singletonList(cfm1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
    TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
    cfm2.addTriggerDefinition(td);
    MigrationManager.announceColumnFamilyUpdate(cfm2, false);

    CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName);
    assertFalse(cfm3.getTriggers().isEmpty());
    assertEquals(1, cfm3.getTriggers().size());
    assertEquals(td, cfm3.getTriggers().get(triggerName));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:TriggersSchemaTest.java


示例5: removeTriggerFromCf

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void removeTriggerFromCf() throws Exception
{
    TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    cfm1.addTriggerDefinition(td);
    KSMetaData ksm = KSMetaData.newKeyspace(ksName,
                                            SimpleStrategy.class,
                                            Collections.singletonMap("replication_factor", "1"),
                                            true,
                                            Collections.singletonList(cfm1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
    cfm2.removeTrigger(triggerName);
    MigrationManager.announceColumnFamilyUpdate(cfm2, false);

    CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName).copy();
    assertTrue(cfm3.getTriggers().isEmpty());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:TriggersSchemaTest.java


示例6: createKeyspace

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
/**
 * creating a keyspace
 *
 * @throws Exception
 */
@Test
public void createKeyspace() throws Exception {
	// keyspace define
	KsDef kd = new KsDef();
	kd.setName("mock");
	// kd.setStrategy_class("org.apache.cassandra.locator.SimpleStrategy");
	kd.setStrategy_class(SimpleStrategy.class.getName());
	//
	Map<String, String> map = new HashMap<String, String>();
	map.put("replication_factor", String.valueOf(1));
	kd.setStrategy_options(map);
	kd.setCf_defs(new ArrayList<CfDef>());
	//
	client.system_add_keyspace(kd);// InvalidRequestException(why:Keyspace
									// names must be case-insensitively
									// unique ("mock" conflicts with
									// "mock"))
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:24,代码来源:CassandraThriftDDLTest.java


示例7: getStrategy

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
static StrategyAdapter getStrategy(final TokenMetadata tokenMetadata, final SimpleStrategy rs, final InetAddress endpoint)
{
    final int replicas = rs.getReplicationFactor();

    return new StrategyAdapter()
    {
        @Override
        public int replicas()
        {
            return replicas;
        }

        @Override
        public Object getGroup(InetAddress unit)
        {
            return unit;
        }

        @Override
        public boolean inAllocationRing(InetAddress other)
        {
            return true;
        }
    };
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:TokenAllocation.java


示例8: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD));
    SchemaLoader.createKeyspace(KEYSPACE_CQL,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                CFMetaData.compile("CREATE TABLE " + CF_CQL + " ("
                                                 + "k text,"
                                                 + "c text,"
                                                 + "v text,"
                                                 + "PRIMARY KEY (k, c))", KEYSPACE_CQL));
    addData();
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:QueryPagerTest.java


示例9: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD1));
    SchemaLoader.createKeyspace(KEYSPACE_CACHED,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHED, CF_CACHED).caching(CachingOptions.ALL));
    SchemaLoader.createKeyspace(KEYSPACE_CQL,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                CFMetaData.compile("CREATE TABLE " + CF_CQL + " ("
                                                 + "k int PRIMARY KEY,"
                                                 + "v1 text,"
                                                 + "v2 int"
                                                 + ")", KEYSPACE_CQL));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:27,代码来源:CompactionsPurgeTest.java


示例10: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    Map<String, String> compactionOptions = new HashMap<>();
    compactionOptions.put("tombstone_compaction_interval", "1");
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1).compactionStrategyOptions(compactionOptions),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD4),
                                SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER1, LongType.instance),
                                SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER5, BytesType.instance),
                                SchemaLoader.superCFMD(KEYSPACE1, CF_SUPERGC, BytesType.instance).gcGraceSeconds(0));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:18,代码来源:CompactionsTest.java


示例11: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    AbstractType<?> compositeMaxMin = CompositeType.getInstance(Arrays.asList(new AbstractType<?>[]{BytesType.instance, IntegerType.instance}));
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARDLONG),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_STANDARDCOMPOSITE2, compositeMaxMin));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD3));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:18,代码来源:KeyspaceTest.java


示例12: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF2));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                false,
                                true,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF2));
    System.setProperty("cassandra.commitlog.stop_on_errors", "true");
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:CommitLogTest.java


示例13: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.startGossiper();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2));
    SchemaLoader.createKeyspace(KEYSPACE3, true, false,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(5),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                SchemaLoader.indexCFMD(KEYSPACE3, CF_INDEXED, true));
    SchemaLoader.createKeyspace(KEYSPACE6,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.indexCFMD(KEYSPACE6, CF_INDEXED, true));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:21,代码来源:DefsTest.java


示例14: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws Exception
{
    SchemaLoader.prepareServer();
    StorageService.instance.initServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance).defaultValidator(CounterColumnType.instance),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_STANDARDINT, IntegerType.instance),
                                SchemaLoader.indexCFMD(KEYSPACE1, CF_INDEX, true));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1));
    SchemaLoader.createKeyspace(KEYSPACE_CACHEKEY,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD2),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD3));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:StreamingTransferTest.java


示例15: setupAuthKeyspace

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
private static void setupAuthKeyspace()
{
    if (Schema.instance.getKSMetaData(AUTH_KS) == null)
    {
        try
        {
            KSMetaData ksm = KSMetaData.newKeyspace(AUTH_KS, SimpleStrategy.class.getName(), ImmutableMap.of("replication_factor", "1"), true);
            MigrationManager.announceNewKeyspace(ksm, 0, false);
        }
        catch (Exception e)
        {
            throw new AssertionError(e); // shouldn't ever happen.
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:Auth.java


示例16: testTransKsMigration

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@Test
public void testTransKsMigration() throws ConfigurationException
{
    SchemaLoader.cleanupAndLeaveDirs();
    DatabaseDescriptor.loadSchemas();
    assertEquals(0, Schema.instance.getNonSystemKeyspaces().size());

    Gossiper.instance.start((int)(System.currentTimeMillis() / 1000));
    Keyspace.setInitialized();

    try
    {
        // add a few.
        MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class, KSMetaData.optsWithRF(3)));
        MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class, KSMetaData.optsWithRF(3)));

        assertNotNull(Schema.instance.getKSMetaData("ks0"));
        assertNotNull(Schema.instance.getKSMetaData("ks1"));

        Schema.instance.clearKeyspaceDefinition(Schema.instance.getKSMetaData("ks0"));
        Schema.instance.clearKeyspaceDefinition(Schema.instance.getKSMetaData("ks1"));

        assertNull(Schema.instance.getKSMetaData("ks0"));
        assertNull(Schema.instance.getKSMetaData("ks1"));

        DatabaseDescriptor.loadSchemas();

        assertNotNull(Schema.instance.getKSMetaData("ks0"));
        assertNotNull(Schema.instance.getKSMetaData("ks1"));
    }
    finally
    {
        Gossiper.instance.stop();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:36,代码来源:DatabaseDescriptorTest.java


示例17: setupAuthKeyspace

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
private static void setupAuthKeyspace()
{
    if (Schema.instance.getKSMetaData(AUTH_KS) == null)
    {
        try
        {
            KSMetaData ksm = KSMetaData.newKeyspace(AUTH_KS, SimpleStrategy.class.getName(), ImmutableMap.of("replication_factor", "1"), true);
            MigrationManager.announceNewKeyspace(ksm, 0);
        }
        catch (Exception e)
        {
            throw new AssertionError(e); // shouldn't ever happen.
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:16,代码来源:Auth.java


示例18: defineSchema

import org.apache.cassandra.locator.SimpleStrategy; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    Map<String, String> leveledOptions = new HashMap<>();
    leveledOptions.put("sstable_size_in_mb", "1");
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARDLVL)
                                            .compactionStrategyClass(LeveledCompactionStrategy.class)
                                            .compactionStrategyOptions(leveledOptions));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:14,代码来源:LongLeveledCompactionStrategyTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocaleManager类代码示例发布时间:2022-05-21
下一篇:
Java MRConfig类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap