use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class GossipDigestSynVerbHandler method doVerb.
public void doVerb(Message message, String id) {
InetAddress from = message.getFrom();
if (logger_.isTraceEnabled())
logger_.trace("Received a GossipDigestSynMessage from {}", from);
if (!Gossiper.instance.isEnabled()) {
if (logger_.isTraceEnabled())
logger_.trace("Ignoring GossipDigestSynMessage because gossip is disabled");
return;
}
byte[] bytes = message.getMessageBody();
DataInputStream dis = new DataInputStream(new FastByteArrayInputStream(bytes));
try {
GossipDigestSynMessage gDigestMessage = GossipDigestSynMessage.serializer().deserialize(dis, message.getVersion());
/* If the message is from a different cluster throw it away. */
if (!gDigestMessage.clusterId_.equals(DatabaseDescriptor.getClusterName())) {
logger_.warn("ClusterName mismatch from " + from + " " + gDigestMessage.clusterId_ + "!=" + DatabaseDescriptor.getClusterName());
return;
}
List<GossipDigest> gDigestList = gDigestMessage.getGossipDigests();
if (logger_.isTraceEnabled()) {
StringBuilder sb = new StringBuilder();
for (GossipDigest gDigest : gDigestList) {
sb.append(gDigest);
sb.append(" ");
}
logger_.trace("Gossip syn digests are : " + sb.toString());
}
/* Notify the Failure Detector */
Gossiper.instance.notifyFailureDetector(gDigestList);
doSort(gDigestList);
List<GossipDigest> deltaGossipDigestList = new ArrayList<GossipDigest>();
Map<InetAddress, EndpointState> deltaEpStateMap = new HashMap<InetAddress, EndpointState>();
Gossiper.instance.examineGossiper(gDigestList, deltaGossipDigestList, deltaEpStateMap);
GossipDigestAckMessage gDigestAck = new GossipDigestAckMessage(deltaGossipDigestList, deltaEpStateMap);
Message gDigestAckMessage = Gossiper.instance.makeGossipDigestAckMessage(gDigestAck, message.getVersion());
if (logger_.isTraceEnabled())
logger_.trace("Sending a GossipDigestAckMessage to {}", from);
MessagingService.instance().sendOneWay(gDigestAckMessage, from);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class Gossiper method makeGossipDigestSynMessage.
Message makeGossipDigestSynMessage(List<GossipDigest> gDigests, int version) throws IOException {
GossipDigestSynMessage gDigestMessage = new GossipDigestSynMessage(DatabaseDescriptor.getClusterName(), gDigests);
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
GossipDigestSynMessage.serializer().serialize(gDigestMessage, dos, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.GOSSIP_DIGEST_SYN, bos.toByteArray(), version);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class IndexScanVerbHandler method doVerb.
public void doVerb(Message message, String id) {
try {
IndexScanCommand command = IndexScanCommand.read(message);
ColumnFamilyStore cfs = Table.open(command.keyspace).getColumnFamilyStore(command.column_family);
List<Row> rows = cfs.search(command.index_clause.expressions, command.range, command.index_clause.count, QueryFilter.getFilter(command.predicate, cfs.getComparator()));
RangeSliceReply reply = new RangeSliceReply(rows);
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 MigrationManager method makeMigrationMessage.
// other half of transformation is in DefinitionsUpdateResponseVerbHandler.
private static Message makeMigrationMessage(Collection<IColumn> migrations, int version) throws IOException {
FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);
dout.writeInt(migrations.size());
// problem during upgrades.
for (IColumn col : migrations) {
assert col instanceof Column;
ByteBufferUtil.writeWithLength(col.name(), dout);
ByteBufferUtil.writeWithLength(col.value(), dout);
}
dout.close();
byte[] body = bout.toByteArray();
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.DEFINITIONS_UPDATE, body, version);
}
use of org.apache.cassandra.net.Message 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;
}
Aggregations