use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class DeploymentRequestOfUnknownClassProcessingTest method testResponseReceivingOnDeploymentRequestOfUnknownClass.
/**
* @throws Exception If failed.
*/
@Test
public void testResponseReceivingOnDeploymentRequestOfUnknownClass() throws Exception {
IgniteEx locNode = grid(0);
IgniteEx remNode = grid(1);
// Register deployment on remote node for attemt to load class on request receiving
GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) });
Class task = ldr.loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1");
GridDeployment locDep = remNode.context().deploy().deploy(task, task.getClassLoader());
final GridFutureAdapter<Void> testResultFut = new GridFutureAdapter<>();
final LogListener remNodeLogLsnr = LogListener.matches(s -> s.matches("Failed to resolve class.*?" + UNKNOWN_CLASS_NAME + ".*")).build();
remNodeLog.registerListener(remNodeLogLsnr);
locNode.context().io().addMessageListener(TEST_TOPIC_NAME, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
try {
assertTrue(msg instanceof GridDeploymentResponse);
GridDeploymentResponse resp = (GridDeploymentResponse) msg;
assertFalse("Unexpected response result, success=" + resp.success(), resp.success());
String errMsg = resp.errorMessage();
assertNotNull("Response should contain an error message.", errMsg);
assertTrue("Response contains unexpected error message, errorMessage=" + errMsg, errMsg.matches("Requested resource not found \\(ignoring locally\\).*?" + UNKNOWN_CLASS_NAME + ".*"));
testResultFut.onDone();
} catch (Error e) {
testResultFut.onDone(e);
}
}
});
GridDeploymentRequest req = new GridDeploymentRequest(TEST_TOPIC_NAME, locDep.classLoaderId(), UNKNOWN_CLASS_NAME, false);
req.responseTopicBytes(U.marshal(locNode.context(), req.responseTopic()));
locNode.context().io().sendToGridTopic(remNode.localNode(), TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);
// Сhecks that the expected response has been received.
testResultFut.get(5_000, TimeUnit.MILLISECONDS);
// Checks that error has been logged on remote node.
assertTrue(remNodeLogLsnr.check());
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class IgniteMarshallerCacheClientRequestsMappingOnMissTest method replaceWithStoppingMappingRequestListener.
/**
*/
private void replaceWithStoppingMappingRequestListener(GridIoManager ioMgr, final int nodeIdToStop, final CountDownLatch latch) {
ioMgr.removeMessageListener(GridTopic.TOPIC_MAPPING_MARSH);
ioMgr.addMessageListener(GridTopic.TOPIC_MAPPING_MARSH, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
new Thread(new Runnable() {
@Override
public void run() {
mappingReqsCounter.incrementAndGet();
latch.countDown();
stopGrid(nodeIdToStop, true);
}
}).start();
}
});
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class IgniteMarshallerCacheClientRequestsMappingOnMissTest method replaceWithCountingMappingRequestListener.
/**
*/
private void replaceWithCountingMappingRequestListener(GridIoManager ioMgr) {
GridMessageListener[] lsnrs = U.field(ioMgr, "sysLsnrs");
final GridMessageListener delegate = lsnrs[GridTopic.TOPIC_MAPPING_MARSH.ordinal()];
GridMessageListener wrapper = new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
mappingReqsCounter.incrementAndGet();
delegate.onMessage(nodeId, msg, plc);
}
};
lsnrs[GridTopic.TOPIC_MAPPING_MARSH.ordinal()] = wrapper;
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class GridCacheBinaryObjectMetadataExchangeMultinodeTest method replaceWithStoppingMappingRequestListener.
/**
*/
private void replaceWithStoppingMappingRequestListener(GridIoManager ioMgr, final int nodeIdToStop) {
ioMgr.removeMessageListener(GridTopic.TOPIC_METADATA_REQ);
ioMgr.addMessageListener(GridTopic.TOPIC_METADATA_REQ, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
new Thread(new Runnable() {
@Override
public void run() {
metadataReqsCounter.incrementAndGet();
stopGrid(nodeIdToStop, true);
}
}).start();
}
});
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class GridCacheBinaryObjectMetadataExchangeMultinodeTest method replaceWithCountingMappingRequestListener.
/**
*/
private void replaceWithCountingMappingRequestListener(GridIoManager ioMgr) {
GridMessageListener[] lsnrs = U.field(ioMgr, "sysLsnrs");
final GridMessageListener delegate = lsnrs[GridTopic.TOPIC_METADATA_REQ.ordinal()];
GridMessageListener wrapper = new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
metadataReqsCounter.incrementAndGet();
delegate.onMessage(nodeId, msg, plc);
}
};
lsnrs[GridTopic.TOPIC_METADATA_REQ.ordinal()] = wrapper;
}
Aggregations