use of org.apache.cassandra.io.util.FastByteArrayInputStream in project eiger by wlloyd.
the class MigrationManager method makeColumns.
// other half of this transformation is in MigrationManager.
public static Collection<Column> makeColumns(Message msg) throws IOException {
Collection<Column> cols = new ArrayList<Column>();
DataInputStream in = new DataInputStream(new FastByteArrayInputStream(msg.getMessageBody()));
int count = in.readInt();
for (int i = 0; i < count; i++) {
byte[] name = new byte[in.readInt()];
in.readFully(name);
byte[] value = new byte[in.readInt()];
in.readFully(value);
cols.add(new Column(ByteBuffer.wrap(name), ByteBuffer.wrap(value)));
}
in.close();
return cols;
}
use of org.apache.cassandra.io.util.FastByteArrayInputStream in project eiger by wlloyd.
the class StreamReplyVerbHandler method doVerb.
public void doVerb(Message message, String id) {
byte[] body = message.getMessageBody();
FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
try {
StreamReply reply = StreamReply.serializer.deserialize(new DataInputStream(bufIn), message.getVersion());
logger.debug("Received StreamReply {}", reply);
StreamOutSession session = StreamOutSession.get(message.getFrom(), reply.sessionId);
if (session == null) {
logger.debug("Received stream action " + reply.action + " for an unknown session from " + message.getFrom());
return;
}
switch(reply.action) {
case FILE_FINISHED:
logger.info("Successfully sent {} to {}", reply.file, message.getFrom());
session.validateCurrentFile(reply.file);
session.startNext();
break;
case FILE_RETRY:
session.validateCurrentFile(reply.file);
logger.info("Need to re-stream file {} to {}", reply.file, message.getFrom());
session.retry();
break;
case SESSION_FINISHED:
session.close();
break;
default:
throw new RuntimeException("Cannot handle FileStatus.Action: " + reply.action);
}
} catch (IOException ex) {
throw new IOError(ex);
}
}
use of org.apache.cassandra.io.util.FastByteArrayInputStream in project eiger by wlloyd.
the class StreamRequestVerbHandler method doVerb.
public void doVerb(Message message, String id) {
if (logger.isDebugEnabled())
logger.debug("Received a StreamRequestMessage from {}", message.getFrom());
byte[] body = message.getMessageBody();
FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
try {
StreamRequestMessage srm = StreamRequestMessage.serializer().deserialize(new DataInputStream(bufIn), message.getVersion());
if (logger.isDebugEnabled())
logger.debug(srm.toString());
StreamOutSession session = StreamOutSession.create(srm.table, message.getFrom(), srm.sessionId);
StreamOut.transferRanges(session, srm.columnFamilies, srm.ranges, srm.type);
} catch (IOException ex) {
throw new IOError(ex);
}
}
use of org.apache.cassandra.io.util.FastByteArrayInputStream in project eiger by wlloyd.
the class RowMutationVerbHandler method forwardToLocalNodes.
/**
* Older version (< 1.0) will not send this message at all, hence we don't
* need to check the version of the data.
*/
private void forwardToLocalNodes(Message message, byte[] forwardBytes) throws IOException {
DataInputStream dis = new DataInputStream(new FastByteArrayInputStream(forwardBytes));
int size = dis.readInt();
// remove fwds from message to avoid infinite loop
Message messageCopy = message.withHeaderRemoved(RowMutation.FORWARD_HEADER);
for (int i = 0; i < size; i++) {
// Send a message to each of the addresses on our Forward List
InetAddress address = CompactEndpointSerializationHelper.deserialize(dis);
String id = dis.readUTF();
if (logger_.isDebugEnabled())
logger_.debug("Forwarding message to " + address + " with= ID: " + id);
// Let the response go back to the coordinator
MessagingService.instance().sendOneWay(messageCopy, id, address);
}
}
use of org.apache.cassandra.io.util.FastByteArrayInputStream in project eiger by wlloyd.
the class RangeSliceCommandSerializer method read.
public static RangeSliceCommand read(Message message) throws IOException {
byte[] bytes = message.getMessageBody();
FastByteArrayInputStream bis = new FastByteArrayInputStream(bytes);
return serializer.deserialize(new DataInputStream(bis), message.getVersion());
}
Aggregations