Example usage for java.util.concurrent ConcurrentNavigableMap descendingKeySet

List of usage examples for java.util.concurrent ConcurrentNavigableMap descendingKeySet

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentNavigableMap descendingKeySet.

Prototype

NavigableSet<K> descendingKeySet();

Source Link

Document

Returns a reverse order NavigableSet view of the keys contained in this map.

Usage

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);
    }
}