use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class AbstractTransactionMessage method getMessage.
@Override
public Message getMessage(Integer version) throws IOException {
DataOutputBuffer dob = new DataOutputBuffer();
serializer().serialize(this, dob, version);
logger.debug("getMessage called on " + this + " serialized into " + dob.getLength());
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.TRANSACTION_MESSAGE, Arrays.copyOf(dob.getData(), dob.getLength()), version);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class TransactionProxy method replicateTransactionToOtherDatacenters.
//WL TODO: Remove the assumption that datacenters have matching keyranges
private static void replicateTransactionToOtherDatacenters(MessageProducer producer, String keyspace, ByteBuffer targetKey) throws IOException {
List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, targetKey);
String localDataCenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress());
IWriteResponseHandler ignoredResponseHandler = WriteResponseHandler.create(endpoints, ConsistencyLevel.ALL, keyspace);
// code follows the structure of StorageProxy.sendToHintedEndpoints
// Multimap that holds onto all the messages and addresses meant for a specific datacenter
Map<String, Multimap<Message, InetAddress>> dcMessages = new HashMap<String, Multimap<Message, InetAddress>>(endpoints.size());
for (InetAddress destination : endpoints) {
assert FailureDetector.instance.isAlive(destination) : "Not dealing with failed nodes in the dc right now";
if (destination.equals(FBUtilities.getBroadcastAddress())) {
//no need to *replicate* to the local machine, it should already have started handling the transaction
continue;
}
if (logger.isDebugEnabled())
logger.debug("replicate transaction to " + destination);
String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(destination);
Multimap<Message, InetAddress> messages = dcMessages.get(dc);
if (messages == null) {
messages = HashMultimap.create();
dcMessages.put(dc, messages);
}
messages.put(producer.getMessage(Gossiper.instance.getVersion(destination)), destination);
}
StorageProxy.sendMessages(localDataCenter, dcMessages, ignoredResponseHandler);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class BootStrapper method getBootstrapTokenFrom.
static Token<?> getBootstrapTokenFrom(InetAddress maxEndpoint) {
Message message = new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.BOOTSTRAP_TOKEN, ArrayUtils.EMPTY_BYTE_ARRAY, Gossiper.instance.getVersion(maxEndpoint));
int retries = 5;
long timeout = Math.max(MessagingService.getDefaultCallbackTimeout(), BOOTSTRAP_TIMEOUT);
while (retries > 0) {
BootstrapTokenCallback btc = new BootstrapTokenCallback();
MessagingService.instance().sendRR(message, maxEndpoint, btc, timeout);
Token token = btc.getToken(timeout);
if (token != null)
return token;
retries--;
}
throw new RuntimeException("Bootstrap failed, could not obtain token from: " + maxEndpoint);
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class AntiEntropyService method respond.
/**
* Responds to the node that requested the given valid tree.
* @param validator A locally generated validator
* @param local localhost (parameterized for testing)
*/
void respond(Validator validator, InetAddress local) {
MessagingService ms = MessagingService.instance();
try {
Message message = TreeResponseVerbHandler.makeVerb(local, validator);
if (!validator.request.endpoint.equals(FBUtilities.getBroadcastAddress()))
logger.info(String.format("[repair #%s] Sending completed merkle tree to %s for %s", validator.request.sessionid, validator.request.endpoint, validator.request.cf));
ms.sendOneWay(message, validator.request.endpoint);
} catch (Exception e) {
logger.error(String.format("[repair #%s] Error sending completed merkle tree to %s for %s ", validator.request.sessionid, validator.request.endpoint, validator.request.cf), e);
}
}
use of org.apache.cassandra.net.Message in project eiger by wlloyd.
the class Gossiper method makeGossipDigestAckMessage.
Message makeGossipDigestAckMessage(GossipDigestAckMessage gDigestAckMessage, int version) throws IOException {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
GossipDigestAckMessage.serializer().serialize(gDigestAckMessage, dos, version);
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.GOSSIP_DIGEST_ACK, bos.toByteArray(), version);
}
Aggregations