java.util.concurrent.ConcurrentHashMap#keys ( )源码实例Demo

下面列出了java.util.concurrent.ConcurrentHashMap#keys ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FHIR   文件: CacheUtil.java
/**
 * Takes the contents of one of the JDBC PL caches and represents the contents in a format suitable for logging.
 * @param cacheName - The name of the JDBC PL cache to be dumped.
 * @param mapOfMaps - The contents of the multi-datastore cache.
 * @return String - A formatted representation of the cache contents.
 */
public static String dumpCacheContents(String cacheName, ConcurrentHashMap<String,ConcurrentHashMap<String,Integer>> mapOfMaps) {
    
    String cacheKey;
    Enumeration<String> cacheKeys = mapOfMaps.keys();
    ConcurrentHashMap<String,Integer> dbCache;
    StringBuffer dumpedCache = new StringBuffer();
    
    dumpedCache.append(NEWLINE).append("Contents of ").append(cacheName).append(NEWLINE);
    while(cacheKeys.hasMoreElements()) {
        cacheKey = cacheKeys.nextElement();
        dbCache = mapOfMaps.get(cacheKey);
        dumpedCache.append(cacheName).append(" for datastoreid: " + cacheKey).append(NEWLINE);
        dumpedCache.append(dbCache.toString().replaceAll(",", NEWLINE)).append(NEWLINE);
    }
    
    return dumpedCache.toString();
}
 
源代码2 项目: khan-session   文件: KhanSessionManager.java
/**
 * Cleanup all sessions
 *
 */
public void cleanup() {
    ConcurrentHashMap<String, Long> sessionIds = sessionIdStore.getSessionStore(appName);
    Enumeration<String> keys = sessionIds.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        String storeMetaKey = KhanSessionKeyGenerator.generate(khanSessionConfig.getNamespace(), key, KhanHttpSession.METADATA_KEY);
        String storeAttrKey = KhanSessionKeyGenerator.generate(khanSessionConfig.getNamespace(), key, KhanHttpSession.ATTRIBUTES_KEY);

        if( log.isDebugEnabled() ) {
            log.debug("key=" + key);
            log.debug("storeMetaKey=" + storeMetaKey);
            log.debug("storeAttrKey=" + storeAttrKey);
        }

        Object attr = sessionStore.get(storeAttrKey);
        Object meta = sessionStore.get(storeMetaKey);

        if( log.isDebugEnabled() ) {
            log.debug("attr,meta=" + attr + "," + meta);
        }
        if (attr == null && meta == null) {
            sessionIds.remove(key);
        }
    }
}
 
源代码3 项目: DDMQ   文件: ParameterDynamicZookeeper.java
private void syncFromZooKeeper() throws ZkException, IOException {
    ConcurrentHashMap<String/*zk path*/, Set<IZkDataListener>> listeners = zkClient.getDataListener();
    Enumeration<String> paths = listeners.keys();
    while (paths.hasMoreElements()) {
        String path = paths.nextElement();
        initPathData(path);
    }
}
 
源代码4 项目: DDMQ   文件: ParameterDynamicZookeeper.java
private void syncFromZooKeeper() throws ZkException, IOException {
    ConcurrentHashMap<String/*zk path*/, Set<IZkDataListener>> listeners = zkClient.getDataListener();
    Enumeration<String> paths = listeners.keys();
    while (paths.hasMoreElements()) {
        String path = paths.nextElement();
        initPathData(path);
    }
}
 
源代码5 项目: openjdk-jdk9   文件: ConcurrentHashMapTest.java
/**
 * keys returns an enumeration containing all the keys from the map
 */
public void testKeys() {
    ConcurrentHashMap map = map5();
    Enumeration e = map.keys();
    int count = 0;
    while (e.hasMoreElements()) {
        count++;
        e.nextElement();
    }
    assertEquals(5, count);
}
 
源代码6 项目: rya   文件: HashJoin.java
@Override
public CloseableIteration<RyaIRI, RyaDAOException> join(C conf, Map.Entry<RyaIRI, RyaType>... predObjs) throws RyaDAOException {
    ConcurrentHashMap<RyaIRI, Integer> ht = new ConcurrentHashMap<RyaIRI, Integer>();
    int count = 0;
    boolean first = true;
    for (Map.Entry<RyaIRI, RyaType> predObj : predObjs) {
        count++;
        RyaIRI pred = predObj.getKey();
        RyaType obj = predObj.getValue();
        //query
        CloseableIteration<RyaStatement, RyaDAOException> results = ryaQueryEngine.query(new RyaStatement(null, pred, obj), null);
        //add to hashtable
        while (results.hasNext()) {
            RyaIRI subject = results.next().getSubject();
            if (!first) {
                if (!ht.containsKey(subject)) {
                    continue; //not in join
                }
            }
            ht.put(subject, count);
        }
        //remove from hashtable values that are under count
        if (first) {
            first = false;
        } else {
            for (Map.Entry<RyaIRI, Integer> entry : ht.entrySet()) {
                if (entry.getValue() < count) {
                    ht.remove(entry.getKey());
                }
            }
        }
    }
    return new EnumerationWrapper<RyaIRI, RyaDAOException>(ht.keys());
}
 
源代码7 项目: j2objc   文件: ConcurrentHashMapTest.java
/**
 * keys returns an enumeration containing all the keys from the map
 */
public void testKeys() {
    ConcurrentHashMap map = map5();
    Enumeration e = map.keys();
    int count = 0;
    while (e.hasMoreElements()) {
        count++;
        e.nextElement();
    }
    assertEquals(5, count);
}
 
源代码8 项目: pentaho-kettle   文件: LoggingRegistry.java
/**
 * Helper Method that determines a LogChannelFileWriterBuffer invoked by getLogChannelFileWriterBuffer and returns 1.
 * @param possibleWriters  Map to search from.
 * @return LogChannelFileWriterBuffer, null if could not be determined.
 */
private LogChannelFileWriterBuffer determineLogChannelFileWriterBuffer( ConcurrentHashMap<LogChannelFileWriterBuffer,
  List<String>> possibleWriters ) {

  // Just one writer so just return it
  if ( possibleWriters.size() == 1 ) {
    return possibleWriters.keys().nextElement();
  } else {

    // Several possibilities, so, lets get the writer among them that is the "lowest in the chain",
    // meaning, the one that is not a parent of the others
    Enumeration<LogChannelFileWriterBuffer> possibleWritersIds = possibleWriters.keys();
    while ( possibleWritersIds.hasMoreElements() ) {
      LogChannelFileWriterBuffer writer = possibleWritersIds.nextElement();

      for ( Map.Entry<LogChannelFileWriterBuffer, List<String>> entry : possibleWriters.entrySet() ) {
        if ( entry.getKey().equals( writer ) ) {
          continue;
        }
        if ( !entry.getValue().contains( writer.getLogChannelId() ) ) {
          return entry.getKey();
        }
      }
    }
  }

  return null;
}
 
源代码9 项目: jane   文件: LongConcurrentHashMapWrap.java
private KeyIterator(ConcurrentHashMap<Long, V> map)
{
	it = map.keys();
}