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


Java MessagingService类代码示例

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


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

示例1: fromBytes

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
/**
 * Deserialize a partition update from a provided byte buffer.
 *
 * @param bytes the byte buffer that contains the serialized update.
 * @param version the version with which the update is serialized.
 * @param key the partition key for the update. This is only used if {@code version &lt 3.0}
 * and can be {@code null} otherwise.
 *
 * @return the deserialized update or {@code null} if {@code bytes == null}.
 */
public static PartitionUpdate fromBytes(ByteBuffer bytes, int version, DecoratedKey key)
{
    if (bytes == null)
        return null;

    try
    {
        return serializer.deserialize(new DataInputBuffer(bytes, true),
                                      version,
                                      SerializationHelper.Flag.LOCAL,
                                      version < MessagingService.VERSION_30 ? key : null);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:28,代码来源:PartitionUpdate.java

示例2: await

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
Outcome await()
{
    long timeout = TimeUnit.MILLISECONDS.toNanos(DatabaseDescriptor.getTimeout(MessagingService.Verb.HINT)) - (System.nanoTime() - start);
    boolean timedOut;

    try
    {
        timedOut = !condition.await(timeout, TimeUnit.NANOSECONDS);
    }
    catch (InterruptedException e)
    {
        throw new AssertionError(e);
    }

    return timedOut ? Outcome.TIMEOUT : outcome;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:HintsDispatcher.java

示例3: deserialize

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public PrepareResponse deserialize(DataInputPlus in, int version) throws IOException
{
    boolean success = in.readBoolean();
    Commit inProgress = Commit.serializer.deserialize(in, version);
    Commit mostRecent;
    if (version < MessagingService.VERSION_30)
    {
        UUID ballot = UUIDSerializer.serializer.deserialize(in, version);
        PartitionUpdate update = PartitionUpdate.serializer.deserialize(in, version, SerializationHelper.Flag.LOCAL, inProgress.update.partitionKey());
        mostRecent = new Commit(ballot, update);
    }
    else
    {
        mostRecent = Commit.serializer.deserialize(in, version);
    }
    return new PrepareResponse(success, inProgress, mostRecent);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:PrepareResponse.java

示例4: finishParentSession

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public synchronized void finishParentSession(UUID parentSession, Set<InetAddress> neighbors, boolean doAntiCompaction) throws InterruptedException, ExecutionException, IOException
{
    try
    {
        if (doAntiCompaction)
        {
            for (InetAddress neighbor : neighbors)
            {
                AnticompactionRequest acr = new AnticompactionRequest(parentSession);
                MessageOut<RepairMessage> req = acr.createMessage();
                MessagingService.instance().sendOneWay(req, neighbor);
            }
            List<Future<?>> futures = doAntiCompaction(parentSession);
            FBUtilities.waitOnFutures(futures);
        }
    }
    finally
    {
        parentRepairSessions.remove(parentSession);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:ActiveRepairService.java

示例5: asyncRemoveFromBatchlog

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public static void asyncRemoveFromBatchlog(Collection<InetAddress> endpoints, UUID uuid)
{
    AbstractWriteResponseHandler<IMutation> handler = new WriteResponseHandler<>(endpoints,
                                                                                 Collections.<InetAddress>emptyList(),
                                                                                 ConsistencyLevel.ANY,
                                                                                 Keyspace.open(SystemKeyspace.NAME),
                                                                                 null,
                                                                                 WriteType.SIMPLE);
    Mutation mutation = getRemoveMutation(uuid);

    for (InetAddress target : endpoints)
    {
        logger.trace("Sending legacy batchlog remove request {} to {}", uuid, target);
        MessagingService.instance().sendRR(mutation.createMessage(MessagingService.Verb.MUTATION), target, handler, false);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:LegacyBatchlogMigrator.java

示例6: doVerb

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public void doVerb(MessageIn<AbstractRangeCommand> message, int id)
{
    try
    {
        if (StorageService.instance.isBootstrapMode())
        {
            /* Don't service reads! */
            throw new RuntimeException("Cannot service reads while bootstrapping!");
        }
        RangeSliceReply reply = new RangeSliceReply(message.payload.executeLocally());
        Tracing.trace("Enqueuing response to {}", message.from);
        MessagingService.instance().sendReply(reply.createMessage(), id, message.from);
    }
    catch (TombstoneOverwhelmingException e)
    {
        // error already logged.  Drop the request
    }
    catch (Exception ex)
    {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:RangeSliceVerbHandler.java

示例7: test

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
@Test
public void test() throws IOException
{
    InetAddress endpoint = InetAddress.getByName("127.0.0.1");
    int generation = 0;
    int maxVersion = 123;
    GossipDigest expected = new GossipDigest(endpoint, generation, maxVersion);
    //make sure we get the same values out
    assertEquals(endpoint, expected.getEndpoint());
    assertEquals(generation, expected.getGeneration());
    assertEquals(maxVersion, expected.getMaxVersion());

    //test the serialization and equals
    DataOutputBuffer output = new DataOutputBuffer();
    GossipDigest.serializer.serialize(expected, output, MessagingService.current_version);

    ByteArrayInputStream input = new ByteArrayInputStream(output.getData(), 0, output.getLength());
    GossipDigest actual = GossipDigest.serializer.deserialize(new DataInputStream(input), MessagingService.current_version);
    assertEquals(0, expected.compareTo(actual));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:GossipDigestTest.java

示例8: maybeTryAdditionalReplicas

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public void maybeTryAdditionalReplicas()
{
    // no latency information, or we're overloaded
    if (cfs.sampleLatencyNanos > TimeUnit.MILLISECONDS.toNanos(command.getTimeout()))
        return;

    if (!handler.await(cfs.sampleLatencyNanos, TimeUnit.NANOSECONDS))
    {
        // Could be waiting on the data, or on enough digests.
        ReadCommand retryCommand = command;
        if (handler.resolver.isDataPresent())
            retryCommand = command.copy().setIsDigestQuery(true);

        InetAddress extraReplica = Iterables.getLast(targetReplicas);
        if (traceState != null)
            traceState.trace("speculating read retry on {}", extraReplica);
        logger.trace("speculating read retry on {}", extraReplica);
        int version = MessagingService.instance().getVersion(extraReplica);
        MessagingService.instance().sendRRWithFailure(retryCommand.createMessage(version), extraReplica, handler);
        speculated = true;

        cfs.metric.speculativeRetries.inc();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:AbstractReadExecutor.java

示例9: sendReplicationNotification

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
/**
 * Sends a notification to a node indicating we have finished replicating data.
 *
 * @param remote node to send notification to
 */
private void sendReplicationNotification(InetAddress remote)
{
    // notify the remote token
    MessageOut msg = new MessageOut(MessagingService.Verb.REPLICATION_FINISHED);
    IFailureDetector failureDetector = FailureDetector.instance;
    if (logger.isDebugEnabled())
        logger.debug("Notifying {} of replication completion\n", remote);
    while (failureDetector.isAlive(remote))
    {
        AsyncOneResponse iar = MessagingService.instance().sendRR(msg, remote);
        try
        {
            iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
            return; // done
        }
        catch(TimeoutException e)
        {
            // try again
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:StorageService.java

示例10: serializedSize

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public long serializedSize(RepairJobDesc desc, int version)
{
    int size = 0;
    if (version >= MessagingService.VERSION_21)
    {
        size += TypeSizes.sizeof(desc.parentSessionId != null);
        if (desc.parentSessionId != null)
            size += UUIDSerializer.serializer.serializedSize(desc.parentSessionId, version);
    }
    size += UUIDSerializer.serializer.serializedSize(desc.sessionId, version);
    size += TypeSizes.sizeof(desc.keyspace);
    size += TypeSizes.sizeof(desc.columnFamily);
    size += TypeSizes.sizeof(desc.ranges.size());
    for (Range<Token> rt : desc.ranges)
    {
        size += AbstractBounds.tokenSerializer.serializedSize(rt, version);
    }
    return size;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:RepairJobDesc.java

示例11: makeRequests

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
private void makeRequests(ReadCommand readCommand, Iterable<InetAddress> endpoints)
{
    MessageOut<ReadCommand> message = null;
    boolean hasLocalEndpoint = false;

    for (InetAddress endpoint : endpoints)
    {
        if (isLocalRequest(endpoint))
        {
            hasLocalEndpoint = true;
            continue;
        }

        logger.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint);
        if (message == null)
            message = readCommand.createMessage();
        MessagingService.instance().sendRR(message, endpoint, handler);
    }

    // We delay the local (potentially blocking) read till the end to avoid stalling remote requests.
    if (hasLocalEndpoint)
    {
        logger.trace("reading {} locally", readCommand.isDigestQuery() ? "digest" : "data");
        StageManager.getStage(Stage.READ).maybeExecuteImmediately(new LocalReadRunnable(command, handler));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:AbstractReadExecutor.java

示例12: maybeTryAdditionalReplicas

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public void maybeTryAdditionalReplicas()
{
    // no latency information, or we're overloaded
    if (cfs.sampleLatencyNanos > TimeUnit.MILLISECONDS.toNanos(command.getTimeout()))
        return;

    if (!handler.await(cfs.sampleLatencyNanos, TimeUnit.NANOSECONDS))
    {
        // Could be waiting on the data, or on enough digests.
        ReadCommand retryCommand = command;
        if (resolver.getData() != null)
            retryCommand = command.copy().setIsDigestQuery(true);

        InetAddress extraReplica = Iterables.getLast(targetReplicas);
        logger.trace("speculating read retry on {}", extraReplica);
        MessagingService.instance().sendRR(retryCommand.createMessage(), extraReplica, handler);
        speculated = true;

        cfs.metric.speculativeRetries.inc();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:AbstractReadExecutor.java

示例13: getTimeout

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
public static long getTimeout(MessagingService.Verb verb)
{
    switch (verb)
    {
        case READ:
            return getReadRpcTimeout();
        case RANGE_SLICE:
        case PAGED_RANGE:
            return getRangeRpcTimeout();
        case TRUNCATE:
            return getTruncateRpcTimeout();
        case READ_REPAIR:
        case MUTATION:
        case PAXOS_COMMIT:
        case PAXOS_PREPARE:
        case PAXOS_PROPOSE:
        case HINT:
        case BATCH_STORE:
        case BATCH_REMOVE:
            return getWriteRpcTimeout();
        case COUNTER_MUTATION:
            return getCounterWriteRpcTimeout();
        default:
            return getRpcTimeout();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:DatabaseDescriptor.java

示例14: testSerializer

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
@Test
public void testSerializer() throws IOException
{
    long now = FBUtilities.timestampMicros();
    Mutation mutation = createMutation("testSerializer", now);
    Hint hint = Hint.create(mutation, now / 1000);

    // serialize
    int serializedSize = (int) Hint.serializer.serializedSize(hint, MessagingService.current_version);
    DataOutputBuffer dob = new DataOutputBuffer();
    Hint.serializer.serialize(hint, dob, MessagingService.current_version);
    assertEquals(serializedSize, dob.getLength());

    // deserialize
    DataInputPlus di = new DataInputBuffer(dob.buffer(), true);
    Hint deserializedHint = Hint.serializer.deserialize(di, MessagingService.current_version);

    // compare before/after
    assertHintsEqual(hint, deserializedHint);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:HintTest.java

示例15: removeEndpoint

import org.apache.cassandra.net.MessagingService; //导入依赖的package包/类
/**
 * Removes the endpoint from Gossip but retains endpoint state
 */
public void removeEndpoint(InetAddress endpoint)
{
    // do subscribers first so anything in the subscriber that depends on gossiper state won't get confused
    for (IEndpointStateChangeSubscriber subscriber : subscribers)
        subscriber.onRemove(endpoint);

    if(seeds.contains(endpoint))
    {
        buildSeedsList();
        seeds.remove(endpoint);
        logger.info("removed {} from seeds, updated seeds list = {}", endpoint, seeds);
    }

    liveEndpoints.remove(endpoint);
    unreachableEndpoints.remove(endpoint);
    // do not remove endpointState until the quarantine expires
    FailureDetector.instance.remove(endpoint);
    MessagingService.instance().resetVersion(endpoint);
    quarantineEndpoint(endpoint);
    MessagingService.instance().destroyConnectionPool(endpoint);
    if (logger.isDebugEnabled())
        logger.debug("removing endpoint {}", endpoint);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:Gossiper.java


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