Example usage for java.util HashSet HashSet

List of usage examples for java.util HashSet HashSet

Introduction

In this page you can find the example usage for java.util HashSet HashSet.

Prototype

public HashSet() 

Source Link

Document

Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).

Usage

From source file:SetDemo.java

public static void main(String[] argv) {
    //+/*from  w w  w  . j a v  a 2 s.com*/
    Set h = new HashSet();
    h.add("One");
    h.add("Two");
    h.add("One"); // DUPLICATE
    h.add("Three");
    Iterator it = h.iterator();
    while (it.hasNext()) {
        System.out.println(it.next());
    }
    //-
}

From source file:ListAlgorithms.java

public static void main(String[] args) {
    Provider[] providers = Security.getProviders();
    Set<String> ciphers = new HashSet<String>();
    Set<String> keyAgreements = new HashSet<String>();
    Set<String> macs = new HashSet<String>();
    Set<String> messageDigests = new HashSet<String>();
    Set<String> signatures = new HashSet<String>();

    for (int i = 0; i != providers.length; i++) {
        Iterator it = providers[i].keySet().iterator();

        while (it.hasNext()) {
            String entry = (String) it.next();

            if (entry.startsWith("Alg.Alias.")) {
                entry = entry.substring("Alg.Alias.".length());
            }//from w w  w. j a  va2s. c  om

            if (entry.startsWith("Cipher.")) {
                ciphers.add(entry.substring("Cipher.".length()));
            } else if (entry.startsWith("KeyAgreement.")) {
                keyAgreements.add(entry.substring("KeyAgreement.".length()));
            } else if (entry.startsWith("Mac.")) {
                macs.add(entry.substring("Mac.".length()));
            } else if (entry.startsWith("MessageDigest.")) {
                messageDigests.add(entry.substring("MessageDigest.".length()));
            } else if (entry.startsWith("Signature.")) {
                signatures.add(entry.substring("Signature.".length()));
            }
        }
    }

    printSet("Ciphers", ciphers);
    printSet("KeyAgreeents", keyAgreements);
    printSet("Macs", macs);
    printSet("MessageDigests", messageDigests);
    printSet("Signatures", signatures);
}

From source file:com.apipulse.bastion.Main.java

public static void main(String[] args) throws IOException, ClassNotFoundException {
    log.info("Bastion starting. Loading chains");
    final File dir = new File("etc/chains");

    final LinkedList<ActorRef> chains = new LinkedList<ActorRef>();
    for (File file : dir.listFiles()) {
        if (!file.getName().startsWith(".") && file.getName().endsWith(".yaml")) {
            log.info("Loading chain: " + file.getName());
            ChainConfig config = new ChainConfig(IOUtils.toString(new FileReader(file)));
            ActorRef ref = BastionActors.getInstance().initChain(config.getName(),
                    Class.forName(config.getQualifiedClass()));
            Iterator<StageConfig> iterator = config.getStages().iterator();
            while (iterator.hasNext())
                ref.tell(iterator.next(), null);
            chains.add(ref);/*from   w  ww.  jav  a2s . c  om*/
        }
    }
    SpringApplication app = new SpringApplication();
    HashSet<Object> objects = new HashSet<Object>();
    objects.add(ApiController.class);
    final ConfigurableApplicationContext context = app.run(ApiController.class, args);
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                log.info("Bastion shutting down");
                Iterator<ActorRef> iterator = chains.iterator();
                while (iterator.hasNext())
                    iterator.next().tell(new StopMessage(), null);
                Thread.sleep(2000);
                context.stop();
                log.info("Bastion shutdown complete");
            } catch (Exception e) {
            }
        }
    });
}

From source file:module.entities.UsernameChecker.CheckOpengovUsernames.java

/**
 * @param args the command line arguments
 *//*w w  w.j a va  2s.c  o  m*/
