Search in sources :

Example 26 with Message

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

the class DependencyCheck method getMessage.

@Override
public Message getMessage(Integer version) throws IOException {
    DataOutputBuffer dob = new DataOutputBuffer();
    serializer_.serialize(this, dob, version);
    return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.DEPENDENCY_CHECK, Arrays.copyOf(dob.getData(), dob.getLength()), version);
}
Also used : Message(org.apache.cassandra.net.Message) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer)

Example 27 with Message

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

the class RowMutationVerbHandler method forwardToLocalNodes.

/**
     * Older version (< 1.0) will not send this message at all, hence we don't
     * need to check the version of the data.
     */
private void forwardToLocalNodes(Message message, byte[] forwardBytes) throws IOException {
    DataInputStream dis = new DataInputStream(new FastByteArrayInputStream(forwardBytes));
    int size = dis.readInt();
    // remove fwds from message to avoid infinite loop
    Message messageCopy = message.withHeaderRemoved(RowMutation.FORWARD_HEADER);
    for (int i = 0; i < size; i++) {
        // Send a message to each of the addresses on our Forward List
        InetAddress address = CompactEndpointSerializationHelper.deserialize(dis);
        String id = dis.readUTF();
        if (logger_.isDebugEnabled())
            logger_.debug("Forwarding message to " + address + " with= ID: " + id);
        // Let the response go back to the coordinator
        MessagingService.instance().sendOneWay(messageCopy, id, address);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) Message(org.apache.cassandra.net.Message) DataInputStream(java.io.DataInputStream) InetAddress(java.net.InetAddress)

Example 28 with Message

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

the class RowMutationVerbHandler method applyAndRespond.

protected void applyAndRespond(Message message, String id, RowMutation rm) {
    try {
        assert message != null && id != null && rm != null : message + ", " + id + ", " + rm;
        if (logger_.isDebugEnabled())
            logger_.debug("Applying " + rm);
        rm.apply();
        WriteResponse response = new WriteResponse(rm.getTable(), rm.key(), true);
        Message responseMessage = WriteResponse.makeWriteResponseMessage(message, response);
        if (logger_.isDebugEnabled())
            logger_.debug(rm + " applied.  Sending response to " + id + "@" + message.getFrom());
        MessagingService.instance().sendReply(responseMessage, id, message.getFrom());
    } catch (IOException e) {
        logger_.error("Error in row mutation", e);
    }
}
Also used : Message(org.apache.cassandra.net.Message) IOException(java.io.IOException)

Example 29 with Message

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

the class SchemaCheckVerbHandler method doVerb.

public void doVerb(Message message, String id) {
    logger.debug("Received schema check request.");
    Message response = message.getInternalReply(Schema.instance.getVersion().toString().getBytes(), message.getVersion());
    MessagingService.instance().sendReply(response, id, message.getFrom());
}
Also used : Message(org.apache.cassandra.net.Message)

Example 30 with Message

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

the class ReadRepairVerbHandler method doVerb.

@Override
public void doVerb(Message message, String id) {
    byte[] body = message.getMessageBody();
    FastByteArrayInputStream buffer = new FastByteArrayInputStream(body);
    try {
        RowMutation rm = RowMutation.serializer().deserialize(new DataInputStream(buffer), message.getVersion());
        //WL TODO: Might need to check dependencies here, if we implement on top of quorums
        rm.apply();
        WriteResponse response = new WriteResponse(rm.getTable(), rm.key(), true);
        Message responseMessage = WriteResponse.makeWriteResponseMessage(message, response);
        MessagingService.instance().sendReply(responseMessage, id, message.getFrom());
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : FastByteArrayInputStream(org.apache.cassandra.io.util.FastByteArrayInputStream) Message(org.apache.cassandra.net.Message) IOError(java.io.IOError) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

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