use of org.apache.ignite.events.EventType.EVT_NODE_FAILED in project ignite by apache.
the class IgniteProjectionStartStopRestartSelfTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() {
if (SSH_KEY != null) {
key = new File(SSH_KEY);
assert key.exists() : "Private key doesn't exist: " + key.getAbsolutePath();
assert key.isFile() : "Private key is not a file: " + key.getAbsolutePath();
} else
pwd = SSH_PWD;
log.info("Username: " + SSH_UNAME);
log.info("Password: " + pwd);
log.info("Key path: " + key);
G.setDaemon(true);
ignite = G.start(CFG_NO_ATTR);
G.setDaemon(false);
ignite.events().localListen((IgnitePredicate<Event>) evt -> {
info("Received event: " + evt.shortDisplay());
if (evt.type() == EVT_NODE_JOINED) {
joinedCnt.incrementAndGet();
if (joinedLatch != null)
joinedLatch.countDown();
} else if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) {
leftCnt.incrementAndGet();
if (leftLatch != null)
leftLatch.countDown();
}
return true;
}, EVT_NODE_JOINED, EVT_NODE_LEFT, EVT_NODE_FAILED);
}
use of org.apache.ignite.events.EventType.EVT_NODE_FAILED in project ignite by apache.
the class IgniteSnapshotManager method start0.
/**
* {@inheritDoc}
*/
@Override
protected void start0() throws IgniteCheckedException {
super.start0();
GridKernalContext ctx = cctx.kernalContext();
if (ctx.clientNode())
return;
if (!CU.isPersistenceEnabled(ctx.config()))
return;
assert cctx.pageStore() instanceof FilePageStoreManager;
storeMgr = (FilePageStoreManager) cctx.pageStore();
pdsSettings = cctx.kernalContext().pdsFolderResolver().resolveFolders();
locSnpDir = resolveSnapshotWorkDirectory(ctx.config());
tmpWorkDir = U.resolveWorkDirectory(storeMgr.workDir().getAbsolutePath(), DFLT_SNAPSHOT_TMP_DIR, true);
U.ensureDirectory(locSnpDir, "snapshot work directory", log);
U.ensureDirectory(tmpWorkDir, "temp directory for snapshot creation", log);
handlers.initialize(ctx, ctx.pools().getSnapshotExecutorService());
MetricRegistry mreg = cctx.kernalContext().metric().registry(SNAPSHOT_METRICS);
mreg.register("LastSnapshotStartTime", () -> lastSeenSnpFut.startTime, "The system time of the last cluster snapshot request start time on this node.");
mreg.register("LastSnapshotEndTime", () -> lastSeenSnpFut.endTime, "The system time of the last cluster snapshot request end time on this node.");
mreg.register("LastSnapshotName", () -> lastSeenSnpFut.name, String.class, "The name of last started cluster snapshot request on this node.");
mreg.register("LastSnapshotErrorMessage", () -> lastSeenSnpFut.error() == null ? "" : lastSeenSnpFut.error().getMessage(), String.class, "The error message of last started cluster snapshot request which fail with an error. " + "This value will be empty if last snapshot request has been completed successfully.");
mreg.register("LocalSnapshotNames", this::localSnapshotNames, List.class, "The list of names of all snapshots currently saved on the local node with respect to " + "the configured via IgniteConfiguration snapshot working path.");
restoreCacheGrpProc.registerMetrics();
cctx.exchange().registerExchangeAwareComponent(this);
ctx.internalSubscriptionProcessor().registerMetastorageListener(this);
cctx.gridEvents().addDiscoveryEventListener(discoLsnr = (evt, discoCache) -> {
if (!busyLock.enterBusy())
return;
try {
UUID leftNodeId = evt.eventNode().id();
if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) {
SnapshotOperationRequest snpReq = clusterSnpReq;
String err = "Snapshot operation interrupted, because baseline node left the cluster: " + leftNodeId;
boolean reqNodeLeft = snpReq != null && snpReq.nodes().contains(leftNodeId);
// the final snapshot phase (SNAPSHOT_END), we start it from a new one.
if (reqNodeLeft && snpReq.startStageEnded() && U.isLocalNodeCoordinator(ctx.discovery())) {
snpReq.error(new ClusterTopologyCheckedException(err));
endSnpProc.start(snpReq.requestId(), snpReq);
}
for (AbstractSnapshotFutureTask<?> sctx : locSnpTasks.values()) {
if (sctx.sourceNodeId().equals(leftNodeId) || (reqNodeLeft && snpReq.snapshotName().equals(sctx.snapshotName())))
sctx.acceptException(new ClusterTopologyCheckedException(err));
}
restoreCacheGrpProc.onNodeLeft(leftNodeId);
snpRmtMgr.onNodeLeft(leftNodeId);
}
} finally {
busyLock.leaveBusy();
}
}, EVT_NODE_LEFT, EVT_NODE_FAILED);
cctx.gridIO().addMessageListener(DFLT_INITIAL_SNAPSHOT_TOPIC, snpRmtMgr);
cctx.kernalContext().io().addTransmissionHandler(DFLT_INITIAL_SNAPSHOT_TOPIC, snpRmtMgr);
ctx.systemView().registerView(SNAPSHOT_SYS_VIEW, SNAPSHOT_SYS_VIEW_DESC, new SnapshotViewWalker(), () -> F.flatCollections(F.transform(localSnapshotNames(), this::readSnapshotMetadatas)), this::snapshotViewSupplier);
}
use of org.apache.ignite.events.EventType.EVT_NODE_FAILED in project ignite by apache.
the class DistributedProcessCoordinatorLeftTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setLocalEventListeners(Collections.singletonMap(event -> {
nodeLeftLatch.countDown();
try {
msgSendLatch.await();
} catch (InterruptedException e) {
fail("Unexpected interrupt.");
}
return false;
}, new int[] { EVT_NODE_LEFT, EVT_NODE_FAILED }));
cfg.setFailureHandler(new FailureHandler() {
@Override
public boolean onFailure(Ignite ignite, FailureContext failureCtx) {
failure.set(true);
return false;
}
});
return cfg;
}
use of org.apache.ignite.events.EventType.EVT_NODE_FAILED in project ignite by apache.
the class TcpDiscoverySelfTest method checkFailedCoordinatorNode.
/**
* @param segPlc Segmentation policy.
* @throws Exception If failed.
*/
private void checkFailedCoordinatorNode(SegmentationPolicy segPlc) throws Exception {
try {
this.segPlc = segPlc;
IgniteEx coord = (IgniteEx) startGridsMultiThreaded(3);
UUID coordId = coord.localNode().id();
IgniteEx ignite1 = grid(1);
AtomicBoolean coordSegmented = new AtomicBoolean();
coord.events().localListen(evt -> {
assertEquals(EVT_NODE_SEGMENTED, evt.type());
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
if (coordId.equals(nodeId))
coordSegmented.set(true);
return true;
}, EVT_NODE_SEGMENTED);
CountDownLatch failedLatch = new CountDownLatch(2);
IgnitePredicate<Event> failLsnr = evt -> {
assertEquals(EVT_NODE_FAILED, evt.type());
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
if (coordId.equals(nodeId))
failedLatch.countDown();
return true;
};
ignite1.events().localListen(failLsnr, EVT_NODE_FAILED);
grid(2).events().localListen(failLsnr, EVT_NODE_FAILED);
ignite1.configuration().getDiscoverySpi().failNode(coordId, null);
assertTrue(failedLatch.await(2000, MILLISECONDS));
assertTrue(coordSegmented.get());
if (segPlc == SegmentationPolicy.STOP) {
assertTrue(coord.context().isStopping());
waitNodeStop(coord.name());
} else
assertFalse(coord.context().isStopping());
assertEquals(2, ignite1.context().discovery().allNodes().size());
} finally {
stopAllGrids();
}
}
Aggregations