Search in sources :

Example 1 with EVT_NODE_FAILED

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);
}
Also used : EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) U(org.apache.ignite.internal.util.typedef.internal.U) UNAME(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.UNAME) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ClusterNode(org.apache.ignite.cluster.ClusterNode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) IgniteCluster(org.apache.ignite.IgniteCluster) Map(java.util.Map) X(org.apache.ignite.internal.util.typedef.X) IGNITE_HOME(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.IGNITE_HOME) NODES(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.NODES) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CFG(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.CFG) DFLT_TIMEOUT(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.DFLT_TIMEOUT) Iterator(java.util.Iterator) EventType(org.apache.ignite.events.EventType) GridTestProperties(org.apache.ignite.testframework.config.GridTestProperties) PASSWD(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.PASSWD) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) IgniteNodeStartUtils(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils) KEY(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.KEY) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) File(java.io.File) CountDownLatch(java.util.concurrent.CountDownLatch) Nullable(org.jetbrains.annotations.Nullable) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) Paths(java.nio.file.Paths) Collections(java.util.Collections) SCRIPT(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.SCRIPT) Event(org.apache.ignite.events.Event) File(java.io.File)

Example 2 with 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);
}
Also used : MappedName(org.apache.ignite.internal.processors.marshaller.MappedName) EVT_CLUSTER_SNAPSHOT_FINISHED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FINISHED) BufferedInputStream(java.io.BufferedInputStream) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) CacheObjectBinaryProcessorImpl.binaryWorkDir(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.binaryWorkDir) ReadOnlyMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) METASTORAGE_CACHE_ID(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID) Map(java.util.Map) TransmissionHandler(org.apache.ignite.internal.managers.communication.TransmissionHandler) Path(java.nio.file.Path) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) Serializable(java.io.Serializable) ByteOrder(java.nio.ByteOrder) FileVisitResult(java.nio.file.FileVisitResult) SnapshotEvent(org.apache.ignite.events.SnapshotEvent) END_SNAPSHOT(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.END_SNAPSHOT) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteLogger(org.apache.ignite.IgniteLogger) EVT_CLUSTER_SNAPSHOT_STARTED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_STARTED) PageIO.getVersion(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getVersion) ReadWriteMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage) S(org.apache.ignite.internal.util.typedef.internal.S) METASTORAGE_CACHE_NAME(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME) GridInternal(org.apache.ignite.internal.processors.task.GridInternal) A(org.apache.ignite.internal.util.typedef.internal.A) MarshallerContextImpl.resolveMappingFileStoreWorkDir(org.apache.ignite.internal.MarshallerContextImpl.resolveMappingFileStoreWorkDir) IOException(java.io.IOException) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) T2(org.apache.ignite.internal.util.typedef.T2) BinaryType(org.apache.ignite.binary.BinaryType) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) StandaloneGridKernalContext(org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext) BROADCAST(org.apache.ignite.internal.GridClosureCallMode.BROADCAST) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) DFLT_BINARY_METADATA_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_BINARY_METADATA_PATH) GroupPartitionId.getTypeByPartId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId) PageIdUtils.flag(org.apache.ignite.internal.pagemem.PageIdUtils.flag) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) START_SNAPSHOT(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.START_SNAPSHOT) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) PageIdUtils.pageId(org.apache.ignite.internal.pagemem.PageIdUtils.pageId) PageIdUtils.toDetailString(org.apache.ignite.internal.pagemem.PageIdUtils.toDetailString) PageStore(org.apache.ignite.internal.pagemem.store.PageStore) IgniteFeatures.nodeSupports(org.apache.ignite.internal.IgniteFeatures.nodeSupports) BiFunction(java.util.function.BiFunction) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MarshallerContextImpl.mappingFileStoreWorkDir(org.apache.ignite.internal.MarshallerContextImpl.mappingFileStoreWorkDir) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) FastCrc(org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc) InitMessage(org.apache.ignite.internal.util.distributed.InitMessage) FilePageStoreManager.cacheDirectories(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirectories) CU(org.apache.ignite.internal.util.typedef.internal.CU) Queue(java.util.Queue) FilePageStoreManager.getPartitionFile(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFile) MarshallerUtils(org.apache.ignite.marshaller.MarshallerUtils) DataPagePayload(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPagePayload) SnapshotViewWalker(org.apache.ignite.internal.managers.systemview.walker.SnapshotViewWalker) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) Function(java.util.function.Function) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) GridUnsafe.bufferAddress(org.apache.ignite.internal.util.GridUnsafe.bufferAddress) DFLT_MARSHALLER_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_MARSHALLER_PATH) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) TC_SUBGRID(org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) FileInputStream(java.io.FileInputStream) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) GridCloseableIterator(org.apache.ignite.internal.util.lang.GridCloseableIterator) Consumer(java.util.function.Consumer) PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) DataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) BitSet(java.util.BitSet) FileChannel(java.nio.channels.FileChannel) IgniteSnapshot(org.apache.ignite.IgniteSnapshot) TransmissionMeta(org.apache.ignite.internal.managers.communication.TransmissionMeta) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) Arrays(java.util.Arrays) CacheType(org.apache.ignite.internal.processors.cache.CacheType) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) MAX_PARTITION_ID(org.apache.ignite.internal.pagemem.PageIdAllocator.MAX_PARTITION_ID) BooleanSupplier(java.util.function.BooleanSupplier) DirectoryStream(java.nio.file.DirectoryStream) GridCloseableIteratorAdapter(org.apache.ignite.internal.util.GridCloseableIteratorAdapter) MarshallerContextImpl.saveMappings(org.apache.ignite.internal.MarshallerContextImpl.saveMappings) ComputeTask(org.apache.ignite.compute.ComputeTask) T_DATA(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.T_DATA) DataRow(org.apache.ignite.internal.processors.cache.tree.DataRow) PERSISTENCE_CACHE_SNAPSHOT(org.apache.ignite.internal.IgniteFeatures.PERSISTENCE_CACHE_SNAPSHOT) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) EnumMap(java.util.EnumMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) GridBusyLock(org.apache.ignite.internal.util.GridBusyLock) TransmissionCancelledException(org.apache.ignite.internal.managers.communication.TransmissionCancelledException) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter) PageIO.getType(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getType) INDEX_PARTITION(org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PageIdUtils.pageIndex(org.apache.ignite.internal.pagemem.PageIdUtils.pageIndex) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) IgniteUtils.isLocalNodeCoordinator(org.apache.ignite.internal.util.IgniteUtils.isLocalNodeCoordinator) CacheObjectBinaryProcessorImpl.resolveBinaryWorkDir(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.resolveBinaryWorkDir) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) READ(java.nio.file.StandardOpenOption.READ) ClusterNode(org.apache.ignite.cluster.ClusterNode) DB_DEFAULT_FOLDER(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) BiConsumer(java.util.function.BiConsumer) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) Files(java.nio.file.Files) Executor(java.util.concurrent.Executor) TC_SKIP_AUTH(org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SKIP_AUTH) FileOutputStream(java.io.FileOutputStream) Marshaller(org.apache.ignite.marshaller.Marshaller) File(java.io.File) GridTopic(org.apache.ignite.internal.GridTopic) Paths(java.nio.file.Paths) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) ArrayDeque(java.util.ArrayDeque) IgniteUuid(org.apache.ignite.lang.IgniteUuid) FLAG_DATA(org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) ByteBuffer(java.nio.ByteBuffer) IgniteFutureCancelledCheckedException(org.apache.ignite.internal.IgniteFutureCancelledCheckedException) SNAPSHOT_SYS_VIEW_DESC(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW_DESC) FilePageStore(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore) IgniteFuture(org.apache.ignite.lang.IgniteFuture) PART_FILE_TEMPLATE(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_TEMPLATE) FailureType(org.apache.ignite.failure.FailureType) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) Predicate(java.util.function.Predicate) IgniteException(org.apache.ignite.IgniteException) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) GridCacheSharedManagerAdapter(org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) DiscoveryEventListener(org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) FilePageStoreManager.getPartitionFileName(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) HashMap(java.util.HashMap) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager) Deque(java.util.Deque) EVT_CLUSTER_SNAPSHOT_FAILED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED) IgniteCallable(org.apache.ignite.lang.IgniteCallable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) FailureContext(org.apache.ignite.failure.FailureContext) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) BALANCE(org.apache.ignite.internal.GridClosureCallMode.BALANCE) PageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO) IgniteThrowableFunction(org.apache.ignite.internal.util.lang.IgniteThrowableFunction) DistributedMetaStorageImpl(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl) OutputStream(java.io.OutputStream) DistributedProcess(org.apache.ignite.internal.util.distributed.DistributedProcess) F(org.apache.ignite.internal.util.typedef.F) PageIO.getPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getPageIO) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) TransmissionPolicy(org.apache.ignite.internal.managers.communication.TransmissionPolicy) ADMIN_SNAPSHOT(org.apache.ignite.plugin.security.SecurityPermission.ADMIN_SNAPSHOT) INDEX_FILE_NAME(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME) Collections(java.util.Collections) InputStream(java.io.InputStream) SnapshotViewWalker(org.apache.ignite.internal.managers.systemview.walker.SnapshotViewWalker) StandaloneGridKernalContext(org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext) GridKernalContext(org.apache.ignite.internal.GridKernalContext) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) PageIdUtils.toDetailString(org.apache.ignite.internal.pagemem.PageIdUtils.toDetailString) UUID(java.util.UUID) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 3 with EVT_NODE_FAILED

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;
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) G(org.apache.ignite.internal.util.typedef.G) DistributedProcess(org.apache.ignite.internal.util.distributed.DistributedProcess) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) TEST_PROCESS(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.TEST_PROCESS) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) FailureHandler(org.apache.ignite.failure.FailureHandler) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) FailureContext(org.apache.ignite.failure.FailureContext) Collections(java.util.Collections) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) FailureHandler(org.apache.ignite.failure.FailureHandler) Ignite(org.apache.ignite.Ignite)

