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


Java Event类代码示例

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


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

示例1: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的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

示例2: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的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

示例3: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的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

示例4: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的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

示例5: executeInternal

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public ResultMessage executeInternal(QueryState state, QueryOptions options)
{
    try
    {
        boolean didChangeSchema = announceMigration(true);
        if (!didChangeSchema)
            return new ResultMessage.Void();

        Event.SchemaChange ce = changeEvent();
        return ce == null ? new ResultMessage.Void() : new ResultMessage.SchemaChange(ce);
    }
    catch (RequestValidationException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:17,代码来源:SchemaAlteringStatement.java

示例6: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(name);
    // In the (very) unlikely case the keyspace was dropped since validate()
    if (oldKsm == null)
        throw new InvalidRequestException("Unknown keyspace " + name);

    KeyspaceMetadata newKsm = oldKsm.withSwapped(attrs.asAlteredKeyspaceParams(oldKsm.params));
    MigrationManager.announceKeyspaceUpdate(newKsm, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, keyspace());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:AlterKeyspaceStatement.java

示例7: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    Function old = Schema.instance.findFunction(functionName, argTypes).orElse(null);
    boolean replaced = old != null;
    if (replaced)
    {
        if (ifNotExists)
            return null;
        if (!orReplace)
            throw new InvalidRequestException(String.format("Function %s already exists", old));
        if (!(old instanceof AggregateFunction))
            throw new InvalidRequestException(String.format("Aggregate %s can only replace an aggregate", old));

        // Means we're replacing the function. We still need to validate that 1) it's not a native function and 2) that the return type
        // matches (or that could break existing code badly)
        if (old.isNative())
            throw new InvalidRequestException(String.format("Cannot replace native aggregate %s", old));
        if (!old.returnType().isValueCompatibleWith(returnType))
            throw new InvalidRequestException(String.format("Cannot replace aggregate %s, the new return type %s is not compatible with the return type %s of existing function",
                                                            functionName, returnType.asCQL3Type(), old.returnType().asCQL3Type()));
    }

    if (!stateFunction.isCalledOnNullInput() && initcond == null)
        throw new InvalidRequestException(String.format("Cannot create aggregate %s without INITCOND because state function %s does not accept 'null' arguments", functionName, stateFunc));

    UDAggregate udAggregate = new UDAggregate(functionName, argTypes, returnType, stateFunction, finalFunction, initcond);

    MigrationManager.announceNewAggregate(udAggregate, isLocalOnly);

    return new Event.SchemaChange(replaced ? Event.SchemaChange.Change.UPDATED : Event.SchemaChange.Change.CREATED,
                                  Event.SchemaChange.Target.AGGREGATE,
                                  udAggregate.name().keyspace, udAggregate.name().name, AbstractType.asCQLTypeStringList(udAggregate.argTypes()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:34,代码来源:CreateAggregateStatement.java

示例8: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
    {
        try
        {
//            ViewDefinition view = Schema.instance.getViewDefinition(keyspace(), columnFamily());
//            if (view == null)
//            {
//                if (Schema.instance.getCFMetaData(keyspace(), columnFamily()) != null)
//                    throw new ConfigurationException(String.format("Cannot drop table '%s' in keyspace '%s'.", columnFamily(), keyspace()));
//
//                throw new ConfigurationException(String.format("Cannot drop non existing materialized view '%s' in keyspace '%s'.", columnFamily(), keyspace()));
//            }
//
//            CFMetaData baseCfm = Schema.instance.getCFMetaData(view.baseTableId);
//            if (baseCfm == null)
//            {
//                if (ifExists)
//                    throw new ConfigurationException(String.format("Cannot drop materialized view '%s' in keyspace '%s' without base CF.", columnFamily(), keyspace()));
//                else
//                    throw new InvalidRequestException(String.format("View '%s' could not be found in any of the tables of keyspace '%s'", cfName, keyspace()));
//            }

            MigrationManager.announceViewDrop(keyspace(), columnFamily(), isLocalOnly);
            return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
        }
        catch (ConfigurationException e)
        {
            if (ifExists)
                return null;
            throw e;
        }
    }
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:DropViewStatement.java

示例9: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
{
    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
    if (ksm == null)
        return null; // do not assert (otherwise IF EXISTS case fails)

    UserType toDrop = ksm.types.getNullable(name.getUserTypeName());
    // Can be null with ifExists
    if (toDrop == null)
        return null;

    MigrationManager.announceTypeDrop(toDrop, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DropTypeStatement.java

示例10: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    try
    {
        MigrationManager.announceNewColumnFamily(getCFMetaData(), isLocalOnly);
        return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
    }
    catch (AlreadyExistsException e)
    {
        if (ifNotExists)
            return null;
        throw e;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:CreateTableStatement.java

示例11: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    Function old = Schema.instance.findFunction(functionName, argTypes).orElse(null);
    boolean replaced = old != null;
    if (replaced)
    {
        if (ifNotExists)
            return null;
        if (!orReplace)
            throw new InvalidRequestException(String.format("Function %s already exists", old));
        if (!(old instanceof ScalarFunction))
            throw new InvalidRequestException(String.format("Function %s can only replace a function", old));
        if (calledOnNullInput != ((ScalarFunction) old).isCalledOnNullInput())
            throw new InvalidRequestException(String.format("Function %s can only be replaced with %s", old,
                                                            calledOnNullInput ? "CALLED ON NULL INPUT" : "RETURNS NULL ON NULL INPUT"));

        if (!Functions.typesMatch(old.returnType(), returnType))
            throw new InvalidRequestException(String.format("Cannot replace function %s, the new return type %s is not compatible with the return type %s of existing function",
                                                            functionName, returnType.asCQL3Type(), old.returnType().asCQL3Type()));
    }

    UDFunction udFunction = UDFunction.create(functionName, argNames, argTypes, returnType, calledOnNullInput, language, body);

    MigrationManager.announceNewFunction(udFunction, isLocalOnly);

    return new Event.SchemaChange(replaced ? Event.SchemaChange.Change.UPDATED : Event.SchemaChange.Change.CREATED,
                                  Event.SchemaChange.Target.FUNCTION,
                                  udFunction.name().keyspace, udFunction.name().name, AbstractType.asCQLTypeStringList(udFunction.argTypes()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:30,代码来源:CreateFunctionStatement.java

示例12: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
{
    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
    assert ksm != null; // should haven't validate otherwise

    // Can happen with ifNotExists
    if (ksm.types.get(name.getUserTypeName()).isPresent())
        return null;

    UserType type = createType();
    checkForDuplicateNames(type);
    MigrationManager.announceNewType(type, isLocalOnly);
    return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:CreateTypeStatement.java

示例13: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws ConfigurationException
{
    try
    {
        MigrationManager.announceKeyspaceDrop(keyspace, isLocalOnly);
        return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, keyspace());
    }
    catch(ConfigurationException e)
    {
        if (ifExists)
            return null;
        throw e;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DropKeyspaceStatement.java

示例14: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
{
    CFMetaData cfm = lookupIndexedTable();
    if (cfm == null)
        return null;

    CFMetaData updatedCfm = cfm.copy();
    updatedCfm.indexes(updatedCfm.getIndexes().without(indexName));
    MigrationManager.announceColumnFamilyUpdate(updatedCfm, isLocalOnly);
    // Dropping an index is akin to updating the CF
    // Note that we shouldn't call columnFamily() at this point because the index has been dropped and the call to lookupIndexedTable()
    // in that method would now throw.
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, cfm.ksName, cfm.cfName);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DropIndexStatement.java

示例15: announceMigration

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    KeyspaceMetadata ksm = KeyspaceMetadata.create(name, attrs.asNewKeyspaceParams());
    try
    {
        MigrationManager.announceNewKeyspace(ksm, isLocalOnly);
        return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, keyspace());
    }
    catch (AlreadyExistsException e)
    {
        if (ifNotExists)
            return null;
        throw e;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:CreateKeyspaceStatement.java


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