use of org.apache.ignite.internal.GridTopic.TOPIC_CLASSLOAD 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());
}
Aggregations