Examples of DrainableExecutor


Examples of net.sourceforge.processdash.util.DrainableExecutor

    private void archiveDirectories(ZipOutputStream out) throws IOException {
        int numThreads = Settings.getInt("slowNetwork.numParallelReads", 10);
        ExecutorService service = Executors.newFixedThreadPool(
            Math.max(numThreads, 1));
        DrainableExecutor executor = new DrainableExecutor(service);
        exceptionEncountered = null;
        NumberFormat fmt = NumberFormat.getIntegerInstance();
        fmt.setMinimumIntegerDigits(3);

        Set<String> extDirNames = new HashSet<String>();
        extDirNames.add(null); extDirNames.add("");
        for (int i = 0; i < importInstructions.size(); i++) {
            ImportDirectoryInstruction instr = importInstructions.get(i);
            String newPath = getExtDirName(instr);
            if (extDirNames.contains(newPath))
                newPath = "extdir" + fmt.format(i + 1);
            extDirNames.add(newPath);
            executor.execute(new ArchiveDirectoryTask(executor, out, instr,
                    newPath));
        }

        executor.drain();

        if (exceptionEncountered != null)
            throw exceptionEncountered;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.