Search in sources :

Example 21 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeByteMessage.

@Test
public void testBuildLargeByteMessage() {
    int numBuffers = 10;
    int size = 1000;
    MessageType type = MessageTypes.BYTE_ARRAY;
    Object data = createKeyedData(800, type, MessageTypes.BYTE_ARRAY);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.BYTE_ARRAY, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertArrayEquals((byte[]) deserializedData.getKey(), (byte[]) ((Tuple) data).getKey());
    Assert.assertArrayEquals((byte[]) deserializedData.getValue(), (byte[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 22 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeIntegerMessage.

@Test
public void testBuildLargeIntegerMessage() {
    int numBuffers = 10;
    int size = 1000;
    MessageType type = MessageTypes.INTEGER_ARRAY;
    Object data = createKeyedData(800, type, MessageTypes.INTEGER);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.INTEGER, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((int) deserializedData.getKey(), (int) ((Tuple) data).getKey());
    Assert.assertArrayEquals((int[]) deserializedData.getValue(), (int[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 23 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildIntegerMessage.

@Test
public void testBuildIntegerMessage() {
    int numBuffers = 4;
    int size = 1000;
    MessageType type = MessageTypes.INTEGER_ARRAY;
    Object data = createKeyedData(80, type, MessageTypes.INTEGER);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.INTEGER, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((int) deserializedData.getKey(), (int) ((Tuple) data).getKey());
    Assert.assertArrayEquals((int[]) deserializedData.getValue(), (int[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 24 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildObjectMessage.

@Test
public void testBuildObjectMessage() {
    int numBuffers = 4;
    int size = 1000;
    MessageType type = MessageTypes.OBJECT;
    Object data = createKeyedData(80, type, MessageTypes.OBJECT);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.OBJECT, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertArrayEquals((byte[]) deserializedData.getKey(), (byte[]) ((Tuple) data).getKey());
    Assert.assertArrayEquals((byte[]) deserializedData.getValue(), (byte[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 25 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeShortMessage.

@Test
public void testBuildLargeShortMessage() {
    int numBuffers = 10;
    int size = 1000;
    MessageType type = MessageTypes.SHORT_ARRAY;
    Object data = createKeyedData(800, type, MessageTypes.SHORT);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.SHORT, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((short) deserializedData.getKey(), (short) ((Tuple) data).getKey());
    Assert.assertArrayEquals((short[]) deserializedData.getValue(), (short[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Aggregations

MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)37 InMessage (edu.iu.dsc.tws.comms.dfw.InMessage)15 ICompute (edu.iu.dsc.tws.api.compute.nodes.ICompute)14 BaseSource (edu.iu.dsc.tws.api.compute.nodes.BaseSource)13 Test (org.junit.Test)13 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)11 ArrayList (java.util.ArrayList)8 List (java.util.List)5 CommunicationContext (edu.iu.dsc.tws.api.comms.CommunicationContext)4 MessageHeader (edu.iu.dsc.tws.api.comms.messaging.MessageHeader)4 JoinedTuple (edu.iu.dsc.tws.api.comms.structs.JoinedTuple)4 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)4 ResettableIterator (edu.iu.dsc.tws.comms.shuffle.ResettableIterator)4 Collections (java.util.Collections)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 Logger (java.util.logging.Logger)4 Op (edu.iu.dsc.tws.api.comms.Op)2 ChannelMessage (edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)2 DataBuffer (edu.iu.dsc.tws.api.comms.packing.DataBuffer)2