@Override protected void copyFileToTarget(PathData src, PathData target) throws IOException { // if number of thread is 1, mimic put and avoid threading overhead if (numThreads == 1) { copyFile(src, target); return; } Runnable task = () -> { try { copyFile(src, target); } catch (IOException e) { displayError(e); } }; executor.submit(task); }
@Override protected void processPath(PathData src, PathData target) throws IOException { // unlike copy, don't merge existing dirs during move if (target.exists && target.stat.isDirectory()) { throw new PathExistsException(target.toString()); } super.processPath(src, target); }
@Override protected void processPath(PathData src, PathData target) throws IOException { // unlike copy, don't merge existing dirs during move if (target.exists && target.stat.isDirectory()) { throw new PathExistsException(target.toString()); } super.processPath(src, target); }
@Override protected void processPath(PathData src, PathData target) throws IOException { // unlike copy, don't merge existing dirs during move if (target.exists && target.stat.isDirectory()) { throw new PathExistsException(target.toString()); } super.processPath(src, target); }
@Override protected void processPath(PathData src, PathData target) throws IOException { // unlike copy, don't merge existing dirs during move if (target.exists && target.stat.isDirectory()) { throw new PathExistsException(target.toString()); } super.processPath(src, target); }
@Override protected void processArguments(LinkedList<PathData> args) throws IOException { executor = new ThreadPoolExecutor(numThreads, numThreads, 1, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1024), new ThreadPoolExecutor.CallerRunsPolicy()); super.processArguments(args); // issue the command and then wait for it to finish executor.shutdown(); try { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES); } catch (InterruptedException e) { executor.shutdownNow(); displayError(e); Thread.currentThread().interrupt(); } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "f", "p", "l", "d"); cf.addOptionWithValue("t"); cf.parse(args); setNumberThreads(cf.getOptValue("t")); setOverwrite(cf.getOpt("f")); setPreserve(cf.getOpt("p")); setLazyPersist(cf.getOpt("l")); setDirectWrite(cf.getOpt("d")); getRemoteDestination(args); // should have a -r option setRecursive(true); }
private void copyFile(PathData src, PathData target) throws IOException { if (isPathRecursable(src)) { throw new PathIsDirectoryException(src.toString()); } super.copyFileToTarget(src, target); }