Search in sources :

Example 21 with Message

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

the class StreamRequestMessage method getMessage.

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

Example 22 with Message

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

the class SerializationsTest method testRangeSliceCommandRead.

@Test
public void testRangeSliceCommandRead() throws IOException {
    if (EXECUTE_WRITES)
        testRangeSliceCommandWrite();
    DataInputStream in = getInput("db.RangeSliceCommand.bin");
    for (int i = 0; i < 6; i++) {
        Message msg = messageSerializer.deserialize(in, getVersion());
        RangeSliceCommand cmd = RangeSliceCommand.read(msg);
    }
    in.close();
}
Also used : Message(org.apache.cassandra.net.Message) DataInputStream(java.io.DataInputStream) Test(org.junit.Test)

Example 23 with Message

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

the class RemoveTest method testRemoveToken.

@Test
public void testRemoveToken() throws InterruptedException {
    IPartitioner partitioner = StorageService.getPartitioner();
    final String token = partitioner.getTokenFactory().toString(removaltoken);
    ReplicationSink rSink = new ReplicationSink();
    SinkManager.add(rSink);
    // start removal in background and send replication confirmations
    final AtomicBoolean success = new AtomicBoolean(false);
    Thread remover = new Thread() {

        public void run() {
            try {
                ss.removeToken(token);
            } catch (Exception e) {
                System.err.println(e);
                e.printStackTrace();
                return;
            }
            success.set(true);
        }
    };
    remover.start();
    // make sure removal is waiting for confirmation
    Thread.sleep(1000);
    assertTrue(tmd.isLeaving(removalhost));
    assertEquals(1, tmd.getLeavingEndpoints().size());
    for (InetAddress host : hosts) {
        Message msg = new Message(host, StorageService.Verb.REPLICATION_FINISHED, new byte[0], MessagingService.version_);
        MessagingService.instance().sendRR(msg, FBUtilities.getBroadcastAddress());
    }
    remover.join();
    assertTrue(success.get());
    assertTrue(tmd.getLeavingEndpoints().isEmpty());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Message(org.apache.cassandra.net.Message) InetAddress(java.net.InetAddress) IOException(java.io.IOException) ConfigurationException(org.apache.cassandra.config.ConfigurationException) IPartitioner(org.apache.cassandra.dht.IPartitioner) Test(org.junit.Test)

Example 24 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 25 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)

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