/** * @param cpTs Checkpoint timestamp. * @return Initialized entry. * @throws IgniteCheckedException If failed to initialize entry. */ private CheckpointEntry entry(Long cpTs) throws IgniteCheckedException { CheckpointEntry entry = histMap.get(cpTs); if (entry == null) throw new IgniteCheckedException("Checkpoint entry was removed: " + cpTs); return entry; }
/** {@inheritDoc} */ @Override public boolean sendMessage(@Nullable UUID nodeId, Message msg, IgniteInClosure<IgniteException> c) throws IgniteCheckedException { try { // Node ID is never provided in asynchronous send mode. assert nodeId == null; ses.sendNoFuture(msg, c); } catch (IgniteCheckedException e) { if (log.isDebugEnabled()) log.debug("Failed to send message [client=" + this + ", err=" + e + ']'); if (e.getCause() instanceof IOException) { ses.close(); return true; } else throw new IgniteCheckedException("Failed to send message [client=" + this + ']', e); } return false; }
/** {@inheritDoc} */ @Override public String getMessage() { return super.getMessage() + ": " + failedKeys; } }
/** * Creates {@code IgniteCheckedException} with the collection of suppressed exceptions. * * @param msg Message. * @param suppressed The collections of suppressed exceptions. * @return {@code IgniteCheckedException}. */ public static IgniteCheckedException exceptionWithSuppressed(String msg, @Nullable Collection<Throwable> suppressed) { IgniteCheckedException e = new IgniteCheckedException(msg); if (suppressed != null) { for (Throwable th : suppressed) e.addSuppressed(th); } return e; }
@Override public IgniteException apply(IgniteCheckedException e) { if (e.getCause() instanceof TransactionDeadlockException) return new TransactionTimeoutException(e.getMessage(), e.getCause()); return new TransactionTimeoutException(e.getMessage(), e); } });
/** * Cast Ignite exception to appropriate IO exception. * * @param e Exception to cast. * @param path Path for exceptions. * @return Casted exception. */ public static IOException cast(IgniteCheckedException e, @Nullable String path) { assert e != null; // First check for any nested IOException; if exists - re-throw it. if (e.hasCause(IOException.class)) return e.getCause(IOException.class); else if (e.hasCause(IgfsPathNotFoundException.class)) return new FileNotFoundException(path); // TODO: Or PathNotFoundException? else if (e.hasCause(IgfsParentNotDirectoryException.class)) return new ParentNotDirectoryException(path); else if (path != null && e.hasCause(IgfsDirectoryNotEmptyException.class)) return new PathIsNotEmptyDirectoryException(path); else if (path != null && e.hasCause(IgfsPathAlreadyExistsException.class)) return new PathExistsException(path); else { String msg = e.getMessage(); return msg == null ? new IOException(e) : new IOException(msg, e); } }
/** * @param ctx Cache context. * @throws IgniteCheckedException If failed. */ public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException { key.prepareMarshal(ctx.cacheObjectContext()); if (err != null && errBytes == null) { try { errBytes = U.marshal(ctx.marshaller(), err); } catch (IgniteCheckedException e) { // Try send exception even if it's unable to marshal. IgniteCheckedException exc = new IgniteCheckedException(err.getMessage()); exc.setStackTrace(err.getStackTrace()); exc.addSuppressed(e); errBytes = U.marshal(ctx.marshaller(), exc); } } assert unprepareRes == null : "marshalResult() was not called for the result: " + this; if (res != null) res.prepareMarshal(ctx.cacheObjectContext()); }
/** * Error occurred on node with given ID. * * @param nodeId Node ID. * @param e Caught exception. */ private void onError(UUID nodeId, IgniteCheckedException e) { // If waiting for ack from this node. if (hasPendingAcks(nodeId)) { ackMap.clear(); signalNoAcks(); if (e.hasCause(IgfsOutOfSpaceException.class)) onDone(new IgniteCheckedException("Failed to write data (not enough space on node): " + nodeId, e)); else onDone(new IgniteCheckedException( "Failed to wait for write completion (write failed on node): " + nodeId, e)); } }
/** * @param e Exception to handle. * @return GridSpiException Converted exception. */ private IgniteSpiException unwrapException(IgniteCheckedException e) { // Avoid double-wrapping. if (e.getCause() instanceof IgniteSpiException) return (IgniteSpiException)e.getCause(); return new IgniteSpiException("Failed to execute SPI context method.", e); } });
info("Got expected exception: " + e); e.printStackTrace(); assertTrue(e.getMessage().startsWith("Incompatible types"));
/** * Gets error code based on exception class. * * @param e Exception to analyze. * @param checkIo Whether to check for IO exception. * @return Error code. */ private int errorCode(IgniteCheckedException e, boolean checkIo) { if (X.hasCause(e, IgfsPathNotFoundException.class)) return ERR_FILE_NOT_FOUND; else if (e.hasCause(IgfsPathAlreadyExistsException.class)) return ERR_PATH_ALREADY_EXISTS; else if (e.hasCause(IgfsDirectoryNotEmptyException.class)) return ERR_DIRECTORY_NOT_EMPTY; else if (e.hasCause(IgfsParentNotDirectoryException.class)) return ERR_PARENT_NOT_DIRECTORY; else if (e.hasCause(IgfsInvalidHdfsVersionException.class)) return ERR_INVALID_HDFS_VERSION; else if (e.hasCause(IgfsCorruptedFileException.class)) return ERR_CORRUPTED_FILE; // This check should be the last. else if (e.hasCause(IgfsException.class)) return ERR_IGFS_GENERIC; return ERR_GENERIC; }
if (e.hasCause(ClusterTopologyCheckedException.class)) { if (log.isDebugEnabled()) log.debug("Failed to process fragmentizer request (remote node left the grid) " + "[req=" + req + ", err=" + e.getMessage() + ']');
e.printStackTrace(); // Should never happen.
@Override public void apply(CacheSearchRow row) { try { rowStore.removeRow(row.link(), grp.statisticsHolderData()); } catch (IgniteCheckedException e) { U.error(log, "Failed to remove row [link=" + row.link() + "]"); IgniteCheckedException ex = exception.get(); if (ex == null) exception.set(e); else ex.addSuppressed(e); } } });
/** * @param nodeId Node ID. * @param msg Message. */ private void onAuthenticateRequestMessage(UUID nodeId, UserAuthenticateRequestMessage msg) { UserAuthenticateResponseMessage respMsg; try { User u = authenticateOnServer(msg.name(), msg.password()); respMsg = new UserAuthenticateResponseMessage(msg.id(), null); } catch (IgniteCheckedException e) { respMsg = new UserAuthenticateResponseMessage(msg.id(), e.toString()); e.printStackTrace(); } try { ctx.io().sendToGridTopic(nodeId, GridTopic.TOPIC_AUTH, respMsg, GridIoPolicy.SYSTEM_POOL); } catch (IgniteCheckedException e) { U.error(log, "Unexpected exception on send UserAuthenticateResponseMessage.", e); } }
/** * @param keys Keys. * @param e Error. */ void addFailedKeys(Collection<KeyCacheObject> keys, Throwable e) { if (failedKeys == null) failedKeys = new ArrayList<>(keys.size()); failedKeys.addAll(keys); if (err == null) err = new IgniteCheckedException("Failed to update keys on primary node."); err.addSuppressed(e); }
if (e.hasCause(ClusterTopologyCheckedException.class, ClusterGroupEmptyCheckedException.class)) U.warn(log, "Failed to execute task due to topology issues (are all mapped " + "nodes alive?) [name=" + name + ", clientId=" + req.clientId() + fut.onDone(new IgniteCheckedException("Failed to marshal task result: " + desc.result(), e)); fut.onDone(new IgniteCheckedException("Failed to execute task (see server logs for details)."));
/** * Converts exception, but unlike {@link #convertException(IgniteCheckedException)} * does not wrap passed in exception if none suitable converter found. * * @param e Ignite checked exception. * @return Ignite runtime exception. */ public static Exception convertExceptionNoWrap(IgniteCheckedException e) { C1<IgniteCheckedException, IgniteException> converter = exceptionConverters.get(e.getClass()); if (converter != null) return converter.apply(e); if (e.getCause() instanceof IgniteException) return (Exception)e.getCause(); return e; }
/** * @param e Ignite checked exception. * @return CacheException runtime exception, never null. */ public static @NotNull RuntimeException convertToCacheException(IgniteCheckedException e) { IgniteClientDisconnectedCheckedException disconnectedErr = e.getCause(IgniteClientDisconnectedCheckedException.class); if (disconnectedErr != null) { assert disconnectedErr.reconnectFuture() != null : disconnectedErr; e = disconnectedErr; } if (e.hasCause(CacheWriterException.class)) return new CacheWriterException(U.convertExceptionNoWrap(e)); if (e instanceof CachePartialUpdateCheckedException) return new CachePartialUpdateException((CachePartialUpdateCheckedException)e); else if (e.hasCause(ClusterTopologyServerNotFoundException.class)) return new CacheServerNotFoundException(e.getMessage(), e); else if (e instanceof SchemaOperationException) return new CacheException(e.getMessage(), e); CacheException ce = X.cause(e, CacheException.class); if (ce != null) return ce; if (e.getCause() instanceof NullPointerException) return (NullPointerException)e.getCause(); if (e.getCause() instanceof SecurityException) return (SecurityException)e.getCause(); C1<IgniteCheckedException, IgniteException> converter = U.getExceptionConverter(e.getClass()); return converter != null ? new CacheException(converter.apply(e)) : new CacheException(e); }
@Override public IgniteException apply(IgniteCheckedException e) { return new IgniteInterruptedException(e.getMessage(), (InterruptedException)e.getCause()); } });