public void clearStats(long threadId) { if (cpuInfoConcurrentHashMap.containsKey(threadId)) { cpuInfoConcurrentHashMap.remove(threadId); } }
private void removeFromCacheForServerToConstructedCQName(final String cqName, ClientProxyMembershipID clientProxyMembershipID) { ConcurrentHashMap<ClientProxyMembershipID, String> cache = serverCqNameCache.get(cqName); if (cache != null) { cache.remove(clientProxyMembershipID); if (cache.size() == 0) { serverCqNameCache.remove(cqName); } } }
/** * Helper method to have a single point of deletion in the queued flows */ public void dequeue(final int executionId) { if (this.queuedFlowMap.containsKey(executionId)) { this.queuedFlowList.remove(this.queuedFlowMap.get(executionId)); this.queuedFlowMap.remove(executionId); } }
public void addError(long offset, int length, long baseOffset) { Long key = Long.valueOf(offset + baseOffset); Integer existingLength = cache.get(key); if (existingLength != null && existingLength >= length) return; Integer value = Integer.valueOf(length); while (true) { existingLength = cache.putIfAbsent(key, value); if (existingLength == null || existingLength >= length) return; cache.remove(key, existingLength); } }
/** * 添加channel */ public void offerChannel(ChannelWrapper channel) { String nodeGroup = channel.getNodeGroup(); NodeType nodeType = channel.getNodeType(); List<ChannelWrapper> channels = getChannels(nodeGroup, nodeType); if (channels == null) { channels = new ArrayList<ChannelWrapper>(); if (nodeType == NodeType.JOB_CLIENT) { clientChannelMap.put(nodeGroup, channels); } else if (nodeType == NodeType.TASK_TRACKER) { taskTrackerChannelMap.put(nodeGroup, channels); // 如果在离线列表中,那么移除 if (offlineTaskTrackerMap.containsKey(channel.getIdentity())) { offlineTaskTrackerMap.remove(channel.getIdentity()); } } channels.add(channel); LOGGER.info("new connected channel={}", channel); } else { if (!channels.contains(channel)) { channels.add(channel); LOGGER.info("new connected channel={}", channel); } } }
/** * Remove the NonceKey if the procedure was not submitted to the executor. * @param nonceKey A unique identifier for this operation from the client or process. */ public void unregisterNonceIfProcedureWasNotSubmitted(final NonceKey nonceKey) { if (nonceKey == null) return; final Long procId = nonceKeysToProcIdsMap.get(nonceKey); if (procId == null) return; // if the procedure was not submitted, remove the nonce if (!(procedures.containsKey(procId) || completed.containsKey(procId))) { nonceKeysToProcIdsMap.remove(nonceKey); } }
@Override public void rename(String source, String dest) throws IOException { ensureOpen(); FileEntry file = files.get(source); if (file == null) { throw new NoSuchFileException(source); } if (files.putIfAbsent(dest, file) != null) { throw new FileAlreadyExistsException(dest); } if (!files.remove(source, file)) { throw new IllegalStateException("File was unexpectedly replaced: " + source); } files.remove(source); }
/** * Remove the value set for key. * * @param key key to remove */ public void remove(PropertyKey key) { // remove is a nop if the key doesn't already exist if (mUserProps.containsKey(key)) { mUserProps.remove(key); } }
/** * 添加channel */ public void offerChannel(ChannelWrapper channel) { String nodeGroup = channel.getNodeGroup(); NodeType nodeType = channel.getNodeType(); List<ChannelWrapper> channels = getChannels(nodeGroup, nodeType); if (channels == null) { channels = new ArrayList<ChannelWrapper>(); if (nodeType == NodeType.JOB_CLIENT) { clientChannelMap.put(nodeGroup, channels); } else if (nodeType == NodeType.TASK_TRACKER) { taskTrackerChannelMap.put(nodeGroup, channels); // 如果在离线列表中,那么移除 if (offlineTaskTrackerMap.containsKey(channel.getIdentity())) { offlineTaskTrackerMap.remove(channel.getIdentity()); } } channels.add(channel); LOGGER.info("new connected channel={}", channel); } else { if (!channels.contains(channel)) { channels.add(channel); LOGGER.info("new connected channel={}", channel); } } }
/** * Removes element from the queue. * @param elem element to remove * @return time at which the element was set to expire, or null if * it wasn't present */ public Long remove(E elem) { Long expiryTime = elemMap.remove(elem); if (expiryTime != null) { Set<E> set = expiryMap.get(expiryTime); if (set != null) { set.remove(elem); // We don't need to worry about removing empty sets, // they'll eventually be removed when they expire. } } return expiryTime; }
/** * @param nodeId Node ID. * @param qryTrackerId Query tracker Id. */ void onQueryDone(UUID nodeId, long qryTrackerId) { if (qryTrackerId == MVCC_TRACKER_ID_NA) return; synchronized (this) { Set<Long> nodeTrackers = activeQueries.get(nodeId); if (nodeTrackers == null || !nodeTrackers.remove(qryTrackerId)) { Set<Long> nodeAcks = rcvdAcks.get(nodeId); if (nodeAcks == null) rcvdAcks.put(nodeId, nodeAcks = new HashSet<>()); // We received qry done ack before the active qry message. Need to save it. nodeAcks.add(qryTrackerId); } if (nodeTrackers != null && nodeTrackers.isEmpty()) activeQueries.remove(nodeId); if (initDone && !prevQueriesDone) prevQueriesDone = activeQueries.isEmpty() && rcvdAcks.isEmpty(); } }
if (!locks.containsKey(kc)) { log.error("Local unlock failed: no locks found for {}", kc); return false; AuditRecord<T> holder = locks.get(kc); boolean removed = locks.remove(kc, unlocker);
private <T> LlapBufferOrBuffers putInternal(T key, ByteBuffer tailBuffer, String tag, AtomicBoolean isStopped) { LlapBufferOrBuffers result = null; while (true) { // Overwhelmingly executes once, or maybe twice (replacing stale value). LlapBufferOrBuffers oldVal = metadata.get(key); if (oldVal == null) { result = wrapBb(result, key, tailBuffer, tag, isStopped); oldVal = metadata.putIfAbsent(key, result); if (oldVal == null) { cacheInPolicy(result); // Cached successfully, add to policy. return result; } } if (lockOldVal(key, result, oldVal)) { return oldVal; } // We found some old value but couldn't incRef it; remove it. metadata.remove(key, oldVal); } }