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


Java SimpleStrategy类代码示例

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


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


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