use of org.apache.cassandra.io.util.FastByteArrayOutputStream 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);
}
use of org.apache.cassandra.io.util.FastByteArrayOutputStream 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.io.util.FastByteArrayOutputStream 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.io.util.FastByteArrayOutputStream in project eiger by wlloyd.
the class StorageProxy method sendMessages.
/**
* for each datacenter, send a message to one node to relay the write to other replicas
*/
public static void sendMessages(String localDataCenter, Map<String, Multimap<Message, InetAddress>> dcMessages, IWriteResponseHandler handler) throws IOException {
for (Map.Entry<String, Multimap<Message, InetAddress>> entry : dcMessages.entrySet()) {
String dataCenter = entry.getKey();
// send the messages corresponding to this datacenter
for (Map.Entry<Message, Collection<InetAddress>> messages : entry.getValue().asMap().entrySet()) {
Message message = messages.getKey();
// a single message object is used for unhinted writes, so clean out any forwards
// from previous loop iterations
message = message.withHeaderRemoved(RowMutation.FORWARD_HEADER);
Iterator<InetAddress> iter = messages.getValue().iterator();
InetAddress target = iter.next();
// direct writes to local DC or old Cassadra versions
if (dataCenter.equals(localDataCenter) || Gossiper.instance.getVersion(target) < MessagingService.VERSION_11) {
// yes, the loop and non-loop code here are the same; this is clunky but we want to avoid
// creating a second iterator since we already have a perfectly good one
MessagingService.instance().sendRR(message, target, handler);
while (iter.hasNext()) {
target = iter.next();
MessagingService.instance().sendRR(message, target, handler);
}
continue;
}
// Add all the other destinations of the same message as a FORWARD_HEADER entry
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeInt(messages.getValue().size() - 1);
while (iter.hasNext()) {
InetAddress destination = iter.next();
CompactEndpointSerializationHelper.serialize(destination, dos);
String id = MessagingService.instance().addCallback(handler, message, destination);
dos.writeUTF(id);
if (logger.isDebugEnabled())
logger.debug("Adding FWD message to: " + destination + " with ID " + id);
}
message = message.withHeaderAdded(RowMutation.FORWARD_HEADER, bos.toByteArray());
// send the combined message + forward headers
String id = MessagingService.instance().sendRR(message, target, handler);
if (logger.isDebugEnabled())
logger.debug("Sending message to: " + target + " with ID " + id);
}
}
}
use of org.apache.cassandra.io.util.FastByteArrayOutputStream in project eiger by wlloyd.
the class StreamRequestMessage method getMessage.
public Message getMessage(Integer version) {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
StreamRequestMessage.serializer().serialize(this, dos, version);
} catch (IOException e) {
throw new IOError(e);
}
return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.STREAM_REQUEST, bos.toByteArray(), version);
}
Aggregations