use of org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener in project ignite by apache.
the class IgniteAuthenticationProcessor method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
super.start();
if (isEnabled && !GridCacheUtils.isPersistenceEnabled(ctx.config())) {
isEnabled = false;
throw new IgniteCheckedException("Authentication can be enabled only for cluster with enabled persistence." + " Check the DataRegionConfiguration");
}
ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_AUTHENTICATION_ENABLED, isEnabled);
GridDiscoveryManager discoMgr = ctx.discovery();
GridIoManager ioMgr = ctx.io();
discoMgr.setCustomEventListener(UserProposedMessage.class, new UserProposedListener());
discoMgr.setCustomEventListener(UserAcceptedMessage.class, new UserAcceptedListener());
discoLsnr = new DiscoveryEventListener() {
@Override
public void onEvent(DiscoveryEvent evt, DiscoCache discoCache) {
if (!isEnabled || ctx.isStopping())
return;
switch(evt.type()) {
case EVT_NODE_LEFT:
case EVT_NODE_FAILED:
onNodeLeft(evt.eventNode().id());
break;
case EVT_NODE_JOINED:
onNodeJoin(evt.eventNode());
break;
}
}
};
ctx.event().addDiscoveryEventListener(discoLsnr, DISCO_EVT_TYPES);
ioLsnr = new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
if (!isEnabled || ctx.isStopping())
return;
if (msg instanceof UserManagementOperationFinishedMessage)
onFinishMessage(nodeId, (UserManagementOperationFinishedMessage) msg);
else if (msg instanceof UserAuthenticateRequestMessage)
onAuthenticateRequestMessage(nodeId, (UserAuthenticateRequestMessage) msg);
else if (msg instanceof UserAuthenticateResponseMessage)
onAuthenticateResponseMessage((UserAuthenticateResponseMessage) msg);
}
};
ioMgr.addMessageListener(GridTopic.TOPIC_AUTH, ioLsnr);
exec = new IgniteThreadPoolExecutor("auth", ctx.config().getIgniteInstanceName(), 1, 1, 0, new LinkedBlockingQueue<>());
}
Aggregations