Search in sources :

Example 1 with RangeSliceReply

use of org.apache.cassandra.db.RangeSliceReply in project eiger by wlloyd.

the class RangeSliceResponseResolver method resolve.

// Note: this would deserialize the response a 2nd time if getData was called first.
// (this is not currently an issue since we don't do read repair for range queries.)
public Iterable<Row> resolve() throws IOException {
    ArrayList<RowIterator> iters = new ArrayList<RowIterator>(responses.size());
    int n = 0;
    for (Message response : responses) {
        RangeSliceReply reply = RangeSliceReply.read(response.getMessageBody(), response.getVersion());
        n = Math.max(n, reply.rows.size());
        iters.add(new RowIterator(reply.rows.iterator(), response.getFrom()));
    }
    // for each row, compute the combination of all different versions seen, and repair incomplete versions
    // TODO do we need to call close?
    CloseableIterator<Row> iter = MergeIterator.get(iters, pairComparator, new Reducer());
    List<Row> resolvedRows = new ArrayList<Row>(n);
    while (iter.hasNext()) resolvedRows.add(iter.next());
    return resolvedRows;
}
Also used : Message(org.apache.cassandra.net.Message) RangeSliceReply(org.apache.cassandra.db.RangeSliceReply) Row(org.apache.cassandra.db.Row)

Example 2 with RangeSliceReply

use of org.apache.cassandra.db.RangeSliceReply 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 3 with RangeSliceReply

use of org.apache.cassandra.db.RangeSliceReply in project eiger by wlloyd.

the class RangeSliceResponseResolver method getData.

public List<Row> getData() throws IOException {
    Message response = responses.iterator().next();
    RangeSliceReply reply = RangeSliceReply.read(response.getMessageBody(), response.getVersion());
    return reply.rows;
}
Also used : Message(org.apache.cassandra.net.Message) RangeSliceReply(org.apache.cassandra.db.RangeSliceReply)

Aggregations

RangeSliceReply (org.apache.cassandra.db.RangeSliceReply)3 Message (org.apache.cassandra.net.Message)3 ExecutionException (java.util.concurrent.ExecutionException)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 RangeSliceCommand (org.apache.cassandra.db.RangeSliceCommand)1 Row (org.apache.cassandra.db.Row)1