use of org.apache.ignite.internal.managers.communication.GridMessageListener 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<>());
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class HadoopShuffle method start.
/**
* {@inheritDoc}
*/
@Override
public void start(HadoopContext ctx) throws IgniteCheckedException {
super.start(ctx);
ctx.kernalContext().io().addMessageListener(GridTopic.TOPIC_HADOOP_MSG, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
onMessageReceived(nodeId, (HadoopMessage) msg);
}
});
ctx.kernalContext().io().addUserMessageListener(GridTopic.TOPIC_HADOOP, new IgniteBiPredicate<UUID, Object>() {
@Override
public boolean apply(UUID nodeId, Object msg) {
return onMessageReceived(nodeId, (HadoopMessage) msg);
}
});
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class GridH2IndexBase method initDistributedJoinMessaging.
/**
* @param tbl Table.
*/
protected final void initDistributedJoinMessaging(GridH2Table tbl) {
final GridH2RowDescriptor desc = tbl.rowDescriptor();
if (desc != null && desc.context() != null) {
ctx = desc.context();
GridKernalContext ctx = desc.context().kernalContext();
log = ctx.log(getClass());
msgTopic = new IgniteBiTuple<>(GridTopic.TOPIC_QUERY, tbl.identifierString() + '.' + getName());
msgLsnr = new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
GridSpinBusyLock l = desc.indexing().busyLock();
if (!l.enterBusy())
return;
try {
onMessage0(nodeId, msg);
} finally {
l.leaveBusy();
}
}
};
ctx.io().addMessageListener(msgTopic, msgLsnr);
} else {
msgTopic = null;
msgLsnr = null;
log = new NullLogger();
}
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class GridMapQueryExecutor method start.
/**
* @param ctx Context.
* @param h2 H2 Indexing.
* @throws IgniteCheckedException If failed.
*/
public void start(final GridKernalContext ctx, IgniteH2Indexing h2) throws IgniteCheckedException {
this.ctx = ctx;
this.h2 = h2;
log = ctx.log(GridMapQueryExecutor.class);
final UUID locNodeId = ctx.localNodeId();
ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override
public void onEvent(final Event evt) {
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
GridH2QueryContext.clearAfterDeadNode(locNodeId, nodeId);
MapNodeResults nodeRess = qryRess.remove(nodeId);
if (nodeRess == null)
return;
nodeRess.cancelAll();
}
}, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_LEFT);
ctx.io().addMessageListener(GridTopic.TOPIC_QUERY, new GridMessageListener() {
@SuppressWarnings("deprecation")
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
if (!busyLock.enterBusy())
return;
try {
if (msg instanceof GridCacheQueryMarshallable)
((GridCacheQueryMarshallable) msg).unmarshall(ctx.config().getMarshaller(), ctx);
GridMapQueryExecutor.this.onMessage(nodeId, msg);
} finally {
busyLock.leaveBusy();
}
}
});
}
use of org.apache.ignite.internal.managers.communication.GridMessageListener in project ignite by apache.
the class GridReduceQueryExecutor method start.
/**
* @param ctx Context.
* @param h2 H2 Indexing.
* @throws IgniteCheckedException If failed.
*/
public void start(final GridKernalContext ctx, final IgniteH2Indexing h2) throws IgniteCheckedException {
this.ctx = ctx;
this.h2 = h2;
log = ctx.log(GridReduceQueryExecutor.class);
ctx.io().addMessageListener(GridTopic.TOPIC_QUERY, new GridMessageListener() {
@SuppressWarnings("deprecation")
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
if (!busyLock.enterBusy())
return;
try {
if (msg instanceof GridCacheQueryMarshallable)
((GridCacheQueryMarshallable) msg).unmarshall(ctx.config().getMarshaller(), ctx);
GridReduceQueryExecutor.this.onMessage(nodeId, msg);
} finally {
busyLock.leaveBusy();
}
}
});
ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override
public void onEvent(final Event evt) {
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
for (ReduceQueryRun r : runs.values()) {
for (GridMergeIndex idx : r.indexes()) {
if (idx.hasSource(nodeId)) {
handleNodeLeft(r, nodeId);
break;
}
}
}
for (DistributedUpdateRun r : updRuns.values()) r.handleNodeLeft(nodeId);
}
}, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_LEFT);
}
Aggregations