List of usage examples for com.google.common.collect ImmutableMultimap get
@Override public abstract ImmutableCollection<V> get(K key);
From source file:org.knowm.dropwizard.sundial.tasks.RemoveJobTask.java
@Override public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception { logger.info(parameters.toString());/*from w ww . j a v a 2 s . co m*/ String jobName = (String) parameters.get("JOB_NAME").toArray()[0]; SundialJobScheduler.removeJob(jobName); }
From source file:org.knowm.dropwizard.sundial.tasks.StopJobTask.java
@Override public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception { logger.info(parameters.toString());/*from w w w. j av a 2 s .com*/ String jobName = (String) parameters.get("JOB_NAME").toArray()[0]; SundialJobScheduler.stopJob(jobName); }
From source file:org.kiji.rest.resources.CloseTask.java
/** {@inheritDoc} */ @Override//from ww w. j a v a2 s . com public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception { final Collection<String> instances = Preconditions.checkNotNull(parameters.get(INSTANCE_KEY)); Preconditions.checkArgument(instances.size() == 1, "Must supply a single instance."); final String instance = instances.iterator().next(); final Collection<String> tables = parameters.get(TABLE_KEY); if (tables.isEmpty()) { // Close the instance mKijiClient.invalidateInstance(instance); } else { Preconditions.checkArgument(tables.size() == 1, "Can not close multiple tables: %s.", tables); final String table = tables.iterator().next(); mKijiClient.invalidateTable(instance, table); } }
From source file:io.jwt.primer.tasks.DeleteStaticTokensTask.java
@Override public void execute(ImmutableMultimap<String, String> parameters, PrintWriter out) throws Exception { if (parameters.containsKey("app")) { log.info("Deleting static tokens for app: " + parameters.get("app").asList().get(0)); final String setName = parameters.get("app").asList().get(0) + "_static_tokens"; log.info("Set Name: " + setName); AerospikeConnectionManager.getClient().scanAll(null, aerospikeConfig.getNamespace(), setName, (key, record) -> AerospikeConnectionManager.getClient().delete(null, key)); out.print("Static tokens for app: [" + parameters.get("app").asList().get(0) + "] is being deleted"); } else {/* ww w .j a v a 2s .co m*/ out.print("Parameter[app] missing!"); } }
From source file:io.jwt.primer.tasks.DeleteDynamicTokensTask.java
@Override public void execute(ImmutableMultimap<String, String> parameters, PrintWriter out) throws Exception { if (parameters.containsKey("app")) { log.info("Deleting dynamic tokens for app: " + parameters.get("app").asList().get(0)); final String setName = parameters.get("app").asList().get(0) + "_tokens"; log.info("Set Name: " + setName); AerospikeConnectionManager.getClient().scanAll(null, aerospikeConfig.getNamespace(), setName, (key, record) -> AerospikeConnectionManager.getClient().delete(null, key)); out.print("Dynamic tokens for app: [" + parameters.get("app").asList().get(0) + "] is being deleted"); } else {/* w w w . ja v a2 s .com*/ out.print("Parameter[app] missing!"); } }
From source file:com.google.idea.blaze.base.targetmaps.SourceToTargetMapImpl.java
@Override public ImmutableCollection<TargetKey> getRulesForSourceFile(File sourceFile) { ImmutableMultimap<File, TargetKey> sourceToTargetMap = getSourceToTargetMap(); if (sourceToTargetMap == null) { return ImmutableList.of(); }/*from www . ja va 2s . c om*/ return sourceToTargetMap.get(sourceFile); }
From source file:com.google.errorprone.bugpatterns.android.WakelockReleasedDangerously.java
/** * Whether the given WakeLock may throw an unexpected RuntimeException when released. * * <p>Returns true if: 1) the given WakeLock was acquired with timeout, and 2) the given WakeLock * is reference counted.// w ww . jav a2s. co m */ private boolean wakelockMayThrow(Symbol wakelockSymbol, VisitorState state) { ClassTree enclosingClass = getTopLevelClass(state); ImmutableMultimap<String, MethodInvocationTree> map = methodCallsForSymbol(wakelockSymbol, enclosingClass); // Was acquired with timeout. return map.get("acquire").stream().anyMatch(m -> m.getArguments().size() == 1) // Is reference counted, i.e., referenceCounted not explicitly set to false. && map.get("setReferenceCounted").stream() .noneMatch(m -> Boolean.FALSE.equals(constValue(m.getArguments().get(0), Boolean.class))); }
From source file:org.smartloli.kafka.eagle.core.sql.schema.JSqlSchema.java
@Override protected Multimap<String, Function> getFunctionMultimap() { ImmutableMultimap<String, ScalarFunction> funcs = ScalarFunctionImpl.createAll(JSONFunction.class); Multimap<String, Function> functions = HashMultimap.create(); for (String key : funcs.keySet()) { for (ScalarFunction func : funcs.get(key)) { functions.put(key, func);/* w ww. j a v a2 s .c om*/ } } return functions; }
From source file:com.smoketurner.dropwizard.consul.task.MaintenanceTask.java
@Override public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception { if (!parameters.containsKey("enable")) { throw new IllegalArgumentException("Parameter \"enable\" not found"); }// w w w.j a va 2s . c o m final boolean enable = Boolean.parseBoolean(parameters.get("enable").asList().get(0)); final String reason; if (parameters.containsKey("reason")) { reason = Strings.nullToEmpty(parameters.get("reason").asList().get(0)); } else { reason = ""; } if (enable) { if (!Strings.isNullOrEmpty(reason)) { LOGGER.warn("Enabling maintenance mode for service {} (reason: {})", serviceId, reason); } else { LOGGER.warn("Enabling maintenance mode for service {} (no reason given)", serviceId); } } else { LOGGER.warn("Disabling maintenance mode for service {}", serviceId); } consul.agentClient().toggleMaintenanceMode(serviceId, enable, reason); output.println("OK"); output.flush(); }
From source file:org.apache.aurora.scheduler.stats.SlotSizeCounter.java
private void updateStats(String name, Iterable<MachineResource> slots, ResourceBag slotSize) { ImmutableMultimap.Builder<String, ResourceBag> builder = ImmutableMultimap.builder(); for (MachineResource slot : slots) { builder.put(getStatName(name, slot.isDedicated(), slot.isRevocable()), slot.getSize()); }// ww w . j av a2 s.c om ImmutableMultimap<String, ResourceBag> sizes = builder.build(); for (String slotGroup : SLOT_GROUPS) { String statName = slotGroup + name; cachedCounters.get(statName).set(countSlots(sizes.get(statName), slotSize)); } }