public static void main(String[] args) throws SQLException, IOException {
    //        args = new String[1];
    //        args[0] = "searchConf.txt";
    Date d = new Date();
    long milTime = d.getTime();
    long execStart = System.nanoTime();
    Timestamp startTime = new Timestamp(milTime);
    long lStartTime;
    long lEndTime = 0;
    int status_id = 1;
    JSONObject obj = new JSONObject();
    if (args.length != 1) {
        System.out.println("None or too many argument parameters where defined! "
                + "\nPlease provide ONLY the configuration file name as the only argument.");
    } else {
        try {
            configFile = args[0];
            initLexicons();
            Database.init();
            lStartTime = System.currentTimeMillis();
            System.out.println("Opengov username identification process started at: " + startTime);
            usernameCheckerId = Database.LogUsernameChecker(lStartTime);
            TreeMap<Integer, String> OpenGovUsernames = Database.GetOpenGovUsers();
            HashSet<ReportEntry> report_names = new HashSet<>();
            if (OpenGovUsernames.size() > 0) {
                for (int userID : OpenGovUsernames.keySet()) {
                    String DBusername = Normalizer
                            .normalize(OpenGovUsernames.get(userID).toUpperCase(locale), Normalizer.Form.NFD)
                            .replaceAll("\\p{M}", "");
                    String username = "";
                    int type;
                    String[] splitUsername = DBusername.split(" ");
                    if (checkNameInLexicons(splitUsername)) {
                        for (String splText : splitUsername) {
                            username += splText + " ";
                        }
                        type = 1;
                    } else if (checkOrgInLexicons(splitUsername)) {
                        for (String splText : splitUsername) {
                            username += splText + " ";
                        }
                        type = 2;
                    } else {
                        username = DBusername;
                        type = -1;
                    }
                    ReportEntry cerEntry = new ReportEntry(userID, username.trim(), type);
                    report_names.add(cerEntry);
                }
                status_id = 2;
                obj.put("message", "Opengov username checker finished with no errors");
                obj.put("details", "");
                Database.UpdateOpengovUsersReportName(report_names);
                lEndTime = System.currentTimeMillis();
            } else {
                status_id = 2;
                obj.put("message", "Opengov username checker finished with no errors");
                obj.put("details", "No usernames needed to be checked");
                lEndTime = System.currentTimeMillis();
            }
        } catch (Exception ex) {
            System.err.println(ex.getMessage());
            status_id = 3;
            obj.put("message", "Opengov username checker encountered an error");
            obj.put("details", ex.getMessage().toString());
            lEndTime = System.currentTimeMillis();
        }
    }
    long execEnd = System.nanoTime();
    long executionTime = (execEnd - execStart);
    System.out.println("Total process time: " + (((executionTime / 1000000) / 1000) / 60) + " minutes.");
    Database.UpdateLogUsernameChecker(lEndTime, status_id, usernameCheckerId, obj);
    Database.closeConnection();
}

From source file:jrrombaldo.pset.PSETMain.java

