use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class TruncationSerializer method getMessage.
public Message getMessage(Integer version) throws IOException {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
serializer().serialize(this, dos, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.TRUNCATE, bos.toByteArray(), version);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class RowRepairResolver method resolve.
/*
* This method handles the following scenario:
*
* there was a mismatch on the initial read, so we redid the digest requests
* as full data reads. In this case we need to compute the most recent version
* of each column, and send diffs to out-of-date replicas.
*/
public Row resolve() throws DigestMismatchException, IOException {
if (logger.isDebugEnabled())
logger.debug("resolving " + replies.size() + " responses");
long startTime = System.currentTimeMillis();
ColumnFamily resolved;
if (replies.size() > 1) {
List<ColumnFamily> versions = new ArrayList<ColumnFamily>(replies.size());
List<InetAddress> endpoints = new ArrayList<InetAddress>(replies.size());
for (Map.Entry<Message, ReadResponse> entry : replies.entrySet()) {
Message message = entry.getKey();
ReadResponse response = entry.getValue();
ColumnFamily cf = response.row().cf;
assert !response.isDigestQuery() : "Received digest response to repair read from " + entry.getKey().getFrom();
versions.add(cf);
endpoints.add(message.getFrom());
// compute maxLiveColumns to prevent short reads -- see https://issues.apache.org/jira/browse/CASSANDRA-2643
int liveColumns = cf == null ? 0 : cf.getLiveColumnCount();
if (liveColumns > maxLiveColumns)
maxLiveColumns = liveColumns;
}
resolved = resolveSuperset(versions);
if (logger.isDebugEnabled())
logger.debug("versions merged");
// (resolved can be null even if versions doesn't have all nulls because of the call to removeDeleted in resolveSuperSet)
if (resolved != null)
repairResults = scheduleRepairs(resolved, table, key, versions, endpoints);
} else {
resolved = replies.values().iterator().next().row().cf;
}
if (logger.isDebugEnabled())
logger.debug("resolve: " + (System.currentTimeMillis() - startTime) + " ms.");
return new Row(key, resolved);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class ReplicationFinishedVerbHandler method doVerb.
public void doVerb(Message msg, String id) {
StorageService.instance.confirmReplication(msg.getFrom());
Message response = msg.getInternalReply(ArrayUtils.EMPTY_BYTE_ARRAY, msg.getVersion());
if (logger.isDebugEnabled())
logger.debug("Replying to " + id + "@" + msg.getFrom());
MessagingService.instance().sendReply(response, id, msg.getFrom());
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class StorageService method sendReplicationNotification.
/**
* Sends a notification to a node indicating we have finished replicating data.
*
* @param local the local address
* @param remote node to send notification to
*/
private void sendReplicationNotification(InetAddress local, InetAddress remote) {
// notify the remote token
Message msg = new Message(local, StorageService.Verb.REPLICATION_FINISHED, new byte[0], Gossiper.instance.getVersion(remote));
IFailureDetector failureDetector = FailureDetector.instance;
if (logger_.isDebugEnabled())
logger_.debug("Notifying " + remote.toString() + " of replication completion\n");
while (failureDetector.isAlive(remote)) {
IAsyncResult iar = MessagingService.instance().sendRR(msg, remote);
try {
iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
// done
return;
} catch (TimeoutException e) {
// try again
}
}
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class StreamReply method getMessage.
public Message getMessage(Integer version) throws IOException {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
serializer.serialize(this, dos, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.STREAM_REPLY, bos.toByteArray(), version);
}
Aggregations