Search in sources :

Example 16 with Message

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

the class RangeSliceVerbHandler method doVerb.

public void doVerb(Message message, String id) {
    try {
        if (StorageService.instance.isBootstrapMode()) {
            /* Don't service reads! */
            throw new RuntimeException("Cannot service reads while bootstrapping!");
        }
        RangeSliceCommand command = RangeSliceCommand.read(message);
        ColumnFamilyStore cfs = Table.open(command.keyspace).getColumnFamilyStore(command.column_family);
        RangeSliceReply reply = new RangeSliceReply(executeLocally(command));
        Message response = reply.getReply(message);
        if (logger.isDebugEnabled())
            logger.debug("Sending " + reply + " to " + id + "@" + message.getFrom());
        MessagingService.instance().sendReply(response, id, message.getFrom());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : RangeSliceReply(org.apache.cassandra.db.RangeSliceReply) Message(org.apache.cassandra.net.Message) RangeSliceCommand(org.apache.cassandra.db.RangeSliceCommand) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) ExecutionException(java.util.concurrent.ExecutionException)

Example 17 with Message

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

the class ReadCallback method get.

public T get() throws TimeoutException, DigestMismatchException, IOException {
    long timeout = DatabaseDescriptor.getRpcTimeout() - (System.currentTimeMillis() - startTime);
    boolean success;
    try {
        success = condition.await(timeout, TimeUnit.MILLISECONDS);
    } catch (InterruptedException ex) {
        throw new AssertionError(ex);
    }
    if (!success) {
        StringBuilder sb = new StringBuilder("");
        for (Message message : resolver.getMessages()) sb.append(message.getFrom()).append(", ");
        throw new TimeoutException("Operation timed out - received only " + received.get() + " responses from " + sb.toString() + " .");
    }
    return blockfor == 1 ? resolver.getData() : resolver.resolve();
}
Also used : Message(org.apache.cassandra.net.Message) TimeoutException(java.util.concurrent.TimeoutException)

Example 18 with Message

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

the class RowRepairResolver method scheduleRepairs.

/**
     * For each row version, compare with resolved (the superset of all row versions);
     * if it is missing anything, send a mutation to the endpoint it come from.
     */
public static List<IAsyncResult> scheduleRepairs(ColumnFamily resolved, String table, DecoratedKey<?> key, List<ColumnFamily> versions, List<InetAddress> endpoints) {
    List<IAsyncResult> results = new ArrayList<IAsyncResult>(versions.size());
    for (int i = 0; i < versions.size(); i++) {
        ColumnFamily diffCf = ColumnFamily.diff(versions.get(i), resolved);
        if (// no repair needs to happen
        diffCf == null)
            continue;
        // create and send the row mutation message based on the diff
        RowMutation rowMutation = new RowMutation(table, key.key);
        rowMutation.add(diffCf);
        Message repairMessage;
        try {
            // use a separate verb here because we don't want these to be get the white glove hint-
            // on-timeout behavior that a "real" mutation gets
            repairMessage = rowMutation.getMessage(StorageService.Verb.READ_REPAIR, Gossiper.instance.getVersion(endpoints.get(i)));
        } catch (IOException e) {
            throw new IOError(e);
        }
        results.add(MessagingService.instance().sendRR(repairMessage, endpoints.get(i)));
    }
    return results;
}
Also used : Message(org.apache.cassandra.net.Message) IOError(java.io.IOError) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IAsyncResult(org.apache.cassandra.net.IAsyncResult)

Example 19 with Message

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

the class FileStreamTask method receiveReply.

private void receiveReply() throws IOException {
    MessagingService.validateMagic(input.readInt());
    int msheader = input.readInt();
    assert MessagingService.getBits(msheader, 3, 1) == 0 : "Stream received before stream reply";
    int version = MessagingService.getBits(msheader, 15, 8);
    // Read total size
    input.readInt();
    String id = input.readUTF();
    Header header = Header.serializer().deserialize(input, version);
    int bodySize = input.readInt();
    byte[] body = new byte[bodySize];
    input.readFully(body);
    Message message = new Message(header, body, version);
    assert message.getVerb() == StorageService.Verb.STREAM_REPLY : "Non-reply message received on stream socket";
    handler.doVerb(message, id);
}
Also used : Header(org.apache.cassandra.net.Header) Message(org.apache.cassandra.net.Message)

Example 20 with Message

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

the class StreamIn method requestRanges.

/**
     * Request ranges to be transferred from specific CFs
     */
public static void requestRanges(InetAddress source, String tableName, Collection<ColumnFamilyStore> columnFamilies, Collection<Range<Token>> ranges, Runnable callback, OperationType type) {
    assert ranges.size() > 0;
    if (logger.isDebugEnabled())
        logger.debug("Requesting from {} ranges {}", source, StringUtils.join(ranges, ", "));
    StreamInSession session = StreamInSession.create(source, callback);
    StreamRequestMessage srm = new StreamRequestMessage(FBUtilities.getBroadcastAddress(), ranges, tableName, columnFamilies, session.getSessionId(), type);
    Message message = srm.getMessage(Gossiper.instance.getVersion(source));
    MessagingService.instance().sendOneWay(message, source);
}
Also used : 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