public static void main(String[] args) {

    Options options = prepareOptions();/*from w ww  . ja v  a 2  s  . c  o  m*/
    CommandLineParser parser = new DefaultParser();
    try {
        CommandLine line = parser.parse(options, args);

        String domain = line.getOptionValue("d");

        // print help
        if (line.hasOption("h")) {
            printHelp(options);
            return;
        }

        // start gui e do nothing else
        if (!line.hasOption("c")) {
            startGuiVersion(domain);
            return;
        }

        // start gui e do nothing else
        if (!line.hasOption("d")) {
            System.out.println("a target domain is required, none was specified!");
            printHelp(options);
            return;
        }

        if (!line.hasOption("g") && !line.hasOption("b")) {
            System.out.println("No search engine selected, at least one should be present");
            printHelp(options);
            return;
        }

        if (line.hasOption("p")) {
            String proxy = line.getOptionValue("p");
            System.out.println(proxy);
        }

        Set<String> results = new HashSet<>();

        if (line.hasOption("g")) {
            results.addAll(new GoogleSearch(domain).listSubdomains());
        }

        if (line.hasOption("b")) {
            results.addAll(new BingSearch(domain).listSubdomains());
        }

        List<String> sortedResult = new ArrayList<String>(results);
        Collections.sort(sortedResult);
        int q = 1;
        for (String subDomain : sortedResult) {
            if (q == 1) {
                System.out.println("\nResults:");
            }
            System.out.println(q + ": " + subDomain);
            q++;
        }

    } catch (ParseException exp) {
        System.out.println(exp.getLocalizedMessage());
        printHelp(options);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:mase.deprecated.SelectionBenchmark.java

public static void main(String[] args) {

    int L = 100, N = 10000;
    double[] truncationP = new double[] { 0.25, 0.50, 0.75 };
    int[] tournamentP = new int[] { 2, 5, 7, 10 };

    DescriptiveStatistics[] truncationStat = new DescriptiveStatistics[truncationP.length];
    for (int i = 0; i < truncationStat.length; i++) {
        truncationStat[i] = new DescriptiveStatistics();
    }// w  w w.ja v  a  2s  .  c  o  m
    DescriptiveStatistics[] tournamentStat = new DescriptiveStatistics[tournamentP.length];
    DescriptiveStatistics[] tournamentStat2 = new DescriptiveStatistics[tournamentP.length];
    for (int i = 0; i < tournamentStat.length; i++) {
        tournamentStat[i] = new DescriptiveStatistics();
        tournamentStat2[i] = new DescriptiveStatistics();
    }
    DescriptiveStatistics rouletteStat = new DescriptiveStatistics();
    DescriptiveStatistics rouletteStat2 = new DescriptiveStatistics();
    DescriptiveStatistics baseStat = new DescriptiveStatistics();

    for (int i = 0; i < N; i++) {
        // generate test vector
        double[] test = new double[L];
        for (int j = 0; j < L; j++) {
            test[j] = Math.random();
        }

        // truncation
        for (int p = 0; p < truncationP.length; p++) {
            double[] v = Arrays.copyOf(test, test.length);
            Arrays.sort(v);
            int nElites = (int) Math.ceil(truncationP[p] * test.length);
            double cutoff = v[test.length - nElites];
            double[] weights = new double[test.length];
            for (int k = 0; k < test.length; k++) {
                weights[k] = test[k] >= cutoff ? test[k] * (1 / truncationP[p]) : 0;
            }
            truncationStat[p].addValue(sum(weights));
        }

        // tournament
        for (int p = 0; p < tournamentP.length; p++) {
            double[] weights = new double[test.length];
            HashSet<Integer> added = new HashSet<Integer>();
            for (int k = 0; k < test.length; k++) {
                int idx = makeTournament(test, tournamentP[p]);
                weights[idx] += test[idx];
                added.add(idx);
            }
            tournamentStat2[p].addValue(added.size());
            tournamentStat[p].addValue(sum(weights));
        }

        // roulette
        double[] weights = new double[test.length];
        HashSet<Integer> added = new HashSet<Integer>();
        for (int k = 0; k < test.length; k++) {
            int idx = roulette(test);
            weights[idx] += test[idx];
            added.add(idx);
        }
        rouletteStat.addValue(sum(weights));
        rouletteStat2.addValue(added.size());

        // base
        baseStat.addValue(sum(test));
    }

    for (int p = 0; p < truncationP.length; p++) {
        System.out.println("Truncation\t" + truncationP[p] + "\t" + truncationStat[p].getMean() + "\t"
                + truncationStat[p].getStandardDeviation() + "\t" + ((int) Math.ceil(L * truncationP[p]))
                + "\t 0");
    }
    for (int p = 0; p < tournamentP.length; p++) {
        System.out.println("Tournament\t" + tournamentP[p] + "\t" + tournamentStat[p].getMean() + "\t"
                + tournamentStat[p].getStandardDeviation() + "\t" + tournamentStat2[p].getMean() + "\t"
                + tournamentStat2[p].getStandardDeviation());
    }
    System.out.println("Roulette\t\t" + rouletteStat.getMean() + "\t" + rouletteStat.getStandardDeviation()
            + "\t" + rouletteStat2.getMean() + "\t" + rouletteStat2.getStandardDeviation());
    System.out.println(
            "Base    \t\t" + baseStat.getMean() + "\t" + baseStat.getStandardDeviation() + "\t " + L + "\t0");
}

From source file:eu.fbk.dkm.sectionextractor.PageClassMerger.java

public static void main(String args[]) throws IOException {

    CommandLineWithLogger commandLineWithLogger = new CommandLineWithLogger();
    commandLineWithLogger.addOption(OptionBuilder.withArgName("file").hasArg()
            .withDescription("WikiData ID file").isRequired().withLongOpt("wikidata-id").create("i"));
    commandLineWithLogger.addOption(OptionBuilder.withArgName("file").hasArg()
            .withDescription("Airpedia Person file").isRequired().withLongOpt("airpedia").create("a"));
    commandLineWithLogger.addOption(OptionBuilder.withArgName("file").hasArg().withDescription("Output file")
            .isRequired().withLongOpt("output").create("o"));
    CommandLine commandLine = null;// w ww.j  ava 2 s  . com
    try {
        commandLine = commandLineWithLogger.getCommandLine(args);
        PropertyConfigurator.configure(commandLineWithLogger.getLoggerProps());
    } catch (Exception e) {
        System.exit(1);
    }

    String wikiIDFileName = commandLine.getOptionValue("wikidata-id");
    String airpediaFileName = commandLine.getOptionValue("airpedia");
    String outputFileName = commandLine.getOptionValue("output");

    HashMap<Integer, String> wikiIDs = new HashMap<>();
    HashSet<Integer> airpediaClasses = new HashSet<>();

    List<String> strings;

    logger.info("Loading file " + wikiIDFileName);
    strings = Files.readLines(new File(wikiIDFileName), Charsets.UTF_8);
    for (String line : strings) {
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }
        if (line.startsWith("#")) {
            continue;
        }

        String[] parts = line.split("\t");
        if (parts.length < 2) {
            continue;
        }

        int id;
        try {
            id = Integer.parseInt(parts[0]);
        } catch (Exception e) {
            continue;
        }
        wikiIDs.put(id, parts[1]);
    }

    logger.info("Loading file " + airpediaFileName);
    strings = Files.readLines(new File(airpediaFileName), Charsets.UTF_8);
    for (String line : strings) {
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }
        if (line.startsWith("#")) {
            continue;
        }

        String[] parts = line.split("\t");
        if (parts.length < 2) {
            continue;
        }

        int id;
        try {
            id = Integer.parseInt(parts[0]);
        } catch (Exception e) {
            continue;
        }
        airpediaClasses.add(id);
    }

    logger.info("Saving information");
    BufferedWriter writer = new BufferedWriter(new FileWriter(outputFileName));
    for (int i : wikiIDs.keySet()) {
        if (!airpediaClasses.contains(i)) {
            continue;
        }

        writer.append(wikiIDs.get(i)).append("\n");
    }
    writer.close();
}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.CollectionDiffer.java

