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

Java Event类代码示例

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

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



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


示例16: execute

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
{
    // If an IF [NOT] EXISTS clause was used, this may not result in an actual schema change.  To avoid doing
    // extra work in the drivers to handle schema changes, we return an empty message in this case. (CASSANDRA-7600)
    Event.SchemaChange ce = announceMigration(false);
    if (ce == null)
        return new ResultMessage.Void();

    // when a schema alteration results in a new db object being created, we grant permissions on the new
    // object to the user performing the request if:
    // * the user is not anonymous
    // * the configured IAuthorizer supports granting of permissions (not all do, AllowAllAuthorizer doesn't and
    //   custom external implementations may not)
    AuthenticatedUser user = state.getClientState().getUser();
    if (user != null && !user.isAnonymous() && ce.change == Event.SchemaChange.Change.CREATED)
    {
        try
        {
            grantPermissionsToCreator(state);
        }
        catch (UnsupportedOperationException e)
        {
            // not a problem, grant is an optional method on IAuthorizer
        }
    }

    return new ResultMessage.SchemaChange(ce);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:SchemaAlteringStatement.java


示例17: assertLastSchemaChange

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
protected void assertLastSchemaChange(Event.SchemaChange.Change change, Event.SchemaChange.Target target,
                                      String keyspace, String name,
                                      String... argTypes)
{
    Assert.assertTrue(lastSchemaChangeResult instanceof ResultMessage.SchemaChange);
    ResultMessage.SchemaChange schemaChange = (ResultMessage.SchemaChange) lastSchemaChangeResult;
    Assert.assertSame(change, schemaChange.change.change);
    Assert.assertSame(target, schemaChange.change.target);
    Assert.assertEquals(keyspace, schemaChange.change.keyspace);
    Assert.assertEquals(name, schemaChange.change.name);
    Assert.assertEquals(argTypes != null ? Arrays.asList(argTypes) : null, schemaChange.change.argTypes);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:CQLTester.java


示例18: execute

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
{
    // If an IF [NOT] EXISTS clause was used, this may not result in an actual schema change.  To avoid doing
    // extra work in the drivers to handle schema changes, we return an empty message in this case. (CASSANDRA-7600)
    boolean didChangeSchema = announceMigration(false);
    if (!didChangeSchema)
        return new ResultMessage.Void();

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


示例19: changeEvent

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange changeEvent()
{
    return new Event.SchemaChange(Event.SchemaChange.Change.DROPPED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:DropTableStatement.java


示例20: changeEvent

import org.apache.cassandra.transport.Event; //导入依赖的package包/类
public Event.SchemaChange changeEvent()
{
    return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:CreateTriggerStatement.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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