use of org.jgroups.util.ByteArrayDataInputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testCompressedLongSequence.
public void testCompressedLongSequence() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
long[] numbers = { 0, 1, 100, 322649, Long.MAX_VALUE - 1000 };
for (long i : numbers) Bits.writeLongSequence(i, i + 100, out);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (long i : numbers) {
long[] seq = { 0, 0 };
Bits.readLongSequence(in, seq, 0);
assert Arrays.equals(seq, new long[] { i, i + 100 });
}
}
use of org.jgroups.util.ByteArrayDataInputStream in project JGroups by belaban.
the class RouterStub method receive.
@Override
public void receive(Address sender, byte[] buf, int offset, int length) {
ByteArrayDataInputStream in = new ByteArrayDataInputStream(buf, offset, length);
GossipData data = new GossipData();
try {
data.readFrom(in);
switch(data.getType()) {
case MESSAGE:
case SUSPECT:
if (receiver != null)
receiver.receive(data);
break;
case GET_MBRS_RSP:
notifyResponse(data.getGroup(), data.getPingData());
break;
}
} catch (Exception ex) {
log.error(Util.getMessage("FailedReadingData"), ex);
}
}
Aggregations