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);
}
}
}
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();
}
}
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;
}
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;
}
Aggregations