List of usage examples for com.google.common.collect ImmutableMap of
public static <K, V> ImmutableMap<K, V> of(K k1, V v1)
From source file:consumer.kafka.ProcessedOffsetManager.java
private static void persistProcessedOffsets(Properties props, Map<Integer, Long> partitionOffsetMap) { ZkState state = new ZkState(props.getProperty(Config.ZOOKEEPER_CONSUMER_CONNECTION)); for (Map.Entry<Integer, Long> po : partitionOffsetMap.entrySet()) { Map<Object, Object> data = (Map<Object, Object>) ImmutableMap.builder() .put("consumer", ImmutableMap.of("id", props.getProperty(Config.KAFKA_CONSUMER_ID))) .put("offset", po.getValue()).put("partition", po.getKey()) .put("broker", ImmutableMap.of("host", "", "port", "")) .put("topic", props.getProperty(Config.KAFKA_TOPIC)).build(); String path = processedPath(po.getKey(), props); try {/*from w ww. j a v a2s .c o m*/ state.writeJSON(path, data); } catch (Exception ex) { state.close(); throw ex; } } state.close(); }
From source file:org.openqa.selenium.grid.sessionmap.httpd.DefaultSessionMapConfig.java
public DefaultSessionMapConfig() { super(ImmutableMap.of("events", ImmutableMap.of("publish", "tcp://*:4442", "subscribe", "tcp://*:4443"))); }
From source file:com.torodb.stampede.config.jackson.BackendSerializer.java
public BackendSerializer() { super(ImmutableMap.of("pool", (backend) -> backend.getPool())); }
From source file:com.jive.myco.seyren.core.service.checker.NoopTargetCheck.java
@Override public Map<String, Optional<BigDecimal>> check(Check check) throws Exception { return ImmutableMap.of(check.getTarget(), Optional.<BigDecimal>of(value)); }
From source file:org.fogbeam.gradle.sonatype.SonatypeDeployPlugin.java
public void apply(Project target) { // TODO Add a plugin to generate a javadoc and a source jar. target.getLogger().info(getClass().getSimpleName() + " is applying itself to " + target); target.apply(ImmutableMap.of("plugin", "java")); target.apply(ImmutableMap.of("plugin", "maven")); target.apply(ImmutableMap.of("plugin", "signing")); target.getArtifacts().add("archives", target.getTasks().getByName("jar")); configureSigning(target);/*from w w w .ja va2 s . com*/ configureDeployer(target, findMavenDeployer(target), findSigner(target)); addPomConfigurationHook(target); configurePomToSetPackagingString(findMavenDeployer(target).getPom()); target.getExtensions().create(EXTENSION_NAME, SonatypeConfiguration.class); }
From source file:co.cask.cdap.format.GrokRecordFormat.java
public static Map<String, String> settings(String pattern) { return ImmutableMap.of(PATTERN_SETTING, pattern); }
From source file:forge.download.GuiDownloadPrices.java
@Override protected Map<String, String> getNeededFiles() { return ImmutableMap.of(ForgeConstants.QUEST_CARD_PRICE_FILE, ForgeConstants.URL_PRICE_DOWNLOAD); }
From source file:com.icosilune.fn.nodes.ConstantNode.java
public final void setValue(Object value) { // TODO: check type. outputValue = ImmutableMap.of(OUTPUT_NAME, value); setOutputs(outputValue);//from w w w . jav a2 s.c o m getGraph().onNodeUpdated(this); }
From source file:org.scassandra.http.client.ClosedConnectionConfig.java
@Override
Map<String, ?> getProperties() {
return ImmutableMap.of(ErrorConstants.CloseType(), String.valueOf(closeType.toString().toLowerCase()));
}
From source file:es.upm.oeg.tools.quality.ldsniffer.util.HistrogramInputDataGenerator.java
public static void histrogram(String SPARQLEndpoint, List<String> metrics) { int min = 100; int max = 0;/* w w w .java2s . co m*/ Map<String, Map<Integer, Long>> histrograms = new HashMap<>(); for (String metric : metrics) { Map<String, String> litMap = new HashMap<>(); Map<String, String> iriMap = ImmutableMap.of("metric", metric); String queryString = bindQueryString(HIST_QUERY_STRING, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<Map<String, RDFNode>> results = executeQueryForList(queryString, SPARQLEndpoint, ImmutableSet.of("valueInt", "count")); Map<Integer, Long> resultMap = new HashMap<>(); long sum = 0; long countTotal = 0; for (Map<String, RDFNode> result : results) { int value = result.get("valueInt").asLiteral().getInt(); long count = result.get("count").asLiteral().getLong(); resultMap.put(value, count); long subTotal = value * count; sum += subTotal; countTotal += count; //set min and max if (value < min) { min = value; } else if (value > max) { max = value; } } double average = ((double) (sum)) / countTotal; System.out.println(metric + " : total : " + sum); System.out.println(metric + " : count : " + countTotal); System.out.println(metric + " : abg : " + average); histrograms.put(metric, resultMap); } StringBuffer buffer = new StringBuffer(); buffer.append("data.addRows(["); for (int avgValue = min; avgValue < max; avgValue++) { long[] value = new long[metrics.size()]; for (int metricID = 0; metricID < metrics.size(); metricID++) { Map<Integer, Long> metricResultMap = histrograms.get(metrics.get(metricID)); value[metricID] = metricResultMap.containsKey(avgValue) ? metricResultMap.get(avgValue) : 0; } buffer.append("["); buffer.append(avgValue + ","); for (int metricID = 0; metricID < (metrics.size() - 1); metricID++) { buffer.append(value[metricID] + ","); } buffer.append(value[(metrics.size() - 1)] + "],"); buffer.append("\n"); } System.out.println(buffer.toString()); }