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


Java ClientState.getKeyspace方法代码示例

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


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

示例1: system_add_column_family

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

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public List<ColumnOrSuperColumn> get_slice(ByteBuffer key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level)
throws InvalidRequestException, UnavailableException, TimedOutException
{
    if (startSessionIfRequested())
    {
        Map<String, String> traceParameters = ImmutableMap.of("key", ByteBufferUtil.bytesToHex(key),
                                                              "column_parent", column_parent.toString(),
                                                              "predicate", predicate.toString(),
                                                              "consistency_level", consistency_level.name());
        Tracing.instance.begin("get_slice", traceParameters);
    }
    else
    {
        logger.debug("get_slice");
    }

    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        state().hasColumnFamilyAccess(keyspace, column_parent.column_family, Permission.SELECT);
        return getSliceInternal(keyspace, key, column_parent, System.currentTimeMillis(), predicate, consistency_level, cState);
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:33,代码来源:CassandraServer.java

示例3: multiget_slice

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(List<ByteBuffer> keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level)
throws InvalidRequestException, UnavailableException, TimedOutException
{
    if (startSessionIfRequested())
    {
        List<String> keysList = Lists.newArrayList();
        for (ByteBuffer key : keys)
            keysList.add(ByteBufferUtil.bytesToHex(key));
        Map<String, String> traceParameters = ImmutableMap.of("keys", keysList.toString(),
                                                              "column_parent", column_parent.toString(),
                                                              "predicate", predicate.toString(),
                                                              "consistency_level", consistency_level.name());
        Tracing.instance.begin("multiget_slice", traceParameters);
    }
    else
    {
        logger.debug("multiget_slice");
    }

    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        cState.hasColumnFamilyAccess(keyspace, column_parent.column_family, Permission.SELECT);
        return multigetSliceInternal(keyspace, keys, column_parent, System.currentTimeMillis(), predicate, consistency_level, cState);
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:36,代码来源:CassandraServer.java

示例4: get_slice

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public List<ColumnOrSuperColumn> get_slice(ByteBuffer key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level)
throws InvalidRequestException, UnavailableException, TimedOutException
{
    if (startSessionIfRequested())
    {
        Map<String, String> traceParameters = ImmutableMap.of("key", ByteBufferUtil.bytesToHex(key),
                                                              "column_parent", column_parent.toString(),
                                                              "predicate", predicate.toString(),
                                                              "consistency_level", consistency_level.name());
        Tracing.instance.begin("get_slice", traceParameters);
    }
    else
    {
        logger.debug("get_slice");
    }

    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        state().hasColumnFamilyAccess(keyspace, column_parent.column_family, Permission.SELECT);
        return getSliceInternal(keyspace, key, column_parent, System.currentTimeMillis(), predicate, consistency_level);
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:33,代码来源:CassandraServer.java

示例5: multiget_slice

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(List<ByteBuffer> keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level)
throws InvalidRequestException, UnavailableException, TimedOutException
{
    if (startSessionIfRequested())
    {
        List<String> keysList = Lists.newArrayList();
        for (ByteBuffer key : keys)
            keysList.add(ByteBufferUtil.bytesToHex(key));
        Map<String, String> traceParameters = ImmutableMap.of("keys", keysList.toString(),
                                                              "column_parent", column_parent.toString(),
                                                              "predicate", predicate.toString(),
                                                              "consistency_level", consistency_level.name());
        Tracing.instance.begin("multiget_slice", traceParameters);
    }
    else
    {
        logger.debug("multiget_slice");
    }

    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        cState.hasColumnFamilyAccess(keyspace, column_parent.column_family, Permission.SELECT);
        return multigetSliceInternal(keyspace, keys, column_parent, System.currentTimeMillis(), predicate, consistency_level);
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:36,代码来源:CassandraServer.java

示例6: prepareKeyspace

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public void prepareKeyspace(ClientState state) throws InvalidRequestException
{
    if (!functionName.hasKeyspace() && state.getRawKeyspace() != null)
        functionName = new FunctionName(state.getKeyspace(), functionName.name);

    if (!functionName.hasKeyspace())
        throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session");

    ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace);

    stateFunc = new FunctionName(functionName.keyspace, stateFunc.name);
    if (finalFunc != null)
        finalFunc = new FunctionName(functionName.keyspace, finalFunc.name);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:CreateAggregateStatement.java

示例7: prepareKeyspace

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public void prepareKeyspace(ClientState state) throws InvalidRequestException
{
    if (!functionName.hasKeyspace() && state.getRawKeyspace() != null)
        functionName = new FunctionName(state.getKeyspace(), functionName.name);

    if (!functionName.hasKeyspace())
        throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session");

    ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:11,代码来源:DropAggregateStatement.java

示例8: prepareKeyspace

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
@Override
public void prepareKeyspace(ClientState state) throws InvalidRequestException
{
    if (!functionName.hasKeyspace() && state.getRawKeyspace() != null)
        functionName = new FunctionName(state.getKeyspace(), functionName.name);

    if (!functionName.hasKeyspace())
        throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session");

    ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:DropFunctionStatement.java

示例9: get_multi_slice

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
@Override
public List<ColumnOrSuperColumn> get_multi_slice(MultiSliceRequest request)
        throws InvalidRequestException, UnavailableException, TimedOutException
{
    if (startSessionIfRequested())
    {
        Map<String, String> traceParameters = ImmutableMap.of("key", ByteBufferUtil.bytesToHex(request.key),
                                                              "column_parent", request.column_parent.toString(),
                                                              "consistency_level", request.consistency_level.name(),
                                                              "count", String.valueOf(request.count),
                                                              "column_slices", request.column_slices.toString());
        Tracing.instance.begin("get_multi_slice", traceParameters);
    }
    else
    {
        logger.debug("get_multi_slice");
    }
    try
    {
        ClientState cState = state();
        String keyspace = cState.getKeyspace();
        state().hasColumnFamilyAccess(keyspace, request.getColumn_parent().column_family, Permission.SELECT);
        CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace, request.getColumn_parent().column_family);
        if (metadata.cfType == ColumnFamilyType.Super)
            throw new org.apache.cassandra.exceptions.InvalidRequestException("get_multi_slice does not support super columns");
        ThriftValidation.validateColumnParent(metadata, request.getColumn_parent());
        org.apache.cassandra.db.ConsistencyLevel consistencyLevel = ThriftConversion.fromThrift(request.getConsistency_level());
        consistencyLevel.validateForRead(keyspace);
        List<ReadCommand> commands = new ArrayList<>(1);
        ColumnSlice[] slices = new ColumnSlice[request.getColumn_slices().size()];
        for (int i = 0 ; i < request.getColumn_slices().size() ; i++)
        {
            fixOptionalSliceParameters(request.getColumn_slices().get(i));
            Composite start = metadata.comparator.fromByteBuffer(request.getColumn_slices().get(i).start);
            Composite finish = metadata.comparator.fromByteBuffer(request.getColumn_slices().get(i).finish);
            if (!start.isEmpty() && !finish.isEmpty())
            {
                int compare = metadata.comparator.compare(start, finish);
                if (!request.reversed && compare > 0)
                    throw new InvalidRequestException(String.format("Column slice at index %d had start greater than finish", i));
                else if (request.reversed && compare < 0)
                    throw new InvalidRequestException(String.format("Reversed column slice at index %d had start less than finish", i));
            }
            slices[i] = new ColumnSlice(start, finish);
        }

        ColumnSlice[] deoverlapped = ColumnSlice.deoverlapSlices(slices, request.reversed ? metadata.comparator.reverseComparator() : metadata.comparator);
        SliceQueryFilter filter = new SliceQueryFilter(deoverlapped, request.reversed, request.count);
        ThriftValidation.validateKey(metadata, request.key);
        commands.add(ReadCommand.create(keyspace, request.key, request.column_parent.getColumn_family(), System.currentTimeMillis(), filter));
        return getSlice(commands, request.column_parent.isSetSuper_column(), consistencyLevel, cState).entrySet().iterator().next().getValue();
    }
    catch (RequestValidationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:62,代码来源:CassandraServer.java


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