Search in sources :

Example 1 with ClusterGroupEmptyException

use of org.apache.ignite.cluster.ClusterGroupEmptyException in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpLongRunningTransaction.

/**
 * Dumps long running transaction. If transaction is active and is not near, sends compute request
 * to near node to get the stack trace of transaction owner thread.
 *
 * @param tx Transaction.
 */
private void dumpLongRunningTransaction(IgniteInternalTx tx) {
    Collection<UUID> masterNodeIds = tx.masterNodeIds();
    if (masterNodeIds.size() == 1) {
        UUID nearNodeId = masterNodeIds.iterator().next();
        long txOwnerThreadId = tx.threadId();
        Ignite ignite = cctx.kernalContext().grid();
        ClusterGroup nearNode = ignite.cluster().forNodeId(nearNodeId);
        String txRequestInfo = String.format("[xidVer=%s, nodeId=%s]", tx.xidVersion().toString(), nearNodeId.toString());
        if (allNodesSupports(nearNode.nodes(), TRANSACTION_OWNER_THREAD_DUMP_PROVIDING)) {
            IgniteCompute compute = ignite.compute(ignite.cluster().forNodeId(nearNodeId));
            try {
                compute.callAsync(new FetchActiveTxOwnerTraceClosure(txOwnerThreadId)).listen(new IgniteInClosure<IgniteFuture<String>>() {

                    @Override
                    public void apply(IgniteFuture<String> strIgniteFut) {
                        String traceDump = null;
                        try {
                            traceDump = strIgniteFut.get();
                        } catch (ClusterGroupEmptyException e) {
                            U.error(diagnosticLog, "Could not get thread dump from transaction owner because near node " + "is out of topology now. " + txRequestInfo);
                        } catch (Exception e) {
                            U.error(diagnosticLog, "Could not get thread dump from transaction owner near node " + txRequestInfo, e);
                        }
                        if (traceDump != null) {
                            U.warn(diagnosticLog, String.format("Dumping the near node thread that started transaction %s\n%s", txRequestInfo, traceDump));
                        }
                    }
                });
            } catch (Exception e) {
                U.error(diagnosticLog, "Could not send dump request to transaction owner near node " + txRequestInfo, e);
            }
        } else {
            U.warn(diagnosticLog, "Could not send dump request to transaction owner near node: node does not support this feature. " + txRequestInfo);
        }
    }
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) IgniteFuture(org.apache.ignite.lang.IgniteFuture) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) IgniteCompute(org.apache.ignite.IgniteCompute)

Example 2 with ClusterGroupEmptyException

use of org.apache.ignite.cluster.ClusterGroupEmptyException in project ignite by apache.

the class IgniteClusterImpl method startNodesAsync0.

/**
 * @param hosts Startup parameters.
 * @param dflts Default values.
 * @param restart Whether to stop existing nodes
 * @param timeout Connection timeout in milliseconds.
 * @param maxConn Number of parallel SSH connections to one host.
 * @return Future with results.
 * @see IgniteCluster#startNodes(java.util.Collection, java.util.Map, boolean, int, int)
 */
