public WallTableStat getTableStatWithLowerName(String lowerCaseName) { WallTableStat stat = tableStats.get(lowerCaseName); if (stat == null) { if (tableStats.size() > 10000) { return null; } tableStats.putIfAbsent(lowerCaseName, new WallTableStat()); stat = tableStats.get(lowerCaseName); } return stat; }
@Override protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName(); ConcurrentMap<String, WeightedRoundRobin> map = methodWeightMap.get(key); if (map == null) { methodWeightMap.putIfAbsent(key, new ConcurrentHashMap<String, WeightedRoundRobin>()); map = methodWeightMap.get(key); for (Invoker<T> invoker : invokers) { String identifyString = invoker.getUrl().toIdentityString(); WeightedRoundRobin weightedRoundRobin = map.get(identifyString); int weight = getWeight(invoker, invocation); if (!updateLock.get() && invokers.size() != map.size()) { if (updateLock.compareAndSet(false, true)) { try { Iterator<Entry<String, WeightedRoundRobin>> it = newMap.entrySet().iterator(); while (it.hasNext()) { Entry<String, WeightedRoundRobin> item = it.next(); if (now - item.getValue().getLastUpdate() > RECYCLE_PERIOD) { it.remove();
assertTrue(map.replace(one, three, two)); assertSame(two, map.get(one)); assertEquals(3, map.size()); assertEquals(0, map.size()); assertEquals(1, map.size()); assertSame(one, map.get(one)); assertTrue(map.containsKey(one)); assertTrue(map.containsValue(one)); assertSame(one, map.remove(one)); assertEquals(0, map.size()); assertEquals(1, map.size()); assertFalse(map.remove(one, two)); assertTrue(map.remove(one, one)); assertEquals(0, map.size()); assertEquals(newMap.entrySet(), map.entrySet()); assertEquals(newMap.keySet(), map.keySet()); Set<Object> expectedValues = ImmutableSet.of(one); Set<Object> actualValues = ImmutableSet.copyOf(map.values()); assertEquals(expectedValues, actualValues);
/** * Returns a connection for a given session id. * * @param sessionId session id * @return connection if found and null otherwise */ public RTMPConnection getConnectionBySessionId(String sessionId) { log.trace("Getting connection by session id: {}", sessionId); RTMPConnection conn = connMap.get(sessionId); if (conn == null && log.isDebugEnabled()) { log.debug("Connection not found for {}", sessionId); if (log.isTraceEnabled()) { log.trace("Connections ({}) {}", connMap.size(), connMap.values()); } } return conn; }
@Override public void run() { for (Entry entry : commands.values()) { for (BatchCommandData<?, ?> command : entry.getCommands()) { if (command.getPromise().isDone() && !command.getPromise().isSuccess()) { final Map<MasterSlaveEntry, List<Object>> result = new ConcurrentHashMap<MasterSlaveEntry, List<Object>>(); final CountableListener<Map<MasterSlaveEntry, List<Object>>> listener = new CountableListener<Map<MasterSlaveEntry, List<Object>>>(mainPromise, result); listener.setCounter(connections.size()); for (final Map.Entry<MasterSlaveEntry, Entry> entry : commands.entrySet()) { final RPromise<List<Object>> execPromise = new RedissonPromise<List<Object>>(); async(entry.getValue().isReadOnlyMode(), new NodeSource(entry.getKey()), connectionManager.getCodec(), RedisCommands.EXEC, new Object[] {}, execPromise, 0, false); execPromise.addListener(new FutureListener<List<Object>>() {
toClean.addResources(t.getValue()); LOG.debug("Resources to be cleaned after adding {} archives : {}", t.getKey(), toClean); toClean.addResources(t.getValue()); LOG.debug("Resources to be cleaned after adding {} files : {}", t.getKey(), toClean); ConcurrentMap<String, LocalizedResource> filesForUser = userFiles.get(user); ConcurrentMap<String, LocalizedResource> archivesForUser = userArchives.get(user); if ((filesForUser == null || filesForUser.size() == 0) && (archivesForUser == null || archivesForUser.size() == 0)) {
public WallFunctionStat getFunctionStatWithLowerName(String lowerCaseName) { WallFunctionStat stat = functionStats.get(lowerCaseName); if (stat == null) { if (functionStats.size() > 10000) { return null; } functionStats.putIfAbsent(lowerCaseName, new WallFunctionStat()); stat = functionStats.get(lowerCaseName); } return stat; }
public List<Map<String, Object>> getMethodStatDataList() { List<Map<String, Object>> methodStatDataList = new ArrayList<Map<String, Object>>(this.methodStats.size()); for (SpringMethodStat methodStat : this.methodStats.values()) { Map<String, Object> methodStatData = methodStat.getStatData(); int runningCount = ((Number) methodStatData.get("RunningCount")).intValue(); long executeCount = (Long) methodStatData.get("ExecuteCount"); if (runningCount == 0 && executeCount == 0) { continue; } methodStatDataList.add(methodStatData); } return methodStatDataList; }
@Override protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName(); ConcurrentMap<String, WeightedRoundRobin> map = methodWeightMap.get(key); if (map == null) { methodWeightMap.putIfAbsent(key, new ConcurrentHashMap<String, WeightedRoundRobin>()); map = methodWeightMap.get(key); for (Invoker<T> invoker : invokers) { String identifyString = invoker.getUrl().toIdentityString(); WeightedRoundRobin weightedRoundRobin = map.get(identifyString); int weight = getWeight(invoker, invocation); if (!updateLock.get() && invokers.size() != map.size()) { if (updateLock.compareAndSet(false, true)) { try { Iterator<Entry<String, WeightedRoundRobin>> it = newMap.entrySet().iterator(); while (it.hasNext()) { Entry<String, WeightedRoundRobin> item = it.next(); if (now - item.getValue().getLastUpdate() > RECYCLE_PERIOD) { it.remove();
assertTrue(map.replace(one, three, two)); assertSame(two, map.get(one)); assertEquals(3, map.size()); assertEquals(0, map.size()); assertEquals(1, map.size()); assertSame(one, map.get(one)); assertTrue(map.containsKey(one)); assertTrue(map.containsValue(one)); assertSame(one, map.remove(one)); assertEquals(0, map.size()); assertEquals(1, map.size()); assertFalse(map.remove(one, two)); assertTrue(map.remove(one, one)); assertEquals(0, map.size()); assertEquals(newMap.entrySet(), map.entrySet()); assertEquals(newMap.keySet(), map.keySet()); Set<Object> expectedValues = ImmutableSet.of(one); Set<Object> actualValues = ImmutableSet.copyOf(map.values()); assertEquals(expectedValues, actualValues);
while (iterator.hasNext()) { String worker = iterator.next(); ZkWorker zkWorker = zkWorkers.get(worker); try { if (getAssignedTasks(zkWorker.getWorker()).isEmpty() && isLazyWorker.apply(zkWorker.toImmutable())) { log.info("Adding Worker[%s] to lazySet!", zkWorker.getWorker().getHost()); lazyWorkers.put(worker, zkWorker); if (lazyWorkers.size() == maxWorkers) { return getWorkerFromZK(lazyWorkers.values());
@Override public void run() { for (Entry entry : commands.values()) { for (BatchCommandData<?, ?> command : entry.getCommands()) { if (command.getPromise().isDone() && !command.getPromise().isSuccess()) { final Map<MasterSlaveEntry, List<Object>> result = new ConcurrentHashMap<MasterSlaveEntry, List<Object>>(); final CountableListener<Map<MasterSlaveEntry, List<Object>>> listener = new CountableListener<Map<MasterSlaveEntry, List<Object>>>(mainPromise, result); listener.setCounter(connections.size()); for (final Map.Entry<MasterSlaveEntry, Entry> entry : commands.entrySet()) { final RPromise<List<Object>> execPromise = new RedissonPromise<List<Object>>(); async(entry.getValue().isReadOnlyMode(), new NodeSource(entry.getKey()), connectionManager.getCodec(), RedisCommands.EXEC, new Object[] {}, execPromise, 0, false); execPromise.addListener(new FutureListener<List<Object>>() {
public static JSONPath compile(String path) { if (path == null) { throw new JSONPathException("jsonpath can not be null"); } JSONPath jsonpath = pathCache.get(path); if (jsonpath == null) { jsonpath = new JSONPath(path); if (pathCache.size() < 1024) { pathCache.putIfAbsent(path, jsonpath); jsonpath = pathCache.get(path); } } return jsonpath; }
public List<Map<String, Object>> getURIStatDataList() { List<Map<String, Object>> uriStatDataList = new ArrayList<Map<String, Object>>(this.uriStatMap.size()); for (WebURIStat uriStat : this.uriStatMap.values()) { Map<String, Object> uriStatData = uriStat.getStatData(); int runningCount = ((Number) uriStatData.get("RunningCount")).intValue(); long requestCount = (Long) uriStatData.get("RequestCount"); if (runningCount == 0 && requestCount == 0) { continue; } uriStatDataList.add(uriStatData); } return uriStatDataList; }