@Override @SuppressWarnings("unchecked") public final void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws IOException { final Channel channel = ctx.channel(); final O ioTask = (O) channel.attr(NetStorageDriver.ATTR_KEY_IOTASK).get(); if(ioTask != null) { if(driver.isInterrupted() || driver.isClosed()) { ioTask.setStatus(INTERRUPTED); } else if(cause instanceof PrematureChannelClosureException) { LogUtil.exception(Level.WARN, cause, "Premature channel closure"); ioTask.setStatus(FAIL_IO); } else { LogUtil.exception(Level.WARN, cause, "Client handler failure"); ioTask.setStatus(FAIL_UNKNOWN); } if(!driver.isInterrupted()) { try { driver.complete(channel, ioTask); } catch(final Exception e) { LogUtil.exception(Level.DEBUG, e, "Failed to complete the I/O task"); } } } }
protected void prepareIoTask(final O ioTask) throws ServerException { ioTask.reset(); if(ioTask instanceof DataIoTask) { ((DataIoTask) ioTask).getItem().setDataInput(itemDataInput); } final String dstPath = ioTask.getDstPath(); final Credential credential = ioTask.getCredential(); if(credential != null) { pathToCredMap.putIfAbsent(dstPath == null ? "" : dstPath, credential); if(requestAuthTokenFunc != null) { authTokens.computeIfAbsent(credential, requestAuthTokenFunc); } } if(requestNewPathFunc != null) { // NOTE: in the distributed mode null dstPath becomes empty one if(dstPath != null && !dstPath.isEmpty()) { if(null == pathMap.computeIfAbsent(dstPath, requestNewPathFunc)) { Loggers.ERR.debug( "Failed to compute the destination path for the I/O task {}", ioTask ); ioTask.setStatus(IoTask.Status.FAIL_UNKNOWN); } } } }
ioTask.finishRequest(); concurrencyThrottle.release(); ioTask.setStatus(SUCC); ioTask.startResponse(); complete(null, ioTask); } catch (final ConnectException e) { LogUtil.exception(Level.WARN, e, "Failed to lease the connection for the I/O task"); ioTask.setStatus(IoTask.Status.FAIL_IO); complete(null, ioTask);