IgniteInternalFuture<Collection<ClusterStartNodeResult>> startNodesAsync0(Collection<Map<String, Object>> hosts, @Nullable Map<String, Object> dflts, boolean restart, int timeout, int maxConn) {
    A.notNull(hosts, "hosts");
    guard();
    try {
        IgniteSshHelper sshHelper = IgniteComponentType.SSH.create(false);
        Map<String, Collection<IgniteRemoteStartSpecification>> specsMap = specifications(hosts, dflts);
        Map<String, ConcurrentLinkedQueue<StartNodeCallable>> runMap = new HashMap<>();
        int nodeCallCnt = 0;
        for (String host : specsMap.keySet()) {
            InetAddress addr;
            try {
                addr = InetAddress.getByName(host);
            } catch (UnknownHostException e) {
                throw new IgniteCheckedException("Invalid host name: " + host, e);
            }
            Collection<? extends ClusterNode> neighbors = null;
            if (addr.isLoopbackAddress())
                neighbors = neighbors();
            else {
                for (Collection<ClusterNode> p : U.neighborhood(nodes()).values()) {
                    ClusterNode node = F.first(p);
                    if (node.<String>attribute(ATTR_IPS).contains(addr.getHostAddress())) {
                        neighbors = p;
                        break;
                    }
                }
            }
            int startIdx = 1;
            if (neighbors != null) {
                if (restart && !neighbors.isEmpty()) {
                    try {
                        ctx.grid().compute(forNodes(neighbors)).execute(IgniteKillTask.class, false);
                    } catch (ClusterGroupEmptyException ignored) {
                    // No-op, nothing to restart.
                    }
                } else
                    startIdx = neighbors.size() + 1;
            }
            ConcurrentLinkedQueue<StartNodeCallable> nodeRuns = new ConcurrentLinkedQueue<>();
            runMap.put(host, nodeRuns);
            for (IgniteRemoteStartSpecification spec : specsMap.get(host)) {
                assert spec.host().equals(host);
                for (int i = startIdx; i <= spec.nodes(); i++) {
                    nodeRuns.add(sshHelper.nodeStartCallable(spec, timeout));
                    nodeCallCnt++;
                }
            }
        }
        // If there is nothing to start, return finished future with empty result.
        if (nodeCallCnt == 0)
            return new GridFinishedFuture<Collection<ClusterStartNodeResult>>(Collections.<ClusterStartNodeResult>emptyList());
        // Exceeding max line width for readability.
        GridCompoundFuture<ClusterStartNodeResult, Collection<ClusterStartNodeResult>> fut = new GridCompoundFuture<>(CU.<ClusterStartNodeResult>objectsReducer());
        AtomicInteger cnt = new AtomicInteger(nodeCallCnt);
        // Limit maximum simultaneous connection number per host.
        for (ConcurrentLinkedQueue<StartNodeCallable> queue : runMap.values()) {
            for (int i = 0; i < maxConn; i++) {
                if (!runNextNodeCallable(queue, fut, cnt))
                    break;
            }
        }
        return fut;
    } catch (IgniteCheckedException e) {
        return new GridFinishedFuture<>(e);
    } finally {
        unguard();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteSshHelper(org.apache.ignite.internal.util.nodestart.IgniteSshHelper) UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteRemoteStartSpecification(org.apache.ignite.internal.util.nodestart.IgniteRemoteStartSpecification) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Collection(java.util.Collection) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) InetAddress(java.net.InetAddress) StartNodeCallable(org.apache.ignite.internal.util.nodestart.StartNodeCallable)

Example 3 with ClusterGroupEmptyException

use of org.apache.ignite.cluster.ClusterGroupEmptyException in project ignite by apache.

the class IgniteUtils method exceptionConverters.

/**
 * Gets map with converters to convert internal checked exceptions to public API unchecked exceptions.
 *
 * @return Exception converters.
 */
private static Map<Class<? extends IgniteCheckedException>, C1<IgniteCheckedException, IgniteException>> exceptionConverters() {
    Map<Class<? extends IgniteCheckedException>, C1<IgniteCheckedException, IgniteException>> m = new HashMap<>();
    m.put(IgniteInterruptedCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new IgniteInterruptedException(e.getMessage(), (InterruptedException) e.getCause());
        }
    });
    m.put(IgniteFutureCancelledCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new IgniteFutureCancelledException(e.getMessage(), e);
        }
    });
    m.put(IgniteFutureTimeoutCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new IgniteFutureTimeoutException(e.getMessage(), e);
        }
    });
    m.put(ClusterGroupEmptyCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new ClusterGroupEmptyException(e.getMessage(), e);
        }
    });
    m.put(ClusterTopologyCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            ClusterTopologyException topEx = new ClusterTopologyException(e.getMessage(), e);
            ClusterTopologyCheckedException checked = (ClusterTopologyCheckedException) e;
            if (checked.retryReadyFuture() != null)
                topEx.retryReadyFuture(new IgniteFutureImpl<>(checked.retryReadyFuture()));
            return topEx;
        }
    });
    m.put(IgniteDeploymentCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new IgniteDeploymentException(e.getMessage(), e);
        }
    });
    m.put(ComputeTaskTimeoutCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new ComputeTaskTimeoutException(e.getMessage(), e);
        }
    });
    m.put(ComputeTaskCancelledCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new ComputeTaskCancelledException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxRollbackCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionRollbackException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxHeuristicCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionHeuristicException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxTimeoutCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            if (e.getCause() instanceof TransactionDeadlockException)
                return new TransactionTimeoutException(e.getMessage(), e.getCause());
            return new TransactionTimeoutException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxOptimisticCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionOptimisticException(e.getMessage(), e);
        }
    });
    m.put(IgniteClientDisconnectedCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new IgniteClientDisconnectedException(((IgniteClientDisconnectedCheckedException) e).reconnectFuture(), e.getMessage(), e);
        }
    });
    m.put(IgniteTxSerializationCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionSerializationException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxDuplicateKeyCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionDuplicateKeyException(e.getMessage(), e);
        }
    });
    m.put(IgniteTxAlreadyCompletedCheckedException.class, new C1<IgniteCheckedException, IgniteException>() {

        @Override
        public IgniteException apply(IgniteCheckedException e) {
            return new TransactionAlreadyCompletedException(e.getMessage(), e);
        }
    });
    return m;
}
Also used : TransactionDeadlockException(org.apache.ignite.transactions.TransactionDeadlockException) TransactionDuplicateKeyException(org.apache.ignite.transactions.TransactionDuplicateKeyException) TransactionSerializationException(org.apache.ignite.transactions.TransactionSerializationException) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) IgniteDeploymentException(org.apache.ignite.IgniteDeploymentException) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) TransactionHeuristicException(org.apache.ignite.transactions.TransactionHeuristicException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) C1(org.apache.ignite.internal.util.typedef.C1) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ComputeTaskTimeoutException(org.apache.ignite.compute.ComputeTaskTimeoutException) TransactionOptimisticException(org.apache.ignite.transactions.TransactionOptimisticException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) TransactionAlreadyCompletedException(org.apache.ignite.transactions.TransactionAlreadyCompletedException) ComputeTaskCancelledException(org.apache.ignite.compute.ComputeTaskCancelledException) IgniteFutureTimeoutException(org.apache.ignite.lang.IgniteFutureTimeoutException) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) IgniteFutureCancelledException(org.apache.ignite.lang.IgniteFutureCancelledException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 4 with ClusterGroupEmptyException

use of org.apache.ignite.cluster.ClusterGroupEmptyException in project ignite by apache.

the class VisorNodeDataCollectorTask method reduce.

/**
 * @param taskRes Task result.
 * @param results Results.
 * @return Data collector task result.
 */
protected VisorNodeDataCollectorTaskResult reduce(VisorNodeDataCollectorTaskResult taskRes, List<ComputeJobResult> results) {
    for (ComputeJobResult res : results) {
        VisorNodeDataCollectorJobResult jobRes = res.getData();
        if (jobRes != null) {
            UUID nid = res.getNode().id();
            IgniteException unhandledEx = res.getException();
            if (unhandledEx == null)
                reduceJobResult(taskRes, jobRes, nid);
            else {
                // Ignore nodes that left topology.
                if (!(unhandledEx instanceof ClusterGroupEmptyException))
                    taskRes.getUnhandledEx().put(nid, new VisorExceptionWrapper(unhandledEx));
            }
        }
    }
    taskRes.setActive(ignite.cluster().active());
    return taskRes;
}
Also used : IgniteException(org.apache.ignite.IgniteException) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) VisorExceptionWrapper(org.apache.ignite.internal.visor.util.VisorExceptionWrapper) UUID(java.util.UUID) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult)

Aggregations

ClusterGroupEmptyException (org.apache.ignite.cluster.ClusterGroupEmptyException)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Collection (java.util.Collection)1 IdentityHashMap (java.util.IdentityHashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ignite (org.apache.ignite.Ignite)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteCompute (org.apache.ignite.IgniteCompute)1 IgniteDeploymentException (org.apache.ignite.IgniteDeploymentException)1 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)1