/** * 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; }
/** * 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); } }
/** * Sends response to remote node. * * @param nodeId Node ID to send response to. * @param msg Message to send. */ private void sendResponse(UUID nodeId, IgfsCommunicationMessage msg) { try { sendWithRetries(nodeId, msg); } catch (IgniteCheckedException e) { if (e.hasCause(ClusterTopologyCheckedException.class)) { if (log.isDebugEnabled()) log.debug("Failed to send sync response to IGFS fragmentizer coordinator " + "(originating node left the grid): " + nodeId); } else U.error(log, "Failed to send sync response to IGFS fragmentizer coordinator: " + nodeId, e); } } }
/** * @throws Exception If failed. */ @Test public void testHasCause() throws Exception { IgniteCheckedException me = prepareMultiException(); assertFalse(me.hasCause(IOException.class)); assertTrue(me.hasCause(IgniteCheckedException.class)); assertTrue(me.hasCause(IllegalArgumentException.class)); }
/** * Called when all required finish messages are received, * send ACK message to complete operation futures on all nodes. * * @param opId Operation ID. * @param err Error. */ private void onFinishOperation(IgniteUuid opId, IgniteCheckedException err) { try { UserAcceptedMessage msg = new UserAcceptedMessage(opId, err); ctx.discovery().sendCustomEvent(msg); } catch (IgniteCheckedException e) { if (!e.hasCause(IgniteFutureCancelledException.class)) U.error(log, "Unexpected exception on send UserAcceptedMessage.", e); } }
/** * 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 desc Process descriptor. * @return Client. * @throws IgniteCheckedException If failed. */ @Nullable protected HadoopCommunicationClient createNioClient(HadoopProcessDescriptor desc) throws IgniteCheckedException { assert desc != null; int shmemPort = desc.sharedMemoryPort(); // If remote node has shared memory server enabled and has the same set of MACs // then we are likely to run on the same host and shared memory communication could be tried. if (shmemPort != -1 && locProcDesc.parentNodeId().equals(desc.parentNodeId())) { try { return createShmemClient(desc, shmemPort); } catch (IgniteCheckedException e) { if (e.hasCause(IpcOutOfSystemResourcesException.class)) // Has cause or is itself the IpcOutOfSystemResourcesException. LT.warn(log, OUT_OF_RESOURCES_TCP_MSG); else if (log.isDebugEnabled()) log.debug("Failed to establish shared memory connection with local hadoop process: " + desc); } } return createTcpClient(desc); }
if (e.hasCause(ClusterTopologyCheckedException.class)) { if (log.isDebugEnabled()) log.debug("Failed to send fragmentizer request to remote node (node left grid): " +
if (e.hasCause(ClusterTopologyCheckedException.class)) { if (log.isDebugEnabled()) log.debug("Failed to send sync message to remote node (node has left the grid): " +
/** * @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); }
if (!e.hasCause(IgniteFutureCancelledException.class)) U.error(log, "Unexpected exception on wait for end of user operation.", e);
else if (e.hasCause(ClusterTopologyCheckedException.class)) { ClusterTopologyCheckedException topEx = X.cause(e, ClusterTopologyCheckedException.class); else if (e.hasCause(ClusterGroupEmptyCheckedException.class)) { ClusterGroupEmptyCheckedException ex = X.cause(e, ClusterGroupEmptyCheckedException.class);
if (i < 9 && e.hasCause(BindException.class)) { log.error("Failed to start server, will try another port [err=" + e + ", port=" + srvPort + ']');
if (e.hasCause(IpcOutOfSystemResourcesException.class))
if (i < 9 && e.hasCause(BindException.class)) { log.error("Failed to start server, will try another port [err=" + e + ", port=" + srvPort + ']');
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() +
if (e.hasCause(ClusterTopologyCheckedException.class)) { if (log.isDebugEnabled()) log.debug("Failed to process fragmentizer request (remote node left the grid) " +
if (log.isDebugEnabled() || !e.hasCause(SQLException.class)) U.error(log, "Failed to run fields query [qry=" + qryInfo + ", node=" + cctx.nodeId() + ']', e); else { if (e.hasCause(SQLException.class)) U.error(log, "Failed to run fields query [node=" + cctx.nodeId() + ", msg=" + e.getCause(SQLException.class).getMessage() + ']');
if (!failoverSafe && e.hasCause(InterruptedException.class)) info("Ignored expected exception: " + e); else