use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class MigrationManager method pushMigrations.
private static void pushMigrations(InetAddress endpoint, Collection<IColumn> migrations) {
try {
Message msg = makeMigrationMessage(migrations, Gossiper.instance.getVersion(endpoint));
MessagingService.instance().sendOneWay(msg, endpoint);
} catch (IOException ex) {
throw new IOError(ex);
}
}
use of org.apache.cassandra.net.Message 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;
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class RowDigestResolver method resolve.
/*
* This method handles two different scenarios:
*
* a) we're handling the initial read, of data from the closest replica + digests
* from the rest. In this case we check the digests against each other,
* throw an exception if there is a mismatch, otherwise return the data row.
*
* b) we're checking additional digests that arrived after the minimum to handle
* the requested ConsistencyLevel, i.e. asynchronous read repair check
*/
public Row resolve() throws DigestMismatchException, IOException {
if (logger.isDebugEnabled())
logger.debug("resolving " + replies.size() + " responses");
long startTime = System.currentTimeMillis();
// validate digests against each other; throw immediately on mismatch.
// also extract the data reply, if any.
ColumnFamily data = null;
ByteBuffer digest = null;
for (Map.Entry<Message, ReadResponse> entry : replies.entrySet()) {
ReadResponse response = entry.getValue();
if (response.isDigestQuery()) {
if (digest == null) {
digest = response.digest();
} else {
ByteBuffer digest2 = response.digest();
if (!digest.equals(digest2))
throw new DigestMismatchException(key, digest, digest2);
}
} else {
data = response.row().cf;
}
}
// that can only happen when we're doing the repair post-mismatch, and will be handled by RowRepairResolver.
if (digest != null) {
ByteBuffer digest2 = ColumnFamily.digest(data);
if (!digest.equals(digest2))
throw new DigestMismatchException(key, digest, digest2);
if (logger.isDebugEnabled())
logger.debug("digests verified");
}
if (logger.isDebugEnabled())
logger.debug("resolve: " + (System.currentTimeMillis() - startTime) + " ms.");
return new Row(key, data);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class Gossiper method makeGossipDigestAck2Message.
Message makeGossipDigestAck2Message(GossipDigestAck2Message gDigestAck2Message, int version) throws IOException {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
GossipDigestAck2Message.serializer().serialize(gDigestAck2Message, dos, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.GOSSIP_DIGEST_ACK2, bos.toByteArray(), version);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class GossipDigestAckVerbHandler method doVerb.
public void doVerb(Message message, String id) {
InetAddress from = message.getFrom();
if (logger_.isTraceEnabled())
logger_.trace("Received a GossipDigestAckMessage from {}", from);
if (!Gossiper.instance.isEnabled()) {
if (logger_.isTraceEnabled())
logger_.trace("Ignoring GossipDigestAckMessage because gossip is disabled");
return;
}
byte[] bytes = message.getMessageBody();
DataInputStream dis = new DataInputStream(new FastByteArrayInputStream(bytes));
try {
GossipDigestAckMessage gDigestAckMessage = GossipDigestAckMessage.serializer().deserialize(dis, message.getVersion());
List<GossipDigest> gDigestList = gDigestAckMessage.getGossipDigestList();
Map<InetAddress, EndpointState> epStateMap = gDigestAckMessage.getEndpointStateMap();
if (epStateMap.size() > 0) {
/* Notify the Failure Detector */
Gossiper.instance.notifyFailureDetector(epStateMap);
Gossiper.instance.applyStateLocally(epStateMap);
}
/* Get the state required to send to this gossipee - construct GossipDigestAck2Message */
Map<InetAddress, EndpointState> deltaEpStateMap = new HashMap<InetAddress, EndpointState>();
for (GossipDigest gDigest : gDigestList) {
InetAddress addr = gDigest.getEndpoint();
EndpointState localEpStatePtr = Gossiper.instance.getStateForVersionBiggerThan(addr, gDigest.getMaxVersion());
if (localEpStatePtr != null)
deltaEpStateMap.put(addr, localEpStatePtr);
}
GossipDigestAck2Message gDigestAck2 = new GossipDigestAck2Message(deltaEpStateMap);
Message gDigestAck2Message = Gossiper.instance.makeGossipDigestAck2Message(gDigestAck2, message.getVersion());
if (logger_.isTraceEnabled())
logger_.trace("Sending a GossipDigestAck2Message to {}", from);
MessagingService.instance().sendOneWay(gDigestAck2Message, from);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations