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


Java MigrationManager类代码示例

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


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

示例1: system_add_column_family

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public String system_add_column_family(CfDef cf_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
    logger.debug("add_column_family");

    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        cState.hasKeyspaceAccess(keyspace, Permission.CREATE);
        cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero)
        CFMetaData cfm = CFMetaData.fromThrift(cf_def);
        CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions);
        cfm.addDefaultIndexNames();

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

        MigrationManager.announceNewColumnFamily(cfm);
        return Schema.instance.getVersion().toString();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:CassandraServer.java

示例2: system_drop_column_family

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public String system_drop_column_family(String column_family)
throws InvalidRequestException, SchemaDisagreementException, TException
{
    logger.debug("drop_column_family");

    ThriftClientState cState = state();

    try
    {
        String keyspace = cState.getKeyspace();
        cState.hasColumnFamilyAccess(keyspace, column_family, Permission.DROP);
        MigrationManager.announceColumnFamilyDrop(keyspace, column_family);
        return Schema.instance.getVersion().toString();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:CassandraServer.java

示例3: system_drop_keyspace

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public String system_drop_keyspace(String keyspace)
throws InvalidRequestException, SchemaDisagreementException, TException
{
    logger.debug("drop_keyspace");

    try
    {
        ThriftValidation.validateKeyspaceNotSystem(keyspace);
        state().hasKeyspaceAccess(keyspace, Permission.DROP);

        MigrationManager.announceKeyspaceDrop(keyspace);
        return Schema.instance.getVersion().toString();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:CassandraServer.java

示例4: system_update_keyspace

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
/** update an existing keyspace, but do not allow column family modifications.
 * @throws SchemaDisagreementException
 */
public String system_update_keyspace(KsDef ks_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
    logger.debug("update_keyspace");

    try
    {
        ThriftValidation.validateKeyspaceNotSystem(ks_def.name);
        state().hasKeyspaceAccess(ks_def.name, Permission.ALTER);
        ThriftValidation.validateKeyspace(ks_def.name);
        if (ks_def.getCf_defs() != null && ks_def.getCf_defs().size() > 0)
            throw new InvalidRequestException("Keyspace update must not contain any column family definitions.");

        MigrationManager.announceKeyspaceUpdate(KSMetaData.fromThrift(ks_def));
        return Schema.instance.getVersion().toString();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:CassandraServer.java

示例5: 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

示例6: 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

示例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);
    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

示例8: 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

示例9: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
    logger.debug("Updating column {} definition for index {}", columnName, indexName);
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
    ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);

    if (cd.getIndexType() != null && ifNotExists)
        return;

    if (isCustom)
        cd.setIndexType(IndexType.CUSTOM, Collections.singletonMap(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, indexClass));
    else if (cfm.getCfDef().isComposite)
        cd.setIndexType(IndexType.COMPOSITES, Collections.<String, String>emptyMap());
    else
        cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());

    cd.setIndexName(indexName);
    cfm.addDefaultIndexNames();
    MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:CreateIndexStatement.java

示例10: 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

示例11: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
    Triggers triggers = cfm.getTriggers();

    if (triggers.get(triggerName).isPresent())
    {
        if (ifNotExists)
            return null;
        else
            throw new InvalidRequestException(String.format("Trigger %s already exists", triggerName));
    }

    cfm.triggers(triggers.with(TriggerMetadata.create(triggerName, triggerClass)));
    logger.info("Adding trigger with name {} and class {}", triggerName, triggerClass);
    MigrationManager.announceColumnFamilyUpdate(cfm, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:CreateTriggerStatement.java

示例12: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
    Triggers triggers = cfm.getTriggers();

    if (!triggers.get(triggerName).isPresent())
    {
        if (ifExists)
            return null;
        else
            throw new InvalidRequestException(String.format("Trigger %s was not found", triggerName));
    }

    logger.info("Dropping trigger with name {}", triggerName);
    cfm.triggers(triggers.without(triggerName));
    MigrationManager.announceColumnFamilyUpdate(cfm, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:DropTriggerStatement.java

示例13: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    Function old = findFunction();
    if (old == null)
    {
        if (ifExists)
            return null;
        else
            throw new InvalidRequestException(getMissingFunctionError());
    }

    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(old.name().keyspace);
    Collection<UDAggregate> referrers = ksm.functions.aggregatesUsingFunction(old);
    if (!referrers.isEmpty())
        throw new InvalidRequestException(String.format("Function '%s' still referenced by %s", old, referrers));

    MigrationManager.announceFunctionDrop((UDFunction) old, isLocalOnly);

    return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.FUNCTION,
                                  old.name().keyspace, old.name().name, AbstractType.asCQLTypeStringList(old.argTypes()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:DropFunctionStatement.java

示例14: announceMigration

import org.apache.cassandra.service.MigrationManager; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    CFMetaData meta = validateColumnFamily(keyspace(), columnFamily());
    if (!meta.isView())
        throw new InvalidRequestException("Cannot use ALTER MATERIALIZED VIEW on Table");

    ViewDefinition viewCopy = Schema.instance.getView(keyspace(), columnFamily()).copy();

    if (attrs == null)
        throw new InvalidRequestException("ALTER MATERIALIZED VIEW WITH invoked, but no parameters found");

    attrs.validate();

    TableParams params = attrs.asAlteredTableParams(viewCopy.metadata.params);
    if (params.gcGraceSeconds == 0)
    {
        throw new InvalidRequestException("Cannot alter gc_grace_seconds of a materialized view to 0, since this " +
                                          "value is used to TTL undelivered updates. Setting gc_grace_seconds too " +
                                          "low might cause undelivered updates to expire before being replayed.");
    }
    viewCopy.metadata.params(params);

    MigrationManager.announceViewUpdate(viewCopy, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:AlterViewStatement.java

示例15: 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


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