List of usage examples for java.util.concurrent ConcurrentHashMap entrySet
EntrySetView entrySet
To view the source code for java.util.concurrent ConcurrentHashMap entrySet.
Click Source Link
From source file:uk.co.tfd.symplectic.harvester.SymplecticFetch.java
private void consumeTasks(ConcurrentHashMap<String, FutureTask<String>> worklist, ProgressTracker tracker) { for (Entry<String, FutureTask<String>> e : worklist.entrySet()) { if (e.getValue().isDone()) { try { LOGGER.info("Recieved " + e.getValue().get()); } catch (Exception e1) { LOGGER.info("Failed {} ", e.getKey(), e1); }/*from w w w. j a va2 s . c om*/ worklist.remove(e.getKey()); } } if (System.currentTimeMillis() > lastLog + 5000) { LOGGER.info("Current Worklist Backlog {} In Pending or Loading state {} ", worklist.size(), tracker.pending()); lastLog = System.currentTimeMillis(); } }
From source file:com.vmware.identity.idm.server.RsaAuthSessionCache.java
/** * Removes RSA session cache for the given tenant * @param tenantName/*from w ww.j a v a 2 s. c o m*/ * @throws AuthenticationException */ public void removeSessionCache(String tenantName) throws AuthenticationException { Validate.notEmpty(tenantName); //close all sessions in the session cache logger.debug("Removing RSA session cache ... tenant: " + tenantName); ConcurrentHashMap<String, AuthenticationSession> sessionCache = _rsaSessionCacheLookup .get(tenantName.toLowerCase()); if (sessionCache == null) { logger.debug("No RSA session cache found ... tenant: " + tenantName); return; } else { Iterator<Entry<String, AuthenticationSession>> it = sessionCache.entrySet().iterator(); while (it.hasNext()) { it.next().getValue().closeSession(); } } _rsaSessionCacheLookup.remove(tenantName.toLowerCase()); logger.debug("RSA session cache removed"); }
From source file:com.taobao.diamond.server.service.GroupService.java
/** * dumpjson/*from ww w .jav a2s. c o m*/ * * @throws Exception */ public void dumpJSONFile() throws Exception { Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>(); for (Map.Entry<String, ConcurrentHashMap<String, GroupInfo>> entry : this.addressGroupCache.entrySet()) { final String address = entry.getKey(); HashMap<String, String> subMap = new HashMap<String, String>(); map.put(address, subMap); final ConcurrentHashMap<String, GroupInfo> dataIdGroupMap = entry.getValue(); for (Map.Entry<String, GroupInfo> dataIdGroupEntry : dataIdGroupMap.entrySet()) { subMap.put(dataIdGroupEntry.getKey(), dataIdGroupEntry.getValue().getGroup()); } } String serializedGroupInfo = JSONUtils.serializeObject(map); this.diskService.saveFile(Constants.MAP_FILE, serializedGroupInfo); }
From source file:dr.app.bss.Utils.java
public static void printHashMap(ConcurrentHashMap<?, ?> hashMap) { Iterator<?> iterator = hashMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<?, ?> pairs = (Entry<?, ?>) iterator.next(); Taxon taxon = (Taxon) pairs.getKey(); int[] sequence = (int[]) pairs.getValue(); System.out.println(taxon.toString()); Utils.printArray(sequence);/*from w ww. j a v a 2 s. c om*/ } // END: while has next }
From source file:com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry.java
@SuppressWarnings("rawtypes") private void reconnectClient() { if (serviceListeners != null && !serviceListeners.isEmpty()) { try {//from w ww. ja v a 2s. c om clientLock.lock(); for (Map.Entry entry : serviceListeners.entrySet()) { URL url = (URL) entry.getKey(); ConcurrentHashMap<ServiceListener, IZkChildListener> childChangeListeners = serviceListeners .get(url); if (childChangeListeners != null) { for (Map.Entry e : childChangeListeners.entrySet()) { subscribeService(url, (ServiceListener) e.getKey()); } } } for (Map.Entry entry : commandListeners.entrySet()) { URL url = (URL) entry.getKey(); ConcurrentHashMap<CommandListener, IZkDataListener> dataChangeListeners = commandListeners .get(url); if (dataChangeListeners != null) { for (Map.Entry e : dataChangeListeners.entrySet()) { subscribeCommand(url, (CommandListener) e.getKey()); } } } LoggerUtil.info("[{}] reconnect all clients", registryClassName); } finally { clientLock.unlock(); } } }
From source file:com.taobao.tddl.common.StatMonitor.java
void visitMap0(SortedSet<Item> sortedSet, ConcurrentHashMap<String, Value1> map0, String key1, String key2, String key3) {//from ww w . j a v a 2 s.c om if ("*".equals(key1)) { for (Map.Entry<String, Value1> entry : map0.entrySet()) { visitMap1(sortedSet, entry.getValue().map1, entry.getKey(), key2, key3); } } else { Value1 value1 = map0.get(key1); if (value1 != null) { visitMap1(sortedSet, value1.map1, key1, key2, key3); } } }
From source file:com.taobao.tddl.common.StatMonitor.java
void visitMap1(SortedSet<Item> sortedSet, ConcurrentHashMap<String, Value2> map1, String key1, String key2, String key3) {/*from w w w. ja v a2 s . c o m*/ if ("*".equals(key2)) { for (Map.Entry<String, Value2> entry : map1.entrySet()) { visitMap2(sortedSet, entry.getValue().map2, key1, entry.getKey(), key3); } } else { Value2 value2 = map1.get(key2); if (value2 != null) { visitMap2(sortedSet, value2.map2, key1, key2, key3); } } }
From source file:com.taobao.tddl.common.StatMonitor.java
void visitMap2(SortedSet<Item> sortedSet, ConcurrentHashMap<String, StatCounter> map2, String key1, String key2, String key3) {/*from ww w . jav a 2 s . com*/ if ("*".equals(key3)) { for (Map.Entry<String, StatCounter> entry : map2.entrySet()) { sortedSet.add(new Item(key1, key2, entry.getKey(), entry.getValue().count.get(), entry.getValue().value.get())); } } else { StatCounter statCounter = map2.get(key3); if (statCounter != null) { sortedSet.add(new Item(key1, key2, key3, statCounter.count.get(), statCounter.value.get())); } } }
From source file:com.yahoo.elide.core.EntityDictionary.java
/** * If a relationship is bidirectional, returns the name of the peer relationship in the peer entity. * @param cls the cls/*from w w w . j ava 2 s .com*/ * @param relation the relation * @return relation inverse */ public String getRelationInverse(Class<?> cls, String relation) { final ConcurrentHashMap<String, String> mappings = entityBinding(cls).relationshipToInverse; if (mappings != null) { final String mapping = mappings.get(relation); if (mapping != null && !mapping.equals("")) { return mapping; } } /* * This could be the owning side of the relation. Let's see if the entity referenced in the relation * has a bidirectional reference that is mapped to the given relation. */ final Class<?> inverseType = getParameterizedType(cls, relation); final ConcurrentHashMap<String, String> inverseMappings = entityBinding(inverseType).relationshipToInverse; for (Map.Entry<String, String> inverseMapping : inverseMappings.entrySet()) { String inverseRelationName = inverseMapping.getKey(); String inverseMappedBy = inverseMapping.getValue(); if (relation.equals(inverseMappedBy) && getParameterizedType(inverseType, inverseRelationName).equals(lookupEntityClass(cls))) { return inverseRelationName; } } return ""; }
From source file:com.pearson.eidetic.driver.threads.MonitorSnapshotVolumeTime.java
private void addAlreadyDoneTodaySnapshots(ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeTime) { HashMap<Region, HashMap<Date, ArrayList<Volume>>> timeDay = new HashMap<>(); for (Map.Entry<Region, ArrayList<Volume>> entry : localVolumeTime.entrySet()) { Region region = entry.getKey(); if (localVolumeTime.get(region).isEmpty()) { continue; }/*from w w w .j av a2s . c om*/ timeDay.put(region, extractRunAt(localVolumeTime.get(region))); } for (Map.Entry<Region, ArrayList<Volume>> entry : localVolumeTime.entrySet()) { Region region = entry.getKey(); if (localVolumeTime.get(region).isEmpty()) { continue; } AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); for (Volume vol : localVolumeTime.get(region)) { Date date = new java.util.Date(); JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } String period = getPeriod(eideticParameters, vol); if (period == null) { continue; } Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } Boolean success; success = snapshotDecision(ec2Client, vol, period); //Success true means we need to take a snapshot, which it can handle l8r //Success false means we need to add to hashset if (!success) { String runAt = getRunAt(eideticParameters, vol); try { date = dayFormat_.parse(runAt); } catch (ParseException e) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } if (date == null) { continue; } didMySnapshotDay_.get(region).add(date); } } } }