use of org.apache.ignite.internal.managers.communication.GridIoManager in project ignite by apache.
the class ServiceReassignmentFunctionSelfTest method mockServiceProcessor.
/**
* Mocks IgniteServiceProcessor to test method {@link IgniteServiceProcessor#reassign(IgniteUuid,
* ServiceConfiguration, AffinityTopologyVersion, TreeMap)} AffinityTopologyVersion, Map)} )}.
*/
private IgniteServiceProcessor mockServiceProcessor() {
GridTestKernalContext spyCtx = spy(new GridTestKernalContext(new GridTestLog4jLogger()));
GridEventStorageManager mockEvt = mock(GridEventStorageManager.class);
GridIoManager mockIo = mock(GridIoManager.class);
GridSystemViewManager sysViewMgr = mock(GridSystemViewManager.class);
when(spyCtx.event()).thenReturn(mockEvt);
when(spyCtx.io()).thenReturn(mockIo);
when(spyCtx.systemView()).thenReturn(sysViewMgr);
GridDiscoveryManager mockDisco = mock(GridDiscoveryManager.class);
when(mockDisco.nodes(any(AffinityTopologyVersion.class))).thenReturn(new ArrayList<>(nodes));
spyCtx.add(mockDisco);
return new IgniteServiceProcessor(spyCtx);
}
use of org.apache.ignite.internal.managers.communication.GridIoManager in project ignite by apache.
the class GridCacheMessageSelfTest method doSend.
/**
* @throws Exception If failed.
*/
private void doSend() throws Exception {
GridIoManager mgr0 = grid(0).context().io();
GridIoManager mgr1 = grid(1).context().io();
String topic = "test-topic";
final CountDownLatch latch = new CountDownLatch(SAMPLE_CNT);
mgr1.addMessageListener(topic, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
try {
latch.countDown();
Collection<TestMessage1> messages = ((TestMessage) msg).entries();
assertEquals(10, messages.size());
int cnt = 0;
for (TestMessage1 msg1 : messages) {
assertTrue(msg1.body().contains(TEST_BODY));
int i = Integer.parseInt(msg1.body().substring(TEST_BODY.length() + 1));
assertEquals(cnt, i);
TestMessage2 msg2 = (TestMessage2) msg1.message();
assertEquals(TEST_BODY + "_" + i + "_2", msg2.body());
assertEquals(grid(0).localNode().id(), msg2.nodeId());
assertEquals(i, msg2.id());
GridTestMessage msg3 = (GridTestMessage) msg2.message();
assertEquals(cnt, msg3.getMsgId());
assertEquals(grid(1).localNode().id(), msg3.getSourceNodeId());
cnt++;
}
} catch (Exception e) {
fail("Exception " + e.getMessage());
}
}
});
TestMessage msg = new TestMessage();
for (int i = 0; i < 10; i++) {
TestMessage2 mes1 = new TestMessage2();
mes1.init(new GridTestMessage(grid(1).localNode().id(), i, 0), grid(0).localNode().id(), i, TEST_BODY + "_" + i + "_2");
TestMessage1 mes2 = new TestMessage1();
mes2.init(mes1, TEST_BODY + "_" + i);
msg.add(mes2);
}
mgr0.sendToCustomTopic(grid(1).localNode(), topic, msg, GridIoPolicy.PUBLIC_POOL);
assert latch.await(3, SECONDS);
}
Aggregations