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


Java MigrationManager.announceNewKeyspace方法代码示例

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


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

示例1: newKsContainsCfWithTrigger

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的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

示例2: addNewCfWithTriggerToKs

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的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

示例3: addTriggerToCf

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的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

示例4: removeTriggerFromCf

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的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

示例5: loadSchema

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public static void loadSchema(boolean withOldCfIds) throws IOException, ConfigurationException
{
    // Cleanup first
    cleanupAndLeaveDirs();

    CommitLog.instance.allocator.enableReserveSegmentCreation();

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
    {
        public void uncaughtException(Thread t, Throwable e)
        {
            logger.error("Fatal exception in thread " + t, e);
        }
    });

    // Migrations aren't happy if gossiper is not started.  Even if we don't use migrations though,
    // some tests now expect us to start gossip for them.
    startGossiper();
    // if you're messing with low-level sstable stuff, it can be useful to inject the schema directly
    // Schema.instance.load(schemaDefinition(withOldCfIds));
    for (KSMetaData ksm : schemaDefinition(withOldCfIds))
        MigrationManager.announceNewKeyspace(ksm);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:24,代码来源:SchemaLoader.java

示例6: addNewCfWithTriggerToKs

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfWithTriggerToKs() throws Exception
{
    KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
    cfm1.triggers(cfm1.getTriggers().with(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).get());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:TriggersSchemaTest.java

示例7: addTriggerToCf

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addTriggerToCf() throws Exception
{
    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1), Tables.of(cfm1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
    TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
    cfm2.triggers(cfm2.getTriggers().with(td));
    MigrationManager.announceColumnFamilyUpdate(cfm2);

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

示例8: removeTriggerFromCf

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void removeTriggerFromCf() throws Exception
{
    TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
    CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
    cfm1.triggers(cfm1.getTriggers().with(td));
    KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1), Tables.of(cfm1));
    MigrationManager.announceNewKeyspace(ksm);

    CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
    cfm2.triggers(cfm2.getTriggers().without(triggerName));
    MigrationManager.announceColumnFamilyUpdate(cfm2);

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

示例9: addNewKS

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewKS() throws ConfigurationException
{
    CFMetaData cfm = addTestTable("newkeyspace1", "newstandard1", "A new cf for a new ks");
    KeyspaceMetadata newKs = KeyspaceMetadata.create(cfm.ksName, KeyspaceParams.simple(5), Tables.of(cfm));
    MigrationManager.announceNewKeyspace(newKs);

    assertNotNull(Schema.instance.getKSMetaData(cfm.ksName));
    assertEquals(Schema.instance.getKSMetaData(cfm.ksName), newKs);

    // test reads and writes.
    QueryProcessor.executeInternal("INSERT INTO newkeyspace1.newstandard1 (key, col, val) VALUES (?, ?, ?)",
                                   "key0", "col0", "val0");
    ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName);
    assertNotNull(store);
    store.forceBlockingFlush();

    UntypedResultSet rows = QueryProcessor.executeInternal("SELECT * FROM newkeyspace1.newstandard1");
    assertRows(rows, row("key0", "col0", "val0"));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:DefsTest.java

示例10: loadSchema

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@BeforeClass
public static void loadSchema() throws ConfigurationException
{
    // Cleanup first
    cleanupAndLeaveDirs();

    CommitLog.instance.allocator.enableReserveSegmentCreation();

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
    {
        public void uncaughtException(Thread t, Throwable e)
        {
            logger.error("Fatal exception in thread " + t, e);
        }
    });

    Keyspace.setInitialized();
    // Migrations aren't happy if gossiper is not started.  Even if we don't use migrations though,
    // some tests now expect us to start gossip for them.
    startGossiper();
    // if you're messing with low-level sstable stuff, it can be useful to inject the schema directly
    // Schema.instance.load(schemaDefinition());
    for (KSMetaData ksm : schemaDefinition())
        MigrationManager.announceNewKeyspace(ksm);
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:26,代码来源:SchemaLoader.java

示例11: loadSchema

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public static void loadSchema(boolean withOldCfIds) throws ConfigurationException
{
    // Cleanup first
    cleanupAndLeaveDirs();

    CommitLog.instance.allocator.enableReserveSegmentCreation();

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
    {
        public void uncaughtException(Thread t, Throwable e)
        {
            logger.error("Fatal exception in thread " + t, e);
        }
    });

    // Migrations aren't happy if gossiper is not started.  Even if we don't use migrations though,
    // some tests now expect us to start gossip for them.
    startGossiper();
    // if you're messing with low-level sstable stuff, it can be useful to inject the schema directly
    // Schema.instance.load(schemaDefinition(withOldCfIds));
    for (KSMetaData ksm : schemaDefinition(withOldCfIds))
        MigrationManager.announceNewKeyspace(ksm);
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:24,代码来源:SchemaLoader.java

示例12: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    try
    {
        MigrationManager.announceNewKeyspace(attrs.asKSMetadata(name), isLocalOnly);
        return true;
    }
    catch (AlreadyExistsException e)
    {
        if (ifNotExists)
            return false;
        throw e;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:CreateKeyspaceStatement.java

示例13: system_add_keyspace

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public String system_add_keyspace(KsDef ks_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
    logger.debug("add_keyspace");

    try
    {
        ThriftValidation.validateKeyspaceNotSystem(ks_def.name);
        state().hasAllKeyspacesAccess(Permission.CREATE);
        ThriftValidation.validateKeyspaceNotYetExisting(ks_def.name);

        // generate a meaningful error if the user setup keyspace and/or column definition incorrectly
        for (CfDef cf : ks_def.cf_defs)
        {
            if (!cf.getKeyspace().equals(ks_def.getName()))
            {
                throw new InvalidRequestException("CfDef (" + cf.getName() +") had a keyspace definition that did not match KsDef");
            }
        }

        Collection<CFMetaData> cfDefs = new ArrayList<CFMetaData>(ks_def.cf_defs.size());
        for (CfDef cf_def : ks_def.cf_defs)
        {
            cf_def.unsetId(); // explicitly ignore any id set by client (same as system_add_column_family)
            CFMetaData cfm = CFMetaData.fromThrift(cf_def);
            cfm.addDefaultIndexNames();

            if (!cfm.getTriggers().isEmpty())
                state().ensureIsSuper("Only superusers are allowed to add triggers.");

            cfDefs.add(cfm);
        }
        MigrationManager.announceNewKeyspace(KSMetaData.fromThrift(ks_def, cfDefs.toArray(new CFMetaData[cfDefs.size()])));
        return Schema.instance.getVersion().toString();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:41,代码来源:CassandraServer.java

示例14: testTransKsMigration

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的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

示例15: loadSchema

import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@BeforeClass
public static void loadSchema() throws ConfigurationException
{
    prepareServer();

    // Migrations aren't happy if gossiper is not started.  Even if we don't use migrations though,
    // some tests now expect us to start gossip for them.
    startGossiper();

    // if you're messing with low-level sstable stuff, it can be useful to inject the schema directly
    // Schema.instance.load(schemaDefinition());
    for (KSMetaData ksm : schemaDefinition())
        MigrationManager.announceNewKeyspace(ksm);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:SchemaLoader.java


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