@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; } });
ClusterTopologyException topEx = (ClusterTopologyException)e.getCause(); topEx.retryReadyFuture().get(); IgniteFuture<?> fut = e.retryReadyFuture();
/** * Handles cache operation exception. * @param e Exception */ void handleCacheOperationException(Exception e){ IgniteFuture<?> retryFut = null; if (e instanceof IllegalStateException) { initCache(); return; } else if (X.hasCause(e, IgniteClientDisconnectedException.class)) { IgniteClientDisconnectedException cause = X.cause(e, IgniteClientDisconnectedException.class); assert cause != null : e; retryFut = cause.reconnectFuture(); } else if (X.hasCause(e, ClusterTopologyException.class)) { ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class); assert cause != null : e; retryFut = cause.retryReadyFuture(); } if (retryFut != null) { try { retryFut.get(retriesTimeout); } catch (IgniteException retryErr) { throw new IgniteException("Failed to wait for retry: " + retryErr); } } }
/** * Performs an operation with transaction with retries. * * @param cache Cache to do the transaction on. * @param clo Closure. * @return Result of closure execution. * @throws IgniteCheckedException If failed. */ public static <T> T doInTransactionWithRetries(IgniteInternalCache cache, IgniteOutClosureX<T> clo) throws IgniteCheckedException { assert cache != null; int attempts = 0; while (attempts < MAX_CACHE_TX_RETRIES) { try (Transaction tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ)) { T res = clo.applyx(); tx.commit(); return res; } catch (IgniteException | IgniteCheckedException e) { ClusterTopologyException cte = X.cause(e, ClusterTopologyException.class); if (cte != null) ((IgniteFutureImpl)cte.retryReadyFuture()).internalFuture().getUninterruptibly(); else throw U.cast(e); } attempts++; } throw new IgniteCheckedException("Failed to perform operation since max number of attempts " + "exceeded. [maxAttempts=" + MAX_CACHE_TX_RETRIES + ']'); }
ClusterTopologyException topEx = (ClusterTopologyException)e.getCause(); topEx.retryReadyFuture().get(); IgniteFuture<?> fut = e.retryReadyFuture();
/** * 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 throw e; }
@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; } });
((IgniteFutureImpl)cte.retryReadyFuture()).internalFuture().getUninterruptibly(); else throw U.cast(e);
/** * Handles cache operation exception. * @param e Exception */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") void handleCacheOperationException(Exception e){ IgniteFuture<?> retryFut = null; if (e instanceof IllegalStateException) { initCache(); return; } else if (X.hasCause(e, IgniteClientDisconnectedException.class)) { IgniteClientDisconnectedException cause = X.cause(e, IgniteClientDisconnectedException.class); assert cause != null : e; retryFut = cause.reconnectFuture(); } else if (X.hasCause(e, ClusterTopologyException.class)) { ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class); assert cause != null : e; retryFut = cause.retryReadyFuture(); } if (retryFut != null) { try { retryFut.get(retriesTimeout); } catch (IgniteException retryErr) { throw new IgniteException("Failed to wait for retry: " + retryErr); } } }