Search in sources :

Example 1 with IgniteFinishedFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl in project ignite by apache.

the class GridCommandHandlerTest method testConnectivityCommandWithFailedNodes.

/**
 * Test connectivity command works via control.sh with one node failing.
 */
@Test
public void testConnectivityCommandWithFailedNodes() throws Exception {
    UUID okId = UUID.randomUUID();
    UUID failingId = UUID.randomUUID();
    UnaryOperator<IgniteConfiguration> operator = configuration -> {
        configuration.setCommunicationSpi(new TcpCommunicationSpi() {

            /**
             * {inheritDoc}
             */
            @Override
            public IgniteFuture<BitSet> checkConnection(List<ClusterNode> nodes) {
                BitSet bitSet = new BitSet();
                int idx = 0;
                for (ClusterNode remoteNode : nodes) {
                    if (!remoteNode.id().equals(failingId))
                        bitSet.set(idx);
                    idx++;
                }
                return new IgniteFinishedFutureImpl<>(bitSet);
            }
        });
        return configuration;
    };
    IgniteEx ignite = startGrid("normal", configuration -> {
        operator.apply(configuration);
        configuration.setConsistentId(okId);
        configuration.setNodeId(okId);
        return configuration;
    });
    IgniteEx failure = startGrid("failure", configuration -> {
        operator.apply(configuration);
        configuration.setConsistentId(failingId);
        configuration.setNodeId(failingId);
        return configuration;
    });
    ignite.cluster().state(ACTIVE);
    failure.cluster().state(ACTIVE);
    injectTestSystemOut();
    int connectivity = execute("--diagnostic", "connectivity");
    assertEquals(EXIT_CODE_OK, connectivity);
    String out = testOut.toString();
    String what = "There is no connectivity between the following nodes";
    assertContains(log, out.replaceAll("[\\W_]+", "").trim(), what.replaceAll("[\\W_]+", "").trim());
}
Also used : RandomAccessFile(java.io.RandomAccessFile) BlockedWarmUpConfiguration(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration) Arrays(java.util.Arrays) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) UnaryOperator(java.util.function.UnaryOperator) GridConcurrentHashSet(org.apache.ignite.internal.client.util.GridConcurrentHashSet) EntryProcessor(javax.cache.processor.EntryProcessor) BooleanSupplier(java.util.function.BooleanSupplier) GridFunc(org.apache.ignite.internal.util.lang.GridFunc) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) REENCRYPTION_RESUME(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RESUME) Matcher(java.util.regex.Matcher) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Map(java.util.Map) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Path(java.nio.file.Path) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) VisorTxInfo(org.apache.ignite.internal.visor.tx.VisorTxInfo) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) GridClientFactory(org.apache.ignite.internal.client.GridClientFactory) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) MASTER_KEY_NAME_2(org.apache.ignite.internal.encryption.AbstractEncryptionTest.MASTER_KEY_NAME_2) IgniteCache(org.apache.ignite.IgniteCache) EXIT_CODE_CONNECTION_FAILED(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED) Serializable(java.io.Serializable) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) READ_ONLY_SAFE(org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE) REENCRYPTION_SUSPEND(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_SUSPEND) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) GridClusterStateProcessor(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor) Message(org.apache.ignite.plugin.extensions.communication.Message) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) CACHE_GROUP_KEY_IDS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CACHE_GROUP_KEY_IDS) EntryProcessorException(javax.cache.processor.EntryProcessorException) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) REENCRYPTION_RATE(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RATE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) BlockedWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) REENCRYPTION_STATUS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_STATUS) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DEFAULT_TARGET_FOLDER(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER) Files(java.nio.file.Files) IOException(java.io.IOException) IgniteSnapshotManager(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Field(java.lang.reflect.Field) BaselineNode(org.apache.ignite.cluster.BaselineNode) File(java.io.File) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridNearLockResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) AtomicLong(java.util.concurrent.atomic.AtomicLong) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) LongMetric(org.apache.ignite.spi.metric.LongMetric) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) CheckpointState(org.apache.ignite.internal.processors.cache.persistence.CheckpointState) GridNearTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest) SNAPSHOT_METRICS(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METRICS) IgniteNodeAttributes(org.apache.ignite.internal.IgniteNodeAttributes) Transaction(org.apache.ignite.transactions.Transaction) CONFIRM_MSG(org.apache.ignite.internal.commandline.CommandHandler.CONFIRM_MSG) GridTestUtils.assertThrows(org.apache.ignite.testframework.GridTestUtils.assertThrows) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) MutableEntry(javax.cache.processor.MutableEntry) CHANGE_CACHE_GROUP_KEY(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CHANGE_CACHE_GROUP_KEY) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) X(org.apache.ignite.internal.util.typedef.X) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) TestStorageUtils.corruptDataEntry(org.apache.ignite.util.TestStorageUtils.corruptDataEntry) DEACTIVATE(org.apache.ignite.internal.commandline.CommandList.DEACTIVATE) IgniteFuture(org.apache.ignite.lang.IgniteFuture) File.separatorChar(java.io.File.separatorChar) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl) IGNITE_CLUSTER_NAME(org.apache.ignite.IgniteSystemProperties.IGNITE_CLUSTER_NAME) Collectors(java.util.stream.Collectors) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GRID_NOT_IDLE_MSG(org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.GRID_NOT_IDLE_MSG) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) CU(org.apache.ignite.internal.util.typedef.internal.CU) Pattern(java.util.regex.Pattern) ShutdownPolicy(org.apache.ignite.ShutdownPolicy) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) ClusterStateTestUtils(org.apache.ignite.internal.processors.cache.ClusterStateTestUtils) NotNull(org.jetbrains.annotations.NotNull) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) GridJobExecuteResponse(org.apache.ignite.internal.GridJobExecuteResponse) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) IntStream(java.util.stream.IntStream) LongAdder(java.util.concurrent.atomic.LongAdder) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteSnapshotManager.resolveSnapshotWorkDirectory(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.resolveSnapshotWorkDirectory) HashMap(java.util.HashMap) Function(java.util.function.Function) WarmUpTestPluginProvider(org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider) ToFileDumpProcessor(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.dumpprocessors.ToFileDumpProcessor) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) OpenOption(java.nio.file.OpenOption) AbstractSnapshotSelfTest.snp(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.snp) FindAndDeleteGarbageArg(org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) TimeUnit(java.util.concurrent.TimeUnit) BitSet(java.util.BitSet) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test)