public static void main(String[] args) {
    Options options = new Options();

    options.addOption("i1", null, true, "Input file 1");
    options.addOption("i2", null, true, "Input file 2");
    options.addOption("o", null, true, "Output file");

    CommandLineParser parser = new org.apache.commons.cli.GnuParser();

    try {/*from  w  ww  .  j  av  a  2 s . c  o  m*/
        CommandLine cmd = parser.parse(options, args);

        InputStream input1 = null, input2 = null;

        if (cmd.hasOption("i1")) {
            input1 = CompressUtils.createInputStream(cmd.getOptionValue("i1"));
        } else {
            Usage("Specify 'Input file 1'");
        }
        if (cmd.hasOption("i2")) {
            input2 = CompressUtils.createInputStream(cmd.getOptionValue("i2"));
        } else {
            Usage("Specify 'Input file 2'");
        }

        HashSet<String> hSubj = new HashSet<String>();

        BufferedWriter out = null;

        if (cmd.hasOption("o")) {
            String outFile = cmd.getOptionValue("o");

            out = new BufferedWriter(new OutputStreamWriter(CompressUtils.createOutputStream(outFile)));
        } else {
            Usage("Specify 'Output file'");
        }

        XmlIterator inpIter2 = new XmlIterator(input2, YahooAnswersReader.DOCUMENT_TAG);

        int docNum = 1;
        for (String oneRec = inpIter2.readNext(); !oneRec.isEmpty(); oneRec = inpIter2.readNext(), ++docNum) {
            if (docNum % 10000 == 0) {
                System.out.println(String.format(
                        "Loaded and memorized questions for %d documents from the second input file", docNum));
            }
            ParsedQuestion q = YahooAnswersParser.parse(oneRec, false);
            hSubj.add(q.mQuestion);
        }

        XmlIterator inpIter1 = new XmlIterator(input1, YahooAnswersReader.DOCUMENT_TAG);

        System.out.println("=============================================");
        System.out.println("Memoization is done... now let's diff!!!");
        System.out.println("=============================================");

        docNum = 1;
        int skipOverlapQty = 0, skipErrorQty = 0;
        for (String oneRec = inpIter1.readNext(); !oneRec.isEmpty(); ++docNum, oneRec = inpIter1.readNext()) {
            if (docNum % 10000 == 0) {
                System.out.println(String.format("Processed %d documents from the first input file", docNum));
            }

            oneRec = oneRec.trim() + System.getProperty("line.separator");

            ParsedQuestion q = null;
            try {
                q = YahooAnswersParser.parse(oneRec, false);
            } catch (Exception e) {
                // If <bestanswer>...</bestanswer> is missing we may end up here...
                // This is a bit funny, because this element is supposed to be mandatory,
                // but it's not.
                System.err.println("Skipping due to parsing error, exception: " + e);
                skipErrorQty++;
                continue;
            }
            if (hSubj.contains(q.mQuestion.trim())) {
                //System.out.println(String.format("Skipping uri='%s', question='%s'", q.mQuestUri, q.mQuestion));
                skipOverlapQty++;
                continue;
            }

            out.write(oneRec);
        }
        System.out.println(
                String.format("Processed %d documents, skipped because of overlap/errors %d/%d documents",
                        docNum - 1, skipOverlapQty, skipErrorQty));
        out.close();
    } catch (ParseException e) {
        Usage("Cannot parse arguments");
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Terminating due to an exception: " + e);
        System.exit(1);
    }
}

