static <I extends DataItem, O extends DataIoTask<I>> FileChannel openSrcFile(final O ioTask) { String srcPath = ioTask.getSrcPath(); if(srcPath == null || srcPath.isEmpty()) { return null; } if(srcPath.startsWith("/")) { srcPath = srcPath.substring(1); } final String fileItemName = ioTask.getItem().getName(); final Path srcFilePath = srcPath.isEmpty() || fileItemName.startsWith(srcPath) ? FS.getPath(fileItemName) : FS.getPath(srcPath, fileItemName); try { return FS_PROVIDER.newFileChannel(srcFilePath, READ_OPEN_OPT); } catch(final IOException e) { LogUtil.exception(Level.WARN, e, "Failed to open the source channel for the path @ \"{}\"", srcFilePath); ioTask.setStatus(IoTask.Status.FAIL_IO); return null; } }
ioTask.setStatus(IoTask.Status.RESP_FAIL_AUTH); LogUtil.exception(Level.DEBUG, e, "Access denied to open the output channel for the path \"{}\"", dstPath); } catch(final NoSuchFileException e) { ioTask.setStatus(IoTask.Status.FAIL_IO); LogUtil.exception(Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", dstPath); } catch(final FileSystemException e) { final long freeSpace = (new File(e.getFile())).getFreeSpace(); if(freeSpace > 0) { ioTask.setStatus(IoTask.Status.FAIL_IO); LogUtil.exception(Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", dstPath); } else { ioTask.setStatus(IoTask.Status.RESP_FAIL_SPACE); LogUtil.exception(Level.DEBUG, e, "No free space for the path \"{}\"", dstPath); ioTask.setStatus(IoTask.Status.FAIL_IO); LogUtil.exception(Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", dstPath); } catch(final Throwable cause) { ioTask.setStatus(IoTask.Status.FAIL_UNKNOWN); LogUtil.exception(Level.WARN, cause, "Failed to open the output channel for the path \"{}\"", dstPath);
srcFilePath ); ioTask.setStatus(Status.FAIL_IO); return null; ioTask.setStatus(Status.RESP_FAIL_AUTH); LogUtil.exception( Level.DEBUG, e, "Access denied to open the output channel for the path \"{}\"", ); } catch(final NoSuchFileException e) { ioTask.setStatus(Status.FAIL_IO); LogUtil.exception( Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", dstPath final long freeSpace = (new File(e.getFile())).getFreeSpace(); if(freeSpace > 0) { ioTask.setStatus(Status.FAIL_IO); LogUtil.exception( Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", ); } else { ioTask.setStatus(Status.RESP_FAIL_SPACE); LogUtil.exception(Level.DEBUG, e, "No free space for the path \"{}\"", dstPath); ioTask.setStatus(Status.FAIL_IO); LogUtil.exception( Level.DEBUG, e, "Failed to open the output channel for the path \"{}\"", dstPath
ioTask.setStatus(Status.RESP_FAIL_CORRUPT); final long countBytesDone = ioTask.getCountBytesDone() + e.getOffset(); ); } catch(final DataCorruptionException e) { ioTask.setStatus(Status.RESP_FAIL_CORRUPT); final long countBytesDone = ioTask.getCountBytesDone() + e.getOffset(); ioTask.setStatus(Status.FAIL_UNKNOWN); Loggers.ERR.fatal("Unknown load type \"{}\"", ioType); break; ioTask.setStatus(Status.RESP_FAIL_NOT_FOUND); } catch(final AccessDeniedException e) { LogUtil.exception(Level.WARN, e, ioTask.toString()); ioTask.setStatus(Status.RESP_FAIL_AUTH); } catch(final ClosedChannelException e) { ioTask.setStatus(Status.INTERRUPTED); } catch(final IOException e) { LogUtil.exception(Level.WARN, e, ioTask.toString()); ioTask.setStatus(Status.FAIL_IO); } catch(final NullPointerException e) { if(!isClosed()) { // shared content source may be already closed from the load generator e.printStackTrace(System.out); ioTask.setStatus(Status.FAIL_UNKNOWN); } else { Loggers.ERR.debug("I/O task caused NPE while being interrupted: {}", ioTask);
ioTask.setStatus(Status.RESP_FAIL_CORRUPT); final long countBytesDone = ioTask.getCountBytesDone() + e.getOffset(); ioTask.setCountBytesDone(countBytesDone); ); } catch(final DataCorruptionException e) { ioTask.setStatus(Status.RESP_FAIL_CORRUPT); final long countBytesDone = ioTask.getCountBytesDone() + e.getOffset(); ioTask.setCountBytesDone(countBytesDone); ioTask.setStatus(Status.FAIL_UNKNOWN); Loggers.ERR.fatal("Unknown load type \"{}\"", ioType); break; ioTask.setStatus(Status.RESP_FAIL_NOT_FOUND); } catch(final AccessDeniedException e) { LogUtil.exception(Level.WARN, e, ioTask.toString()); ioTask.setStatus(Status.RESP_FAIL_AUTH); } catch(final ClosedChannelException e) { ioTask.setStatus(Status.INTERRUPTED); } catch(final IOException e) { LogUtil.exception(Level.WARN, e, ioTask.toString()); ioTask.setStatus(Status.FAIL_IO); } catch(final NullPointerException e) { if(! isClosed()) { // shared content source may be already closed from the load generator e.printStackTrace(System.out); ioTask.setStatus(Status.FAIL_UNKNOWN); } else { Loggers.ERR.debug("I/O task caused NPE while being interrupted: {}", ioTask);
final DataItem dataItem = dataIoTask.getItem(); dataIoTask.setCountBytesDone(e.getOffset()); dataIoTask.setStatus(IoTask.Status.RESP_FAIL_CORRUPT); if(e instanceof DataSizeException) { try {
ioTask.setStatus(Status.RESP_FAIL_CORRUPT); countBytesDone += e.getOffset(); ioTask.setCountBytesDone(countBytesDone);