Example usage for java.util.concurrent ConcurrentNavigableMap get

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

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.whizzosoftware.hobson.mqtt.MQTTPlugin.java

protected void restoreDevices() {
    ConcurrentNavigableMap<String, String> devices = db.getTreeMap("devices");
    for (String id : devices.keySet()) {
        JSONObject json = new JSONObject(new JSONTokener(devices.get(id)));
        MQTTDevice d = new MQTTDevice(this, json);
        // since the device has never technically checked-in, delete the default check-in time
        d.setDeviceAvailability(false, null);
        publishDevice(d);/*from  w w  w  .  ja v  a  2 s. co m*/
    }
}

From source file:org.apache.hama.graph.IncomingVertexMessageManager.java

public List<GraphJobMessage> getRelevantMessages(String peerName) {
    HashPartitioner<WritableComparable, IntWritable> partitioner = new HashPartitioner();
    List<GraphJobMessage> msgs = new ArrayList<GraphJobMessage>();
    ConcurrentNavigableMap<WritableComparable, List<WritableComparable>> offsetMap = msgPerVertex
            .getVertexIdOffsetMap();/*from   w w  w  . java2 s.  co m*/
    HashMap<WritableComparable, GraphJobMessage> aggregatorMap = msgPerVertex.getMessageAggregatorMap();
    if (offsetMap.size() != aggregatorMap.size()) {
        LOG.info("[ERROR IncomingVertexManager.java] Size mismatch!");
    }

    for (WritableComparable<?> dstVertexId : offsetMap.keySet()) {

        List<WritableComparable> list = offsetMap.get(dstVertexId);
        GraphJobMessage aggregatorGraphMsg = aggregatorMap.get(dstVertexId);
        byte[] valueArray = aggregatorGraphMsg.getValuesBytes();
        int messageSizeBytes = valueArray.length / aggregatorGraphMsg.getNumOfValues();

        Iterator<WritableComparable> it = list.iterator();
        Iterator<Writable> aggregateIt = aggregatorGraphMsg.getIterableMessages().iterator();
        while (it.hasNext()) {
            WritableComparable srcId = it.next();
            int partition = partitioner.getPartition(srcId, null, peer.getNumPeers());
            String srcPeer = peer.getAllPeerNames()[partition];
            if (srcPeer.equals(peerName)) {
                GraphJobMessage newMsg = new GraphJobMessage(dstVertexId, aggregateIt.next(), srcId);
                msgs.add(newMsg);
            } else {
                aggregateIt.next();
            }
        }
    }
    return msgs;
}