Example 4 with EVT_NODE_FAILED

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();
    }
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) DiscoveryDataBag(org.apache.ignite.spi.discovery.DiscoveryDataBag) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) TcpDiscoveryNodeAddFinishedMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage) IgniteEx(org.apache.ignite.internal.IgniteEx) EVT_NODE_SEGMENTED(org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) GridPortRecord(org.apache.ignite.internal.processors.port.GridPortRecord) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) X(org.apache.ignite.internal.util.typedef.X) TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) TcpDiscoveryCustomEventMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage) TcpDiscoveryNodeLeftMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage) IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) TcpDiscoveryConnectionCheckMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryConnectionCheckMessage) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) EventType(org.apache.ignite.events.EventType) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) GridComponent(org.apache.ignite.internal.GridComponent) EVT_TASK_FINISHED(org.apache.ignite.events.EventType.EVT_TASK_FINISHED) UUID(java.util.UUID) TcpDiscoveryAbstractMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) EVT_JOB_MAPPED(org.apache.ignite.events.EventType.EVT_JOB_MAPPED) InetSocketAddress(java.net.InetSocketAddress) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) TcpDiscoveryNodeAddedMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) NotNull(org.jetbrains.annotations.NotNull) TcpDiscoveryMetricsUpdateMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) LogListener(org.apache.ignite.testframework.LogListener) EVT_NODE_METRICS_UPDATED(org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED) Socket(java.net.Socket) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) MARSHALLER_PROC(org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.MARSHALLER_PROC) ArrayList(java.util.ArrayList) TcpDiscoveryStatistics(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics) DiscoveryDataPacket(org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket) StartRoutineAckDiscoveryMessage(org.apache.ignite.internal.processors.continuous.StartRoutineAckDiscoveryMessage) ClusterNode(org.apache.ignite.cluster.ClusterNode) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) IgniteIllegalStateException(org.apache.ignite.IgniteIllegalStateException) SocketTimeoutException(java.net.SocketTimeoutException) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) SegmentationPolicy(org.apache.ignite.plugin.segmentation.SegmentationPolicy) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) DiscoverySpiDataExchange(org.apache.ignite.spi.discovery.DiscoverySpiDataExchange) LinkedHashSet(java.util.LinkedHashSet) OutputStream(java.io.OutputStream) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) TcpDiscoveryNodeFailedMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage) JAVA_ID(org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) IOException(java.io.IOException) Test(org.junit.Test) EVT_TASK_FAILED(org.apache.ignite.events.EventType.EVT_TASK_FAILED) Ignite(org.apache.ignite.Ignite) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) TimeUnit(java.util.concurrent.TimeUnit) Ignition(org.apache.ignite.Ignition) UDP(org.apache.ignite.spi.IgnitePortProtocol.UDP) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PA(org.apache.ignite.internal.util.typedef.PA) Collections(java.util.Collections) IgniteUuid(org.apache.ignite.lang.IgniteUuid) SECONDS(java.util.concurrent.TimeUnit.SECONDS) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteEx(org.apache.ignite.internal.IgniteEx) Event(org.apache.ignite.events.Event) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) UUID(java.util.UUID) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 UUID (java.util.UUID)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 EVT_NODE_FAILED (org.apache.ignite.events.EventType.EVT_NODE_FAILED)4 EVT_NODE_LEFT (org.apache.ignite.events.EventType.EVT_NODE_LEFT)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Map (java.util.Map)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Ignite (org.apache.ignite.Ignite)3 IgniteException (org.apache.ignite.IgniteException)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 F (org.apache.ignite.internal.util.typedef.F)3 G (org.apache.ignite.internal.util.typedef.G)3 U (org.apache.ignite.internal.util.typedef.internal.U)3