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);
}
}
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();
}
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;
}
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);
}
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);
}
Aggregations