use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class AggregatorListTest method testAggregatedObject.
@Test
public void testAggregatedObject() {
int numBuffers = 16;
int size = 1000;
List<Object> data = new ArrayList<>();
for (int i = 0; i < 4; i++) {
data.add("I " + i);
}
Tuple tuple = new Tuple(1, data);
InMessage inMessage = keyedSingleValueCase(numBuffers, size, MessageTypes.OBJECT, MessageTypes.INTEGER, tuple);
Tuple result = (Tuple) inMessage.getDeserializedData();
Assert.assertEquals((int) result.getKey(), 1);
List<Object> resultList = (List<Object>) tuple.getValue();
Assert.assertEquals(resultList, data);
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeDoubleMessage.
@Test
public void testBuildLargeDoubleMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.DOUBLE_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((double[]) inMessage.getDeserializedData(), (double[]) data, .01);
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method singleValueCase.
private InMessage singleValueCase(int numBuffers, int size, MessageType type, Object data) {
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 testBuildLargeIntegerMessage.
@Test
public void testBuildLargeIntegerMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.INTEGER_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((int[]) inMessage.getDeserializedData(), (int[]) data);
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeByteMessage.
@Test
public void testBuildLargeByteMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.BYTE_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((byte[]) inMessage.getDeserializedData(), (byte[]) data);
}
Aggregations