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