List of usage examples for java.util.concurrent ConcurrentNavigableMap descendingKeySet
NavigableSet<K> descendingKeySet();
From source file:actions.DownloadSPDX.java
/** * Gets the persistent storage working. This is necessary for keeping track * of what is currently being processed. If for some reason processing is * interrupted abruptly, on the next restart we can proceed from the last * saved point.//w w w . j a va 2s.c o m */ private void initializeQueueDB() { // assign the folder for our queue database File folder = new File(".", "queue"); // create the folder utils.files.mkdirs(folder); // get the database started dbQueue = DBMaker.newFileDB(new File(folder, "queue.db")).closeOnJvmShutdown().make(); System.out.println("Queue database initialized: " + folder.getAbsolutePath()); // now check for repositories on the queue that we are missing to launch ConcurrentNavigableMap<String, Long> map = dbQueue.getTreeMap("queue"); boolean hasQueue = false; for (String repository : map.descendingKeySet()) { hasQueue = true; System.out.println(repository); // Wait for a free slot while (hasFreeSlots() == false) { utils_deprecated.time.wait(5); } // launch the repository download System.out.println("Resuming: " + repository); launchNewDownload(repository, "github.com"); queueRemove(repository); } }
From source file:actions.RepDownload.java
/** * Gets the persistent storage working. This is necessary for keeping track * of what is currently being processed. If for some reason processing is * interrupted abruptly, on the next restart we can proceed from the last * saved point./*from ww w.j ava2 s . co m*/ */ private void initializeQueueDB() { // assign the folder for our queue database File folder = new File(".", "queue"); // create the folder utils_deprecated.files.mkdirs(folder); // get the database started dbQueue = DBMaker.newFileDB(new File(folder, "queue.db")).closeOnJvmShutdown().make(); System.out.println("Queue database initialized: " + folder.getAbsolutePath()); // now check for repositories on the queue that we are missing to launch ConcurrentNavigableMap<String, Long> map = dbQueue.getTreeMap("queue"); boolean hasQueue = false; for (String repository : map.descendingKeySet()) { hasQueue = true; System.out.println(repository); // Wait for a free slot while (hasFreeSlots() == false) { utils_deprecated.time.wait(5); } // launch the repository download System.out.println("Resuming: " + repository); launchNewDownload(repository, "github.com"); queueRemove(repository); } }