List of usage examples for java.util.concurrent ConcurrentNavigableMap keySet
NavigableSet<K> keySet();
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 .j ava 2s . co m } }
From source file:voldemort.store.cachestore.impl.SortedCacheStore.java
public List<KeyValue> scan(Key from, Key to) { Key floor = findFloorKey(getSkipListMap(map), from); Key ceil = findCeilKey(getSkipListMap(map), to); ConcurrentNavigableMap<Key, CacheBlock> subMap = getSkipListMap(map).subMap(floor, true, ceil, true); if (subMap != null) { int j = 0; List<KeyValue> list = new ArrayList<KeyValue>(subMap.size()); Iterator<Key> keyIt = subMap.keySet().iterator(); for (int i = 0; i < subMap.size(); i++) { Key key = keyIt.next(); if (key != null && !skipKey(key, from, to)) { Value value = super.get(key); if (value != null) { list.add(new KeyValue(key, value)); j++;/* w w w . j a va 2 s.c om*/ } } if (j > MAX_SIZE) { logger.warn("exceed max list size " + MAX_SIZE); break; } } return list; } return null; }
From source file:com.sm.store.server.RemoteScanStore.java
protected Iterator getIterator(CursorPara cursorPara) { if (cursorPara.getCursorType() == CursorPara.CursorType.Scan) { Key floor = getSortedStore().findFloorKey(getSortedStore().getSkipListMap(), cursorPara.getFrom()); Key ceil = getSortedStore().findCeilKey(getSortedStore().getSkipListMap(), cursorPara.getTo()); //empty map return null if (floor == null || ceil == null) { return null; }/* w ww. j a v a2 s. co m*/ ConcurrentNavigableMap<Key, CacheBlock> subMap = getSortedStore().getSkipListMap().subMap(floor, true, ceil, true); return subMap.keySet().iterator(); } else { if (isSorted) return getSortedStore().getSkipListMap().keySet().iterator(); else return getStore().getMap().keySet().iterator(); } }
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();// w ww . j a v a 2 s. c om 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; }
From source file:com.palantir.atlasdb.transaction.impl.SerializableTransaction.java
private NavigableMap<Cell, byte[]> getReadsInRange(String table, Entry<RangeRequest, byte[]> e, RangeRequest range) {/*from www . ja v a 2 s . com*/ NavigableMap<Cell, byte[]> reads = getReadsForTable(table); if (range.getStartInclusive().length != 0) { reads = reads.tailMap(Cells.createSmallestCellForRow(range.getStartInclusive()), true); } if (range.getEndExclusive().length != 0) { reads = reads.headMap(Cells.createSmallestCellForRow(range.getEndExclusive()), false); } ConcurrentNavigableMap<Cell, byte[]> writes = writesByTable.get(table); if (writes != null) { reads = Maps.filterKeys(reads, Predicates.not(Predicates.in(writes.keySet()))); } return reads; }
From source file:com.palantir.atlasdb.transaction.impl.SerializableTransaction.java
private void verifyCells(Transaction ro) { for (String table : cellsRead.keySet()) { final ConcurrentNavigableMap<Cell, byte[]> readsForTable = getReadsForTable(table); for (Iterable<Cell> batch : Iterables.partition(cellsRead.get(table), 1000)) { if (writesByTable.get(table) != null) { // We don't want to verify any reads that we wrote to cause we will just read our own values. // NB: If the value has changed between read and write, our normal SI checking handles this case batch = Iterables.filter(batch, Predicates.not(Predicates.in(writesByTable.get(table).keySet()))); }//w w w. jav a 2 s . c om ImmutableSet<Cell> batchSet = ImmutableSet.copyOf(batch); Map<Cell, byte[]> currentBatch = ro.get(table, batchSet); ImmutableMap<Cell, byte[]> originalReads = Maps.toMap( Sets.intersection(batchSet, readsForTable.keySet()), Functions.forMap(readsForTable)); if (!areMapsEqual(currentBatch, originalReads)) { throw TransactionSerializableConflictException.create(table, getTimestamp(), System.currentTimeMillis() - timeCreated); } } } }