Example 2 with IgniteFinishedFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl in project ignite by apache.

the class GridEncryptionManager method changeMasterKey.

/**
 * {@inheritDoc}
 */
@Override
public IgniteFuture<Void> changeMasterKey(String masterKeyName) {
    if (ctx.clientNode()) {
        return new IgniteFinishedFutureImpl<>(new UnsupportedOperationException("Client and daemon nodes can not " + "perform this operation."));
    }
    if (!IgniteFeatures.allNodesSupports(ctx.grid().cluster().nodes(), MASTER_KEY_CHANGE)) {
        return new IgniteFinishedFutureImpl<>(new IllegalStateException("Not all nodes in the cluster support " + "the master key change process."));
    }
    // can be partially re-encrypted in case of node stop without the possibility of recovery.
    if (!ctx.state().clusterState().active()) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "The cluster is inactive."));
    }
    if (masterKeyName.equals(getMasterKeyName())) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "New name equal to the current."));
    }
    byte[] digest;
    try {
        digest = masterKeyDigest(masterKeyName);
    } catch (Exception e) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "Unable to get the master key digest.", e));
    }
    MasterKeyChangeRequest request = new MasterKeyChangeRequest(UUID.randomUUID(), encryptKeyName(masterKeyName), digest);
    synchronized (opsMux) {
        if (disconnected) {
            return new IgniteFinishedFutureImpl<>(new IgniteClientDisconnectedException(ctx.cluster().clientReconnectFuture(), "Master key change was rejected. Client node disconnected."));
        }
        if (stopped) {
            return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "Node is stopping."));
        }
        if (masterKeyChangeFut != null && !masterKeyChangeFut.isDone()) {
            return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "The previous change was not completed."));
        }
        masterKeyChangeFut = new KeyChangeFuture(request.requestId());
        prepareMKChangeProc.start(request.requestId(), request);
        return new IgniteFutureImpl<>(masterKeyChangeFut);
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteFutureCancelledException(org.apache.ignite.lang.IgniteFutureCancelledException)