From source file:com.jivesoftware.os.routing.bird.deployable.config.extractor.ConfigExtractor.java

public static void main(String[] args) {
    String configHost = args[0];/*  w  ww .  j av a  2  s.co  m*/
    String configPort = args[1];
    String instanceKey = args[2];
    String instanceVersion = args[3];
    String setPath = args[4];
    String getPath = args[5];

    HttpRequestHelper buildRequestHelper = buildRequestHelper(null, configHost, Integer.parseInt(configPort));

    try {
        Set<URL> packages = new HashSet<>();
        for (int i = 5; i < args.length; i++) {
            packages.addAll(ClasspathHelper.forPackage(args[i]));
        }

        Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(packages)
                .setScanners(new SubTypesScanner(), new TypesScanner()));

        Set<Class<? extends Config>> subTypesOf = reflections.getSubTypesOf(Config.class);

        File configDir = new File("./config");
        configDir.mkdirs();

        Set<Class<? extends Config>> serviceConfig = new HashSet<>();
        Set<Class<? extends Config>> healthConfig = new HashSet<>();
        for (Class<? extends Config> type : subTypesOf) {
            if (HealthCheckConfig.class.isAssignableFrom(type)) {
                healthConfig.add(type);
            } else {
                serviceConfig.add(type);
            }
        }

        Map<String, String> defaultServiceConfig = extractAndPublish(serviceConfig,
                new File(configDir, "default-service-config.properties"), "default", instanceKey,
                instanceVersion, buildRequestHelper, setPath);

        DeployableConfig getServiceOverrides = new DeployableConfig("override", instanceKey, instanceVersion,
                defaultServiceConfig);
        DeployableConfig gotSerivceConfig = buildRequestHelper.executeRequest(getServiceOverrides, getPath,
                DeployableConfig.class, null);
        if (gotSerivceConfig == null) {
            System.out.println("Failed to publish default service config for " + Arrays.deepToString(args));
        } else {
            Properties override = createKeySortedProperties();
            override.putAll(gotSerivceConfig.properties);
            override.store(new FileOutputStream("config/override-service-config.properties"), "");
        }

        Map<String, String> defaultHealthConfig = extractAndPublish(healthConfig,
                new File(configDir, "default-health-config.properties"), "default-health", instanceKey,
                instanceVersion, buildRequestHelper, setPath);

        DeployableConfig getHealthOverrides = new DeployableConfig("override-health", instanceKey,
                instanceVersion, defaultHealthConfig);
        DeployableConfig gotHealthConfig = buildRequestHelper.executeRequest(getHealthOverrides, getPath,
                DeployableConfig.class, null);
        if (gotHealthConfig == null) {
            System.out.println("Failed to publish default health config for " + Arrays.deepToString(args));
        } else {
            Properties override = createKeySortedProperties();
            override.putAll(gotHealthConfig.properties);
            override.store(new FileOutputStream("config/override-health-config.properties"), "");
        }

        Properties instanceProperties = createKeySortedProperties();
        File configFile = new File("config/instance.properties");
        if (configFile.exists()) {
            instanceProperties.load(new FileInputStream(configFile));
        }

        Properties serviceOverrideProperties = createKeySortedProperties();
        configFile = new File("config/override-service-config.properties");
        if (configFile.exists()) {
            serviceOverrideProperties.load(new FileInputStream(configFile));
        }

        Properties healthOverrideProperties = createKeySortedProperties();
        configFile = new File("config/override-health-config.properties");
        if (configFile.exists()) {
            healthOverrideProperties.load(new FileInputStream(configFile));
        }

        Properties properties = createKeySortedProperties();
        properties.putAll(defaultServiceConfig);
        properties.putAll(defaultHealthConfig);
        properties.putAll(serviceOverrideProperties);
        properties.putAll(healthOverrideProperties);
        properties.putAll(instanceProperties);
        properties.store(new FileOutputStream("config/config.properties"), "");

        System.exit(0);
    } catch (Exception x) {
        x.printStackTrace();
        System.exit(1);
    }

}

