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


Java ConsistencyLevel类代码示例

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


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

示例1: gatherFlags

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private EnumSet<Flag> gatherFlags(QueryOptions options)
{
    EnumSet<Flag> flags = EnumSet.noneOf(Flag.class);
    if (options.getValues().size() > 0)
        flags.add(Flag.VALUES);
    if (options.skipMetadata())
        flags.add(Flag.SKIP_METADATA);
    if (options.getPageSize() >= 0)
        flags.add(Flag.PAGE_SIZE);
    if (options.getPagingState() != null)
        flags.add(Flag.PAGING_STATE);
    if (options.getSerialConsistency() != ConsistencyLevel.SERIAL)
        flags.add(Flag.SERIAL_CONSISTENCY);
    if (options.getSpecificOptions().timestamp != Long.MIN_VALUE)
        flags.add(Flag.TIMESTAMP);
    return flags;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:QueryOptions.java

示例2: mutate

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private void mutate(List<org.apache.cassandra.db.Mutation> cmds, org.apache.cassandra.db.ConsistencyLevel clvl) throws BackendException {
    try {
        schedule(DatabaseDescriptor.getRpcTimeout());
        try {
            if (atomicBatch) {
                StorageProxy.mutateAtomically(cmds, clvl);
            } else {
                StorageProxy.mutate(cmds, clvl);
            }
        } catch (RequestExecutionException e) {
            throw new TemporaryBackendException(e);
        } finally {
            release();
        }
    } catch (TimeoutException ex) {
        log.debug("Cassandra TimeoutException", ex);
        throw new TemporaryBackendException(ex);
    }
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:20,代码来源:CassandraEmbeddedStoreManager.java

示例3: setupDefaultSuperuser

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private static void setupDefaultSuperuser()
{
    try
    {
        // insert a default superuser if AUTH_KS.USERS_CF is empty.
        if (!hasExistingUsers())
        {
            QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s', %s) USING TIMESTAMP 0",
                                                 AUTH_KS,
                                                 USERS_CF,
                                                 DEFAULT_SUPERUSER_NAME,
                                                 true),
                                   ConsistencyLevel.ONE);
            logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME);
        }
    }
    catch (RequestExecutionException e)
    {
        logger.warn("Skipped default superuser setup: some nodes were not ready");
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:Auth.java

示例4: setupDefaultUser

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private void setupDefaultUser()
{
    try
    {
        // insert the default superuser if AUTH_KS.CREDENTIALS_CF is empty.
        if (!hasExistingUsers())
        {
            process(String.format("INSERT INTO %s.%s (username, salted_hash) VALUES ('%s', '%s') USING TIMESTAMP 0",
                                  Auth.AUTH_KS,
                                  CREDENTIALS_CF,
                                  DEFAULT_USER_NAME,
                                  escape(hashpw(DEFAULT_USER_PASSWORD))),
                    ConsistencyLevel.ONE);
            logger.info("PasswordAuthenticator created default user '{}'", DEFAULT_USER_NAME);
        }
    }
    catch (RequestExecutionException e)
    {
        logger.warn("PasswordAuthenticator skipped default user setup: some nodes were not ready");
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:PasswordAuthenticator.java

示例5: DatacenterSyncWriteResponseHandler

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
public DatacenterSyncWriteResponseHandler(Collection<InetAddress> naturalEndpoints,
                                          Collection<InetAddress> pendingEndpoints,
                                          ConsistencyLevel consistencyLevel,
                                          Keyspace keyspace,
                                          Runnable callback,
                                          WriteType writeType)
{
    // Response is been managed by the map so make it 1 for the superclass.
    super(keyspace, naturalEndpoints, pendingEndpoints, consistencyLevel, callback, writeType);
    assert consistencyLevel == ConsistencyLevel.EACH_QUORUM;

    strategy = (NetworkTopologyStrategy) keyspace.getReplicationStrategy();

    for (String dc : strategy.getDatacenters())
    {
        int rf = strategy.getReplicationFactor(dc);
        responses.put(dc, new AtomicInteger((rf / 2) + 1));
    }

    // During bootstrap, we have to include the pending endpoints or we may fail the consistency level
    // guarantees (see #833)
    for (InetAddress pending : pendingEndpoints)
    {
        responses.get(snitch.getDatacenter(pending)).incrementAndGet();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:DatacenterSyncWriteResponseHandler.java

示例6: setupDefaultSuperuser

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private static void setupDefaultSuperuser()
{
    try
    {
        // insert a default superuser if AUTH_KS.USERS_CF is empty.
        if (QueryProcessor.process(String.format("SELECT * FROM %s.%s", AUTH_KS, USERS_CF), ConsistencyLevel.QUORUM).isEmpty())
        {
            QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s', %s) USING TIMESTAMP 0",
                                                 AUTH_KS,
                                                 USERS_CF,
                                                 DEFAULT_SUPERUSER_NAME,
                                                 true),
                                   ConsistencyLevel.QUORUM);
            logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME);
        }
    }
    catch (RequestExecutionException e)
    {
        logger.warn("Skipped default superuser setup: some nodes were not ready");
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:Auth.java

示例7: executeTriggerOnThriftBatchUpdate

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
@Test
public void executeTriggerOnThriftBatchUpdate() throws Exception
{
    Cassandra.Client client = new Cassandra.Client(
                                new TBinaryProtocol(
                                    new TFramedTransportFactory().openTransport(
                                        InetAddress.getLocalHost().getHostName(), 9170)));
    client.set_keyspace(ksName);
    org.apache.cassandra.thrift.Mutation mutation = new org.apache.cassandra.thrift.Mutation();
    ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
    cosc.setColumn(getColumnForInsert("v1", 3));
    mutation.setColumn_or_supercolumn(cosc);
    client.batch_mutate(
        Collections.singletonMap(bytes(3),
                                 Collections.singletonMap(cfName,
                                                          Collections.singletonList(mutation))),
        org.apache.cassandra.thrift.ConsistencyLevel.ONE);

    assertUpdateIsAugmented(3);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:TriggersTest.java

示例8: onThriftCASRejectGeneratedUpdatesForDifferentCF

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
@Test(expected=InvalidRequestException.class)
public void onThriftCASRejectGeneratedUpdatesForDifferentCF() throws Exception
{
    String cf = "cf" + System.nanoTime();
    try
    {
        setupTableWithTrigger(cf, CrossTableTrigger.class);
        Cassandra.Client client = new Cassandra.Client(
                new TBinaryProtocol(
                        new TFramedTransportFactory().openTransport(
                                InetAddress.getLocalHost().getHostName(), 9170)));
        client.set_keyspace(ksName);
        client.cas(bytes(10),
                   cf,
                   Collections.<Column>emptyList(),
                   Collections.singletonList(getColumnForInsert("v1", 10)),
                   org.apache.cassandra.thrift.ConsistencyLevel.LOCAL_SERIAL,
                   org.apache.cassandra.thrift.ConsistencyLevel.ONE);
    }
    finally
    {
        assertUpdateNotExecuted(cf, 10);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:TriggersTest.java

示例9: onThriftCASRejectGeneratedUpdatesForDifferentPartition

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
@Test(expected=InvalidRequestException.class)
public void onThriftCASRejectGeneratedUpdatesForDifferentPartition() throws Exception
{
    String cf = "cf" + System.nanoTime();
    try
    {
        setupTableWithTrigger(cf, CrossPartitionTrigger.class);
        Cassandra.Client client = new Cassandra.Client(
                new TBinaryProtocol(
                        new TFramedTransportFactory().openTransport(
                                InetAddress.getLocalHost().getHostName(), 9170)));
        client.set_keyspace(ksName);
        client.cas(bytes(9),
                   cf,
                   Collections.<Column>emptyList(),
                   Collections.singletonList(getColumnForInsert("v1", 9)),
                   org.apache.cassandra.thrift.ConsistencyLevel.LOCAL_SERIAL,
                   org.apache.cassandra.thrift.ConsistencyLevel.ONE);
    }
    finally
    {
        assertUpdateNotExecuted(cf, 9);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:TriggersTest.java

示例10: testWriting

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private static void testWriting() throws Exception
{
    // do some writing.
    for (int i = 0; i < 100; i++)
    {
        QueryProcessor.process(String.format("INSERT INTO %s.%s (id, name, value) VALUES ( 'key%d', 'colb', 'value%d')",
                                             KEYSPACE,
                                             COLUMN_FAMILY,
                                             i,
                                             i),
                               ConsistencyLevel.QUORUM);

        System.out.println("wrote key" + i);
    }
    System.out.println("Done writing.");
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:17,代码来源:ClientOnlyExample.java

示例11: AbstractReadExecutor

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
AbstractReadExecutor(Keyspace keyspace, ReadCommand command, ConsistencyLevel consistencyLevel, List<InetAddress> targetReplicas)
{
    this.command = command;
    this.targetReplicas = targetReplicas;
    this.handler = new ReadCallback(new DigestResolver(keyspace, command, consistencyLevel, targetReplicas.size()), consistencyLevel, command, targetReplicas);
    this.traceState = Tracing.instance.get();

    // Set the digest version (if we request some digests). This is the smallest version amongst all our target replicas since new nodes
    // knows how to produce older digest but the reverse is not true.
    // TODO: we need this when talking with pre-3.0 nodes. So if we preserve the digest format moving forward, we can get rid of this once
    // we stop being compatible with pre-3.0 nodes.
    int digestVersion = MessagingService.current_version;
    for (InetAddress replica : targetReplicas)
        digestVersion = Math.min(digestVersion, MessagingService.instance().getVersion(replica));
    command.setDigestVersion(digestVersion);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:AbstractReadExecutor.java

示例12: decode

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
public BatchMessage decode(ChannelBuffer body, int version)
{
    if (version == 1)
        throw new ProtocolException("BATCH messages are not support in version 1 of the protocol");

    byte type = body.readByte();
    int n = body.readUnsignedShort();
    List<Object> queryOrIds = new ArrayList<Object>(n);
    List<List<ByteBuffer>> variables = new ArrayList<List<ByteBuffer>>(n);
    for (int i = 0; i < n; i++)
    {
        byte kind = body.readByte();
        if (kind == 0)
            queryOrIds.add(CBUtil.readLongString(body));
        else if (kind == 1)
            queryOrIds.add(MD5Digest.wrap(CBUtil.readBytes(body)));
        else
            throw new ProtocolException("Invalid query kind in BATCH messages. Must be 0 or 1 but got " + kind);
        variables.add(CBUtil.readValueList(body));
    }
    ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body);
    return new BatchMessage(toType(type), queryOrIds, variables, consistency);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:24,代码来源:BatchMessage.java

示例13: addStatementMutations

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private void addStatementMutations(ModificationStatement statement,
                                   List<ByteBuffer> variables,
                                   boolean local,
                                   ConsistencyLevel cl,
                                   long now,
                                   Map<Pair<String, ByteBuffer>, IMutation> mutations)
throws RequestExecutionException, RequestValidationException
{
    // Group mutation together, otherwise they won't get applied atomically
    for (IMutation m : statement.getMutations(variables, local, cl, attrs.getTimestamp(now, variables), true))
    {
        Pair<String, ByteBuffer> key = Pair.create(m.getKeyspaceName(), m.key());
        IMutation existing = mutations.get(key);

        if (existing == null)
        {
            mutations.put(key, m);
        }
        else
        {
            existing.addAll(m);
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:BatchStatement.java

示例14: DefaultQueryOptions

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
DefaultQueryOptions(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, SpecificOptions options, ProtocolVersion protocolVersion)
{
    this.consistency = consistency;
    this.values = values;
    this.skipMetadata = skipMetadata;
    this.options = options;
    this.protocolVersion = protocolVersion;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:QueryOptions.java

示例15: SpecificOptions

import org.apache.cassandra.db.ConsistencyLevel; //导入依赖的package包/类
private SpecificOptions(int pageSize, PagingState state, ConsistencyLevel serialConsistency, long timestamp)
{
    this.pageSize = pageSize;
    this.state = state;
    this.serialConsistency = serialConsistency == null ? ConsistencyLevel.SERIAL : serialConsistency;
    this.timestamp = timestamp;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:8,代码来源:QueryOptions.java


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