Example 3 with IgniteFinishedFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl in project ignite by apache.

the class CacheAsyncContinuationExecutorTest method testRemoteOperationContinuesOnDefaultExecutor.

/**
 * Tests future chain / listen with default executor.
 *
 * This test would hang before {@link IgniteConfiguration#setAsyncContinuationExecutor(Executor)}
 * was introduced, or if we set {@link Runnable#run()} as the executor.
 */
private void testRemoteOperationContinuesOnDefaultExecutor(boolean chain) throws Exception {
    final String key = getPrimaryKey(1);
    IgniteCache<String, Integer> cache = jcache(0);
    CyclicBarrier barrier = new CyclicBarrier(2);
    AtomicReference<String> listenThreadName = new AtomicReference<>("");
    IgniteInClosure<IgniteFuture<Void>> clos = f -> {
        listenThreadName.set(Thread.currentThread().getName());
        if (allowCacheOperationsInContinuation()) {
            // Check that cache operations do not deadlock.
            cache.replace(key, 2);
        }
        try {
            barrier.await(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            e.printStackTrace();
        }
    };
    IgniteFuture<Void> fut = cache.putAsync(key, 1);
    if (chain)
        fut.chain(f -> {
            clos.apply(f);
            return new IgniteFinishedFutureImpl<>();
        });
    else
        fut.listen(clos);
    barrier.await(10, TimeUnit.SECONDS);
    assertEquals(allowCacheOperationsInContinuation() ? 2 : 1, cache.get(key).intValue());
    assertTrue(listenThreadName.get(), listenThreadName.get().startsWith(expectedThreadNamePrefix()));
}
Also used : IntStream(java.util.stream.IntStream) Factory(javax.cache.configuration.Factory) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteFuture(org.apache.ignite.lang.IgniteFuture) CyclicBarrier(java.util.concurrent.CyclicBarrier) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) Executor(java.util.concurrent.Executor) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheStoreAdapter(org.apache.ignite.cache.store.CacheStoreAdapter) CacheLoaderException(javax.cache.integration.CacheLoaderException) IgniteCache(org.apache.ignite.IgniteCache) TimeUnit(java.util.concurrent.TimeUnit) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) Cache(javax.cache.Cache) CacheStore(org.apache.ignite.cache.store.CacheStore) IgniteFuture(org.apache.ignite.lang.IgniteFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheLoaderException(javax.cache.integration.CacheLoaderException) CyclicBarrier(java.util.concurrent.CyclicBarrier)

Example 4 with IgniteFinishedFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl in project ignite by apache.

the class ComputeTaskInternalFuture method finishedFuture.

/**
 * @param ctx Context.
 * @param taskCls Task class.
 * @param e Error.
 * @return Finished task future.
 */
public static <R> ComputeTaskInternalFuture<R> finishedFuture(final GridKernalContext ctx, final Class<?> taskCls, IgniteCheckedException e) {
    assert ctx != null;
    assert taskCls != null;
    assert e != null;
    final long time = U.currentTimeMillis();
    final IgniteUuid id = IgniteUuid.fromUuid(ctx.localNodeId());
    ComputeTaskSession ses = new ComputeTaskSession() {

        @Override
        public String getTaskName() {
            return taskCls.getName();
        }

        @Override
        public UUID getTaskNodeId() {
            return ctx.localNodeId();
        }

        @Override
        public long getStartTime() {
            return time;
        }

        @Override
        public long getEndTime() {
            return time;
        }

        @Override
        public IgniteUuid getId() {
            return id;
        }

        @Override
        public ClassLoader getClassLoader() {
            return null;
        }

        @Override
        public Collection<ComputeJobSibling> getJobSiblings() throws IgniteException {
            return Collections.emptyList();
        }

        @Override
        public Collection<ComputeJobSibling> refreshJobSiblings() throws IgniteException {
            return Collections.emptyList();
        }

        @Nullable
        @Override
        public ComputeJobSibling getJobSibling(IgniteUuid jobId) throws IgniteException {
            return null;
        }

        @Override
        public void setAttribute(Object key, @Nullable Object val) throws IgniteException {
        }

        @Nullable
        @Override
        public <K, V> V getAttribute(K key) {
            return null;
        }

        @Override
        public void setAttributes(Map<?, ?> attrs) throws IgniteException {
        // No-op.
        }

        @Override
        public Map<?, ?> getAttributes() {
            return Collections.emptyMap();
        }

        @Override
        public void addAttributeListener(ComputeTaskSessionAttributeListener lsnr, boolean rewind) {
        // No-op.
        }

        @Override
        public boolean removeAttributeListener(ComputeTaskSessionAttributeListener lsnr) {
            return false;
        }

        @Override
        public <K, V> V waitForAttribute(K key, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public <K, V> boolean waitForAttribute(K key, @Nullable V val, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public Map<?, ?> waitForAttributes(Collection<?> keys, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public boolean waitForAttributes(Map<?, ?> attrs, long timeout) throws InterruptedException {
            throw new InterruptedException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state) {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout) {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite) {
            throw new IgniteException("Session was closed.");
        }

        @Nullable
        @Override
        public <T> T loadCheckpoint(String key) throws IgniteException {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public boolean removeCheckpoint(String key) throws IgniteException {
            throw new IgniteException("Session was closed.");
        }

        @Override
        public Collection<UUID> getTopology() {
            return Collections.emptyList();
        }

        @Override
        public IgniteFuture<?> mapFuture() {
            return new IgniteFinishedFutureImpl<Object>();
        }
    };
    ComputeTaskInternalFuture<R> fut = new ComputeTaskInternalFuture<>(ses, ctx);
    fut.onDone(e);
    return fut;
}
Also used : ComputeTaskSessionScope(org.apache.ignite.compute.ComputeTaskSessionScope) ComputeTaskSessionAttributeListener(org.apache.ignite.compute.ComputeTaskSessionAttributeListener) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteException(org.apache.ignite.IgniteException) Collection(java.util.Collection) ComputeJobSibling(org.apache.ignite.compute.ComputeJobSibling) UUID(java.util.UUID) Map(java.util.Map) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with IgniteFinishedFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl in project ignite by apache.

the class IgniteClientReconnectMassiveShutdownTest method getRetryFuture.

/**
 * Gets retry or reconnect future if passed in {@code 'Exception'} has corresponding class in {@code 'cause'}
 * hierarchy.
 *
 * @param e {@code Exception}.
 * @return Internal future.
 * @throws Exception If unable to find retry or reconnect future.
 */
private IgniteFuture<?> getRetryFuture(Exception e) throws Exception {
    if (X.hasCause(e, IgniteClientDisconnectedException.class)) {
        IgniteClientDisconnectedException cause = X.cause(e, IgniteClientDisconnectedException.class);
        assertNotNull(cause);
        return cause.reconnectFuture();
    } else if (X.hasCause(e, ClusterTopologyException.class)) {
        ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class);
        assertNotNull(cause);
        return cause.retryReadyFuture();
    } else if (X.hasCause(e, CacheInvalidStateException.class)) {
        // All partition owners have left the cluster, partition data has been lost.
        return new IgniteFinishedFutureImpl<>();
    } else
        throw e;
}
Also used : IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl)

Aggregations

IgniteFinishedFutureImpl (org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl)9 IgniteException (org.apache.ignite.IgniteException)5 Collection (java.util.Collection)4 Map (java.util.Map)3 IgniteFutureImpl (org.apache.ignite.internal.util.future.IgniteFutureImpl)3 Test (org.junit.Test)3 File (java.io.File)2 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 BitSet (java.util.BitSet)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 UUID (java.util.UUID)2 TimeUnit (java.util.concurrent.TimeUnit)2