From source file:com.btoddb.fastpersitentqueue.speedtest.SpeedTest.java

public static void main(String[] args) throws Exception {
    if (0 == args.length) {
        System.out.println();/*from   w w w .ja v  a 2s  .c o  m*/
        System.out.println("ERROR: must specify the config file path/name");
        System.out.println();
        System.exit(1);
    }

    SpeedTestConfig config = SpeedTestConfig.create(args[0]);

    System.out.println(config.toString());

    File theDir = new File(config.getDirectory(), "speed-" + UUID.randomUUID().toString());
    FileUtils.forceMkdir(theDir);

    Fpq queue = config.getFpq();
    queue.setJournalDirectory(new File(theDir, "journals"));
    queue.setPagingDirectory(new File(theDir, "pages"));

    try {
        queue.init();

        //
        // start workers
        //

        AtomicLong counter = new AtomicLong();
        AtomicLong pushSum = new AtomicLong();
        AtomicLong popSum = new AtomicLong();

        long startTime = System.currentTimeMillis();

        Set<SpeedPushWorker> pushWorkers = new HashSet<SpeedPushWorker>();
        for (int i = 0; i < config.getNumberOfPushers(); i++) {
            pushWorkers.add(new SpeedPushWorker(queue, config, counter, pushSum));
        }

        Set<SpeedPopWorker> popWorkers = new HashSet<SpeedPopWorker>();
        for (int i = 0; i < config.getNumberOfPoppers(); i++) {
            popWorkers.add(new SpeedPopWorker(queue, config, popSum));
        }

        ExecutorService pusherExecSrvc = Executors.newFixedThreadPool(
                config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable runnable) {
                        Thread t = new Thread(runnable);
                        t.setName("SpeedTest-Pusher");
                        return t;
                    }
                });

        ExecutorService popperExecSrvc = Executors.newFixedThreadPool(
                config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable runnable) {
                        Thread t = new Thread(runnable);
                        t.setName("SpeedTest-Popper");
                        return t;
                    }
                });

        long startPushing = System.currentTimeMillis();
        for (SpeedPushWorker sw : pushWorkers) {
            pusherExecSrvc.submit(sw);
        }

        long startPopping = System.currentTimeMillis();
        for (SpeedPopWorker sw : popWorkers) {
            popperExecSrvc.submit(sw);
        }

        //
        // wait to finish
        //

        long endTime = startTime + config.getDurationOfTest() * 1000;
        long endPushing = 0;
        long displayTimer = 0;
        while (0 == endPushing || !queue.isEmpty()) {
            // display status every second
            if (1000 < (System.currentTimeMillis() - displayTimer)) {
                System.out.println(String.format("status (%ds) : journals = %d : memory segments = %d",
                        (endTime - System.currentTimeMillis()) / 1000,
                        queue.getJournalMgr().getJournalIdMap().size(),
                        queue.getMemoryMgr().getSegments().size()));
                displayTimer = System.currentTimeMillis();
            }

            pusherExecSrvc.shutdown();
            if (pusherExecSrvc.awaitTermination(100, TimeUnit.MILLISECONDS)) {
                endPushing = System.currentTimeMillis();
                // tell poppers, all pushers are finished
                for (SpeedPopWorker sw : popWorkers) {
                    sw.stopWhenQueueEmpty();
                }
            }
        }

        long endPopping = System.currentTimeMillis();

        popperExecSrvc.shutdown();
        popperExecSrvc.awaitTermination(10, TimeUnit.SECONDS);

        long numberOfPushes = 0;
        for (SpeedPushWorker sw : pushWorkers) {
            numberOfPushes += sw.getNumberOfEntries();
        }

        long numberOfPops = 0;
        for (SpeedPopWorker sw : popWorkers) {
            numberOfPops += sw.getNumberOfEntries();
        }

        long pushDuration = endPushing - startPushing;
        long popDuration = endPopping - startPopping;

        System.out.println("push - pop checksum = " + pushSum.get() + " - " + popSum.get() + " = "
                + (pushSum.get() - popSum.get()));
        System.out.println("push duration = " + pushDuration);
        System.out.println("pop duration = " + popDuration);
        System.out.println();
        System.out.println("pushed = " + numberOfPushes);
        System.out.println("popped = " + numberOfPops);
        System.out.println();
        System.out.println("push entries/sec = " + numberOfPushes / (pushDuration / 1000f));
        System.out.println("pop entries/sec = " + numberOfPops / (popDuration / 1000f));
        System.out.println();
        System.out.println("journals created = " + queue.getJournalsCreated());
        System.out.println("journals removed = " + queue.getJournalsRemoved());
    } finally {
        if (null != queue) {
            queue.shutdown();
        }
        //            FileUtils.deleteDirectory(theDir);
    }
}