Search in sources :

Example 36 with Message

use of org.apache.cassandra.net.Message in project eiger by wlloyd.

the class TruncationSerializer method getMessage.

public Message getMessage(Integer version) throws IOException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    serializer().serialize(this, dos, version);
    return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.TRUNCATE, bos.toByteArray(), version);
}
Also used : FastByteArrayOutputStream(org.apache.cassandra.io.util.FastByteArrayOutputStream) Message(org.apache.cassandra.net.Message)

Example 37 with Message

use of org.apache.cassandra.net.Message in project eiger by wlloyd.

the class RowRepairResolver method resolve.

/*
    * This method handles the following scenario:
    *
    * there was a mismatch on the initial read, so we redid the digest requests
    * as full data reads.  In this case we need to compute the most recent version
    * of each column, and send diffs to out-of-date replicas.
    */
public Row resolve() throws DigestMismatchException, IOException {
    if (logger.isDebugEnabled())
        logger.debug("resolving " + replies.size() + " responses");
    long startTime = System.currentTimeMillis();
    ColumnFamily resolved;
    if (replies.size() > 1) {
        List<ColumnFamily> versions = new ArrayList<ColumnFamily>(replies.size());
        List<InetAddress> endpoints = new ArrayList<InetAddress>(replies.size());
        for (Map.Entry<Message, ReadResponse> entry : replies.entrySet()) {
            Message message = entry.getKey();
            ReadResponse response = entry.getValue();
            ColumnFamily cf = response.row().cf;
            assert !response.isDigestQuery() : "Received digest response to repair read from " + entry.getKey().getFrom();
            versions.add(cf);
            endpoints.add(message.getFrom());
            // compute maxLiveColumns to prevent short reads -- see https://issues.apache.org/jira/browse/CASSANDRA-2643
            int liveColumns = cf == null ? 0 : cf.getLiveColumnCount();
            if (liveColumns > maxLiveColumns)
                maxLiveColumns = liveColumns;
        }
        resolved = resolveSuperset(versions);
        if (logger.isDebugEnabled())
            logger.debug("versions merged");
        // (resolved can be null even if versions doesn't have all nulls because of the call to removeDeleted in resolveSuperSet)
        if (resolved != null)
            repairResults = scheduleRepairs(resolved, table, key, versions, endpoints);
    } else {
        resolved = replies.values().iterator().next().row().cf;
    }
    if (logger.isDebugEnabled())
        logger.debug("resolve: " + (System.currentTimeMillis() - startTime) + " ms.");
    return new Row(key, resolved);
}
Also used : Message(org.apache.cassandra.net.Message) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) Map(java.util.Map)

Example 38 with Message

use of org.apache.cassandra.net.Message in project eiger by wlloyd.

the class ReplicationFinishedVerbHandler method doVerb.

public void doVerb(Message msg, String id) {
    StorageService.instance.confirmReplication(msg.getFrom());
    Message response = msg.getInternalReply(ArrayUtils.EMPTY_BYTE_ARRAY, msg.getVersion());
    if (logger.isDebugEnabled())
        logger.debug("Replying to " + id + "@" + msg.getFrom());
    MessagingService.instance().sendReply(response, id, msg.getFrom());
}
Also used : Message(org.apache.cassandra.net.Message)

Example 39 with Message

use of org.apache.cassandra.net.Message in project eiger by wlloyd.

the class StorageService method sendReplicationNotification.

/**
     * Sends a notification to a node indicating we have finished replicating data.
     *
     * @param local the local address
     * @param remote node to send notification to
     */
private void sendReplicationNotification(InetAddress local, InetAddress remote) {
    // notify the remote token
    Message msg = new Message(local, StorageService.Verb.REPLICATION_FINISHED, new byte[0], Gossiper.instance.getVersion(remote));
    IFailureDetector failureDetector = FailureDetector.instance;
    if (logger_.isDebugEnabled())
        logger_.debug("Notifying " + remote.toString() + " of replication completion\n");
    while (failureDetector.isAlive(remote)) {
        IAsyncResult iar = MessagingService.instance().sendRR(msg, remote);
        try {
            iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
            // done
            return;
        } catch (TimeoutException e) {
        // try again
        }
    }
}
Also used : Message(org.apache.cassandra.net.Message) IAsyncResult(org.apache.cassandra.net.IAsyncResult)

Example 40 with Message

use of org.apache.cassandra.net.Message in project eiger by wlloyd.

the class StreamReply method getMessage.

public Message getMessage(Integer version) throws IOException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    serializer.serialize(this, dos, version);
    return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.STREAM_REPLY, bos.toByteArray(), version);
}
Also used : FastByteArrayOutputStream(org.apache.cassandra.io.util.FastByteArrayOutputStream) Message(org.apache.cassandra.net.Message)

Aggregations

Message (org.apache.cassandra.net.Message)40 IOException (java.io.IOException)9 DataInputStream (java.io.DataInputStream)7 FastByteArrayOutputStream (org.apache.cassandra.io.util.FastByteArrayOutputStream)7 InetAddress (java.net.InetAddress)6 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)6 DataOutputStream (java.io.DataOutputStream)4 IOError (java.io.IOError)3 RangeSliceReply (org.apache.cassandra.db.RangeSliceReply)3 DataOutputBuffer (org.apache.cassandra.io.util.DataOutputBuffer)3 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 TimeoutException (java.util.concurrent.TimeoutException)2 Row (org.apache.cassandra.db.Row)2 IPartitioner (org.apache.cassandra.dht.IPartitioner)2 IAsyncResult (org.apache.cassandra.net.IAsyncResult)2 Test (org.junit.Test)2 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1