use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeListDoubleMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListDoubleMessage() {
int numBuffers = 32;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createData(800, MessageTypes.DOUBLE_ARRAY);
data.add(o);
}
InMessage inMessage = listValueCase(numBuffers, size, data, MessageTypes.DOUBLE_ARRAY);
List<Object> result = (List<Object>) inMessage.getDeserializedData();
for (int i = 0; i < result.size(); i++) {
Object exp = result.get(i);
Object d = data.get(i);
Assert.assertArrayEquals((double[]) exp, (double[]) d, 0.01);
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method listValueCase.
private InMessage listValueCase(int numBuffers, int size, List<Object> data, MessageType type) {
BlockingQueue<DataBuffer> bufferQueue = createDataQueue(numBuffers, size);
OutMessage outMessage = new OutMessage(0, 1, -1, 10, 0, null, null, type, null, null, data);
DataSerializer serializer = new DataSerializer();
serializer.init(Config.newBuilder().build(), bufferQueue);
List<ChannelMessage> messages = new ArrayList<>();
while (outMessage.getSendState() != OutMessage.SendState.SERIALIZED) {
ChannelMessage ch = serializer.build(data, outMessage);
messages.add(ch);
}
DataDeserializer deserializer = new DataDeserializer();
deserializer.init(Config.newBuilder().build());
MessageHeader header = deserializer.buildHeader(messages.get(0).getBuffers().get(0), 1);
InMessage inMessage = new InMessage(0, type, null, header);
for (ChannelMessage channelMessage : messages) {
for (DataBuffer dataBuffer : channelMessage.getBuffers()) {
inMessage.addBufferAndCalculate(dataBuffer);
}
}
deserializer.build(inMessage, 1);
return inMessage;
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeLongMessage.
@Test
public void testBuildLargeLongMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.LONG_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((long[]) inMessage.getDeserializedData(), (long[]) data);
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeListLongMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListLongMessage() {
int numBuffers = 32;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createData(800, MessageTypes.LONG_ARRAY);
data.add(o);
}
InMessage inMessage = listValueCase(numBuffers, size, data, MessageTypes.LONG_ARRAY);
List<Object> result = (List<Object>) inMessage.getDeserializedData();
for (int i = 0; i < result.size(); i++) {
Object exp = result.get(i);
Object d = data.get(i);
Assert.assertArrayEquals((long[]) exp, (long[]) d);
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeObjectMessage.
@Test
public void testBuildLargeObjectMessage() {
int numBuffers = 20;
int size = 1000;
MessageType type = MessageTypes.OBJECT;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((int[]) inMessage.getDeserializedData(), (int[]) data);
}
Aggregations