use of org.apache.ignite.events.NodeValidationFailedEvent in project ignite by apache.
the class IgniteNodeValidationFailedEventTest method testNodeValidationFailedEvent.
/**
*/
@Test
public void testNodeValidationFailedEvent() throws Exception {
startGrid(0);
CountDownLatch evtLatch = new CountDownLatch(1);
AtomicReference<Event> listenedEvtRef = new AtomicReference<>();
grid(0).events().localListen(evt -> {
assertTrue(listenedEvtRef.compareAndSet(null, evt));
evtLatch.countDown();
return true;
}, EVT_NODE_VALIDATION_FAILED);
startGrid(1);
String invalidNodeName = getTestIgniteInstanceName(2);
IgniteConfiguration invalidCfg = getConfiguration(invalidNodeName).setPluginProviders(new TestSecurityPluginProvider("login", "", ALLOW_ALL, false));
assertThrowsWithCause(() -> startGrid(optimize(invalidCfg)), IgniteSpiException.class);
evtLatch.await();
Event listenedEvt = listenedEvtRef.get();
assertTrue(listenedEvt instanceof NodeValidationFailedEvent);
NodeValidationFailedEvent validationEvt = (NodeValidationFailedEvent) listenedEvt;
assertEquals(invalidNodeName, validationEvt.eventNode().attribute(ATTR_NODE_CONSISTENT_ID));
IgniteNodeValidationResult validationRes = validationEvt.validationResult();
assertNotNull(validationRes);
String errMsg = validationRes.message();
assertNotNull(errMsg);
assertTrue(errMsg.contains("Local node's grid security processor class is not equal to remote node's grid security processor class"));
}
use of org.apache.ignite.events.NodeValidationFailedEvent in project ignite by apache.
the class ZookeeperDiscoveryImpl method validateJoiningNode.
/**
* @param joiningNodeData Joining node data.
* @return Validation result.
*/
private ZkNodeValidateResult validateJoiningNode(ZkJoiningNodeData joiningNodeData) {
ZookeeperClusterNode node = joiningNodeData.node();
ZookeeperClusterNode node0 = rtState.top.nodesById.get(node.id());
if (node0 != null) {
U.error(log, "Failed to include node in cluster, node with the same ID already exists [joiningNode=" + node + ", existingNode=" + node0 + ']');
// Note: exception message is checked in tests.
return new ZkNodeValidateResult("Node with the same ID already exists: " + node0);
}
ZkNodeValidateResult res = authenticateNode(node);
if (res.err != null)
return res;
IgniteNodeValidationResult err = spi.getSpiContext().validateNode(node);
if (err == null) {
DiscoveryDataBag joiningNodeBag = new DiscoveryDataBag(node.id(), joiningNodeData.node().isClient());
joiningNodeBag.joiningNodeData(joiningNodeData.discoveryData());
err = spi.getSpiContext().validateNode(node, joiningNodeBag);
}
if (err != null) {
spi.getSpiContext().recordEvent(new NodeValidationFailedEvent(locNode, node, err));
LT.warn(log, err.message());
res.err = err.sendMessage();
}
return res;
}
Aggregations