use of org.apache.ignite.internal.managers.systemview.walker.ContinuousQueryViewWalker in project ignite by apache.
the class GridContinuousProcessor method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
ctx.systemView().registerView(CQ_SYS_VIEW, CQ_SYS_VIEW_DESC, new ContinuousQueryViewWalker(), new ReadOnlyCollectionView2X<>(rmtInfos.entrySet(), locInfos.entrySet()), e -> new ContinuousQueryView(e.getKey(), e.getValue()));
discoProtoVer = ctx.discovery().mutableCustomMessages() ? 1 : 2;
if (discoProtoVer == 2)
routinesInfo = new ContinuousRoutinesInfo();
if (ctx.config().isDaemon())
return;
retryDelay = ctx.config().getNetworkSendRetryDelay();
retryCnt = ctx.config().getNetworkSendRetryCount();
marsh = ctx.config().getMarshaller();
ctx.event().addLocalEventListener(new DiscoveryListener(), EVT_NODE_LEFT, EVT_NODE_FAILED);
ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override
public void onEvent(Event evt) {
cancelFutures(new IgniteCheckedException("Topology segmented"));
}
}, EVT_NODE_SEGMENTED);
ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessage.class, new CustomEventListener<StartRoutineDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineDiscoveryMessage msg) {
assert discoProtoVer == 1 : discoProtoVer;
if (ctx.isStopping())
return;
processStartRequest(snd, msg);
}
});
ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessageV2.class, new CustomEventListener<StartRoutineDiscoveryMessageV2>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineDiscoveryMessageV2 msg) {
assert discoProtoVer == 2 : discoProtoVer;
if (ctx.isStopping())
return;
processStartRequestV2(topVer, snd, msg);
}
});
ctx.discovery().setCustomEventListener(StartRoutineAckDiscoveryMessage.class, new CustomEventListener<StartRoutineAckDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineAckDiscoveryMessage msg) {
if (ctx.isStopping())
return;
processStartAckRequest(topVer, msg);
}
});
ctx.discovery().setCustomEventListener(StopRoutineDiscoveryMessage.class, new CustomEventListener<StopRoutineDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StopRoutineDiscoveryMessage msg) {
if (discoProtoVer == 2)
routinesInfo.removeRoutine(msg.routineId);
if (ctx.isStopping())
return;
processStopRequest(snd, msg);
}
});
ctx.discovery().setCustomEventListener(StopRoutineAckDiscoveryMessage.class, new CustomEventListener<StopRoutineAckDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StopRoutineAckDiscoveryMessage msg) {
if (ctx.isStopping())
return;
processStopAckRequest(msg);
}
});
ctx.io().addMessageListener(TOPIC_CONTINUOUS, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object obj, byte plc) {
if (obj instanceof ContinuousRoutineStartResultMessage)
processRoutineStartResultMessage(nodeId, (ContinuousRoutineStartResultMessage) obj);
else {
GridContinuousMessage msg = (GridContinuousMessage) obj;
if (msg.data() == null && msg.dataBytes() != null) {
try {
msg.data(U.unmarshal(marsh, msg.dataBytes(), U.resolveClassLoader(ctx.config())));
} catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
return;
}
}
switch(msg.type()) {
case MSG_EVT_NOTIFICATION:
processNotification(nodeId, msg);
break;
case MSG_EVT_ACK:
processMessageAck(msg);
break;
default:
assert false : "Unexpected message received: " + msg.type();
}
}
}
});
ctx.cacheObjects().onContinuousProcessorStarted(ctx);
if (log.isDebugEnabled())
log.debug("Continuous processor started.");
}
use of org.apache.ignite.internal.managers.systemview.walker.ContinuousQueryViewWalker in project gridgain by gridgain.
the class GridContinuousProcessor method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
ctx.systemView().registerView(CQ_SYS_VIEW, CQ_SYS_VIEW_DESC, new ContinuousQueryViewWalker(), new ReadOnlyCollectionView2X<>(rmtInfos.entrySet(), locInfos.entrySet()), e -> new ContinuousQueryView(e.getKey(), e.getValue()));
discoProtoVer = ctx.discovery().mutableCustomMessages() ? 1 : 2;
if (discoProtoVer == 2)
routinesInfo = new ContinuousRoutinesInfo();
if (ctx.config().isDaemon())
return;
retryDelay = ctx.config().getNetworkSendRetryDelay();
retryCnt = ctx.config().getNetworkSendRetryCount();
marsh = ctx.config().getMarshaller();
ctx.event().addLocalEventListener(new DiscoveryListener(), EVT_NODE_LEFT, EVT_NODE_FAILED);
ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override
public void onEvent(Event evt) {
cancelFutures(new IgniteCheckedException("Topology segmented"));
}
}, EVT_NODE_SEGMENTED);
ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessage.class, new CustomEventListener<StartRoutineDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineDiscoveryMessage msg) {
assert discoProtoVer == 1 : discoProtoVer;
if (ctx.isStopping())
return;
processStartRequest(snd, msg);
}
});
ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessageV2.class, new CustomEventListener<StartRoutineDiscoveryMessageV2>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineDiscoveryMessageV2 msg) {
assert discoProtoVer == 2 : discoProtoVer;
if (ctx.isStopping())
return;
processStartRequestV2(topVer, snd, msg);
}
});
ctx.discovery().setCustomEventListener(StartRoutineAckDiscoveryMessage.class, new CustomEventListener<StartRoutineAckDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StartRoutineAckDiscoveryMessage msg) {
if (ctx.isStopping())
return;
processStartAckRequest(topVer, msg);
}
});
ctx.discovery().setCustomEventListener(StopRoutineDiscoveryMessage.class, new CustomEventListener<StopRoutineDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StopRoutineDiscoveryMessage msg) {
if (discoProtoVer == 2)
routinesInfo.removeRoutine(msg.routineId);
if (ctx.isStopping())
return;
processStopRequest(snd, msg);
}
});
ctx.discovery().setCustomEventListener(StopRoutineAckDiscoveryMessage.class, new CustomEventListener<StopRoutineAckDiscoveryMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, StopRoutineAckDiscoveryMessage msg) {
if (ctx.isStopping())
return;
processStopAckRequest(msg);
}
});
ctx.io().addMessageListener(TOPIC_CONTINUOUS, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object obj, byte plc) {
if (obj instanceof ContinuousRoutineStartResultMessage)
processRoutineStartResultMessage(nodeId, (ContinuousRoutineStartResultMessage) obj);
else {
GridContinuousMessage msg = (GridContinuousMessage) obj;
if (msg.data() == null && msg.dataBytes() != null) {
try {
msg.data(U.unmarshal(marsh, msg.dataBytes(), U.resolveClassLoader(ctx.config())));
} catch (IgniteCheckedException e) {
U.error(log, "Failed to process message (ignoring): " + msg, e);
return;
}
}
switch(msg.type()) {
case MSG_EVT_NOTIFICATION:
processNotification(nodeId, msg);
break;
case MSG_EVT_ACK:
processMessageAck(msg);
break;
default:
assert false : "Unexpected message received: " + msg.type();
}
}
}
});
ctx.cacheObjects().onContinuousProcessorStarted(ctx);
if (ctx.service() instanceof GridServiceProcessor)
((GridServiceProcessor) ctx.service()).onContinuousProcessorStarted(ctx);
if (log.isDebugEnabled())
log.debug("Continuous processor started.");
}
Aggregations