/** * Returns the value associated with {@code key}, or zero if there is no value associated with * {@code key}. */ public long get(K key) { return map.getOrDefault(key, 0L); }
/** * Returns the value associated with {@code key}, or zero if there is no value associated with * {@code key}. */ public long get(K key) { return map.getOrDefault(key, 0L); }
/** * Returns the value associated with {@code key}, or zero if there is no value associated with * {@code key}. */ public long get(K key) { return map.getOrDefault(key, 0L); }
public V getOrDefault(final Object key, final V defaultValue) { return backingMap.getOrDefault(key, defaultValue); }
public static ImmutableSet<DerivativeDataSource> getDerivatives(String datasource) { return ImmutableSet.copyOf(derivativesRef.get().getOrDefault(datasource, new TreeSet<>())); }
public String getTopic(String profilerName) { String topic = profilerTopics.getOrDefault(profilerName, null); if (topic == null || topic.isEmpty()) { topic = topicPrefix == null ? "" : topicPrefix; topic += profilerName; } return topic; }
public void removeNode(final String clusterName, final String nodeName) { clusterNodes.getOrDefault(clusterName, Collections.emptySet()).remove(nodeName); }
/** * Updates the internal table permissions cache for specified table. * @param table updated table name * @param tablePerms new table permissions */ private void updateTableCache(TableName table, ListMultimap<String, Permission> tablePerms) { PermissionCache<TablePermission> cacheToUpdate = tableCache.getOrDefault(table, new PermissionCache<>()); clearCache(cacheToUpdate); updateCache(tablePerms, cacheToUpdate); tableCache.put(table, cacheToUpdate); mtime.incrementAndGet(); }
/** * Updates the internal namespace permissions cache for specified namespace. * @param namespace updated namespace * @param nsPerms new namespace permissions */ private void updateNamespaceCache(String namespace, ListMultimap<String, Permission> nsPerms) { PermissionCache<NamespacePermission> cacheToUpdate = namespaceCache.getOrDefault(namespace, new PermissionCache<>()); clearCache(cacheToUpdate); updateCache(nsPerms, cacheToUpdate); namespaceCache.put(namespace, cacheToUpdate); mtime.incrementAndGet(); }
pendingCompletionTaskGroups.getOrDefault(groupId, new CopyOnWriteArrayList<>()).size() > 0 && earliestConsistentSequenceId.compareAndSet(-1, taskCheckpoints.firstKey()))) { final SortedMap<Integer, Map<PartitionIdType, SequenceOffsetType>> latestCheckpoints = new TreeMap<>( && pendingCompletionTaskGroups.getOrDefault(groupId, new CopyOnWriteArrayList<>()).size() == 0)) {
&& actorSupported_no != n.canActivate.getOrDefault(interfaceClassName, actorSupported_yes) && (n.placementGroupPending.get() || currentTargetPlacementGroups.contains(n.placementGroup))) .collect(Collectors.toList()); .filter(n -> actorSupported_no != n.canActivate.getOrDefault(interfaceClassName, actorSupported_no) && n.placementGroup != null && targetPlacementGroups.contains(n.placementGroup))
res.centroidStat.put(centroidIdx, centroidStat); } else { int cnt = centroidStat.getOrDefault(lb, 0); centroidStat.put(lb, cnt + 1);
/** * Check if user has given action privilige in table:family scope. * This method is for backward compatibility. * @param user user name * @param table table name * @param family family names * @param action one of action in [Read, Write, Create, Exec, Admin] * @return true if user has, false otherwise */ public boolean authorizeUserFamily(User user, TableName table, byte[] family, Permission.Action action) { PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table, TBL_NO_PERMISSION); if (authorizeFamily(tblPermissions.get(user.getShortName()), table, family, action)) { return true; } for (String group : user.getGroupNames()) { if (authorizeFamily(tblPermissions.get(AuthUtil.toGroupEntry(group)), table, family, action)) { return true; } } return false; }
/** * Check if user has given action privilige in namespace scope. * @param user user name * @param namespace namespace * @param action one of action in [Read, Write, Create, Exec, Admin] * @return true if user has, false otherwise */ public boolean authorizeUserNamespace(User user, String namespace, Permission.Action action) { if (user == null) { return false; } if (authorizeUserGlobal(user, action)) { return true; } PermissionCache<NamespacePermission> nsPermissions = namespaceCache.getOrDefault(namespace, NS_NO_PERMISSION); if (authorizeNamespace(nsPermissions.get(user.getShortName()), namespace, action)) { return true; } for (String group : user.getGroupNames()) { if (authorizeNamespace(nsPermissions.get(AuthUtil.toGroupEntry(group)), namespace, action)) { return true; } } return false; }
return true; PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table, TBL_NO_PERMISSION); if (authorizeTable(tblPermissions.get(user.getShortName()), table, family, qualifier, action)) {
/** * Checks if the user has access to the full table or at least a family/qualifier * for the specified action. * @param user user name * @param table table name * @param action action in one of [Read, Write, Create, Exec, Admin] * @return true if the user has access to the table, false otherwise */ public boolean accessUserTable(User user, TableName table, Permission.Action action) { if (user == null) { return false; } if (table == null) { table = AccessControlLists.ACL_TABLE_NAME; } if (authorizeUserNamespace(user, table.getNamespaceAsString(), action)) { return true; } PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table, TBL_NO_PERMISSION); if (hasAccessTable(tblPermissions.get(user.getShortName()), action)) { return true; } for (String group : user.getGroupNames()) { if (hasAccessTable(tblPermissions.get(AuthUtil.toGroupEntry(group)), action)) { return true; } } return false; }
@Override public String apply(String s) { if (remaining.get() <= 0) { return values.getOrDefault(s, OTHERS); } else { String v = values.get(s); if (v == null) { add(s); v = values.getOrDefault(s, OTHERS); } return v; } }
private List<IncomingMessageEnvelope> poll(SystemStreamPartition ssp, String offset) { int startingOffset = Integer.parseInt(offset); List<IncomingMessageEnvelope> messageEnvelopesForSSP = bufferedMessages.getOrDefault(ssp, new LinkedList<>()); if (startingOffset >= messageEnvelopesForSSP.size()) { return new ArrayList<>(); } return messageEnvelopesForSSP.subList(startingOffset, messageEnvelopesForSSP.size()); } }
@SneakyThrows(StreamSegmentNotExistsException.class) private TransactionalEventStreamWriter<byte[]> getTransactionalWriter(String streamName, int routingKey) { List<TransactionalEventStreamWriter<byte[]>> writers = this.transactionalWriters.getOrDefault(streamName, null); if (writers == null) { throw new StreamSegmentNotExistsException(streamName); } return writers.get(routingKey % writers.size()); }
private void handleIncomingMessage(Message message) throws InvalidObjectException { int state = userState.getOrDefault(message.getFrom().getId(), 0); switch(state) { case WAITINGCHANNEL: onWaitingChannelMessage(message); break; default: sendHelpMessage(message.getChatId(), message.getMessageId(), null); userState.put(message.getFrom().getId(), WAITINGCHANNEL); break; } }