@Override protected Map<AnEnum, String> create(Entry<AnEnum, String>[] entries) { Map<AnEnum, String> map = Maps.newHashMap(); for (Entry<AnEnum, String> entry : entries) { // checkArgument(!map.containsKey(entry.getKey())); map.put(entry.getKey(), entry.getValue()); } return Maps.immutableEnumMap(map); } }
public Periodicals(ScheduledExecutorService scheduler, ScheduledExecutorService daemonScheduler) { this.scheduler = scheduler; this.daemonScheduler = daemonScheduler; this.periodicals = Lists.newArrayList(); this.futures = Maps.newHashMap(); }
@Override public Map<K, V> getBatch(Collection<K> keys) throws IOException { Map<K, V> batch = Maps.<K, V>newHashMap(); for (K key : keys) { batch.put(key, kvStore.get(key)); } return batch; }
private void loadBlocks() { blockFamilyIds = Maps.newHashMap(); gameInfo.getManifest().getBlockIdMap().entrySet().forEach(blockId -> { String familyName = blockId.getKey().split(":")[0].toLowerCase(); blockFamilyIds.computeIfAbsent(familyName, k -> new ArrayList<>()); blockFamilyIds.get(familyName).add(blockId.toString()); }); blocks.setList(Lists.newArrayList(blockFamilyIds.keySet())); }
@JsonIgnore public Map<String, List<RequestedConfigurationField>> getRequestedConfiguration() { Map<String, List<RequestedConfigurationField>> result = Maps.newHashMap(); for (Map.Entry<String, AvailableAlarmCallbackSummaryResponse> entry : types.entrySet()) { result.put(entry.getKey(), entry.getValue().extractRequestedConfiguration(entry.getValue().requested_configuration)); } return result; } }
protected Map<String, MasterMain> startDefaultMasters(final int numMasters, String... args) throws Exception { final Map<String, MasterMain> masters = Maps.newHashMap(); for (int i = 0; i < numMasters; i++) { final String name = TEST_MASTER + i; final List<String> argsList = Lists.newArrayList(args); argsList.addAll(asList("--name", name)); masters.put(name, startDefaultMaster(i, argsList.toArray(new String[argsList.size()]))); } return masters; }
/** * Get environment variables for the container. * * @return The environment variables. */ public Map<String, String> containerEnv() { final Map<String, String> env = Maps.newHashMap(envVars); // Put in variables that tell the container where it's exposed for (final Entry<String, Integer> entry : ports.entrySet()) { env.put("HELIOS_PORT_" + entry.getKey(), host + ":" + entry.getValue()); } // Job environment variables take precedence. env.putAll(job.getEnv()); return env; }
public void setMessage(String id, Map<String, Object> message) { Map<String, Object> tmp = Maps.newHashMap(); tmp.putAll(message); tmp.put(Message.FIELD_ID, id); if (tmp.containsKey(Message.FIELD_TIMESTAMP)) { final Object tsField = tmp.get(Message.FIELD_TIMESTAMP); try { tmp.put(Message.FIELD_TIMESTAMP, ES_DATE_FORMAT_FORMATTER.parseDateTime(String.valueOf(tsField))); } catch (IllegalArgumentException e) { // could not parse date string, this is likely a bug, but we will leave the original value alone LOG.warn("Could not parse timestamp of message {}", message.get("id"), e); } } this.message = new Message(tmp); }
@Override public CompletableFuture<Boolean> containsAll(Collection<? extends String> keys) { Map<PartitionId, Collection<String>> partitions = Maps.newHashMap(); keys.forEach(key -> partitions.computeIfAbsent(getProxyClient().getPartitionId(key), k -> Lists.newArrayList()).add(key)); return Futures.allOf(partitions.entrySet().stream() .map(entry -> getProxyClient() .applyOn(entry.getKey(), service -> service.containsKeys(entry.getValue()))) .collect(Collectors.toList())) .thenApply(results -> results.stream().reduce(Boolean::logicalAnd).orElse(false)); }
/** * get the component's configuration */ public static Map getComponentMap(DefaultTopologyAssignContext context, Integer task) { String componentName = context.getTaskToComponent().get(task); ComponentCommon componentCommon = ThriftTopologyUtils.getComponentCommon(context.getSysTopology(), componentName); Map componentMap = (Map) JStormUtils.from_json(componentCommon.get_json_conf()); if (componentMap == null) { componentMap = Maps.newHashMap(); } return componentMap; }
public void stop() { logger.log(Level.INFO, "Stopping watch server ... "); Map<File, WatchRunner> copyOfWatchOperations = Maps.newHashMap(watchOperations); for (Map.Entry<File, WatchRunner> folderEntry : copyOfWatchOperations.entrySet()) { File localDir = folderEntry.getKey(); WatchRunner watchOperationThread = folderEntry.getValue(); logger.log(Level.INFO, "- Stopping watch operation at " + localDir + " ..."); watchOperationThread.stop(); watchOperations.remove(localDir); } }
@Override protected final Map<String, String> create(Entry<String, String>[] entries) { HashMap<String, String> map = Maps.newHashMap(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return wrap(map); }
@Override public List<ACL> getAclForPath(final String path) { // id -> permissions final Map<Id, Integer> matching = Maps.newHashMap(); for (final Rule rule : rules) { if (rule.matches(path)) { final int existingPerms = matching.containsKey(rule.id) ? matching.get(rule.id) : 0; matching.put(rule.id, rule.perms | existingPerms); } } if (matching.isEmpty()) { return null; } final List<ACL> acls = Lists.newArrayList(); for (final Map.Entry<Id, Integer> e : matching.entrySet()) { acls.add(new ACL(e.getValue(), e.getKey())); } return acls; }
private Map<String, String> selectByKeys(Map<String, String> map, String[] keys) { Map<String, String> result = Maps.newHashMap(); for (String key : keys) { if (map.containsKey(key)) { result.put(key, map.get(key)); } } return result; }
protected void createOutputMap() { Preconditions.checkState(outMap == null, "Outputs should only be setup once"); outMap = Maps.newHashMap(); for (Entry<String, LogicalOutput> entry : outputs.entrySet()) { TezKVOutputCollector collector = new TezKVOutputCollector(entry.getValue()); outMap.put(entry.getKey(), collector); } }
@Override public Map<Object, Object> loadAll(Iterable<?> keys) throws Exception { Map<Object, Object> result = Maps.newHashMap(); // ignore request keys result.put(extraKey, extraValue); return result; } };
String assembleQueryConfigUrl(String uri, String appId, String cluster, String namespace, String dataCenter, ApolloNotificationMessages remoteMessages, ApolloConfig previousConfig) { String path = "configs/%s/%s/%s"; List<String> pathParams = Lists.newArrayList(pathEscaper.escape(appId), pathEscaper.escape(cluster), pathEscaper.escape(namespace)); Map<String, String> queryParams = Maps.newHashMap(); if (previousConfig != null) { queryParams.put("releaseKey", queryParamEscaper.escape(previousConfig.getReleaseKey())); } if (!Strings.isNullOrEmpty(dataCenter)) { queryParams.put("dataCenter", queryParamEscaper.escape(dataCenter)); } String localIp = m_configUtil.getLocalIp(); if (!Strings.isNullOrEmpty(localIp)) { queryParams.put("ip", queryParamEscaper.escape(localIp)); } if (remoteMessages != null) { queryParams.put("messages", queryParamEscaper.escape(gson.toJson(remoteMessages))); } String pathExpanded = String.format(path, pathParams.toArray()); if (!queryParams.isEmpty()) { pathExpanded += "?" + MAP_JOINER.join(queryParams); } if (!uri.endsWith("/")) { uri += "/"; } return uri + pathExpanded; }
protected String generateSqoopConfigArgString() { KylinConfig kylinConfig = getConfig(); Map<String, String> config = Maps.newHashMap(); config.put("mapreduce.job.queuename", getSqoopJobQueueName(kylinConfig)); // override job queue from mapreduce config config.putAll(SourceConfigurationUtil.loadSqoopConfiguration()); config.putAll(kylinConfig.getSqoopConfigOverride()); StringBuilder args = new StringBuilder(); for (Map.Entry<String, String> entry : config.entrySet()) { args.append(" -D" + entry.getKey() + "=" + entry.getValue() + " "); } return args.toString(); }
@Override public CompletableFuture<Boolean> containsAll(Collection<? extends String> keys) { Map<PartitionId, Collection<String>> partitions = Maps.newHashMap(); keys.forEach(key -> partitions.computeIfAbsent(getProxyClient().getPartitionId(key), k -> Lists.newArrayList()).add(key)); return Futures.allOf(partitions.entrySet().stream() .map(entry -> getProxyClient() .applyOn(entry.getKey(), service -> service.containsKeys(entry.getValue()))) .collect(Collectors.toList())) .thenApply(results -> results.stream().reduce(Boolean::logicalAnd).orElse(false)); }
public synchronized Map<Long, PositionRange> listAllPositionRange() { Set<Long> batchIdSets = batches.keySet(); List<Long> batchIds = Lists.newArrayList(batchIdSets); Collections.sort(Lists.newArrayList(batchIds)); return Maps.newHashMap(batches); }