Example usage for com.google.common.collect ImmutableMap of

List of usage examples for com.google.common.collect ImmutableMap of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap of.

Prototype

public static <K, V> ImmutableMap<K, V> of(K k1, V v1, K k2, V v2) 

Source Link

Usage

From source file:org.terasology.dialogs.action.ChangeDialogActionTypeHandler.java

@Override
public PersistedData serialize(ChangeDialogAction action, SerializationContext context) {
    Map<String, PersistedData> data = ImmutableMap.of("type", context.create(action.getClass().getSimpleName()),
            "prefab", context.create(action.getPrefab()));

    return context.create(data);
}

From source file:org.janusgraph.diskstorage.es.compat.ES1Compat.java

@Override
public ImmutableMap.Builder prepareScript(String script) {
    return ImmutableMap.builder().put(ES_SCRIPT_KEY,
            ImmutableMap.of(ES_SCRIPT_KEY, script, ES_LANG_KEY, scriptLang()));
}

From source file:edu.cmu.lti.oaqa.baseqa.document.rerank.scorers.OriginalScoreDocumentScorer.java

@Override
public Map<String, Double> score(JCas jcas, Document result) {
    return ImmutableMap.of("original/rank", 1.0 / (result.getRank() + 1.0), "original/score",
            result.getScore());//from   www.ja v a  2  s. c o  m
}

From source file:io.prestosql.plugin.mongodb.MongoQueryRunner.java

public static MongoQueryRunner createMongoQueryRunner(Iterable<TpchTable<?>> tables) throws Exception {
    MongoQueryRunner queryRunner = null;
    try {/*from   www.  ja  v a2 s  .co  m*/
        queryRunner = new MongoQueryRunner(createSession(), 3);

        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");

        Map<String, String> properties = ImmutableMap.of("mongodb.seeds",
                queryRunner.getAddress().getHostString() + ":" + queryRunner.getAddress().getPort(),
                "mongodb.socket-keep-alive", "true");

        queryRunner.installPlugin(new MongoPlugin());
        queryRunner.createCatalog("mongodb", "mongodb", properties);

        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);

        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}

From source file:org.apache.aurora.scheduler.http.Tiers.java

/**
 * Dumps tier configuration file (tiers.json).
 *
 * @return HTTP response.//from ww  w.  j  ava2 s  .  c o m
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getTiers() {
    ImmutableMap<String, Object> tierConfigurations = ImmutableMap.of("default",
            tierManager.getDefaultTierName(), "tiers", tierManager.getTiers());
    return Response.ok(tierConfigurations).build();
}

From source file:edu.cmu.lti.oaqa.baseqa.concept.rerank.scorers.OriginalScoreConceptScorer.java

@Override
public Map<String, Double> score(JCas jcas, ConceptSearchResult result) {
    return ImmutableMap.of("original/rank", 1.0 / (result.getRank() + 1.0), "original/score",
            result.getScore());//from w  w w.  j av a2s  . c  o  m
}

From source file:org.apache.beam.sdk.io.gcp.bigquery.BigQueryCoderRegistrar.java

@Override
public Map<Class<?>, CoderFactory> getCoderFactoriesToUseForClasses() {
    return ImmutableMap.of(TableRow.class, CoderFactories.forCoder(TableRowJsonCoder.of()), TableRowInfo.class,
            CoderFactories.forCoder(TableRowInfoCoder.of()));
}

From source file:org.janusgraph.diskstorage.es.compat.ES2Compat.java

@Override
public Map<String, Object> createKeywordMapping() {
    return ImmutableMap.of(ES_TYPE_KEY, STRING_TYPE_NAME, ES_INDEX_KEY, "not_analyzed");
}

From source file:org.jclouds.rackspace.cloudservers.us.config.CloudServersUSComputeServiceContextModule.java

/**
 * CloudServers images are accessible via the root user, not ubuntu
 */// w w  w. j  a v  a 2  s.c  o m
@Override
protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
    return ImmutableMap.of(OsFamily.WINDOWS, LoginCredentials.builder().user("Administrator").build(),
            OsFamily.UBUNTU, LoginCredentials.builder().user("root").build());
}

From source file:com.metamx.metrics.JvmMonitor.java

@Override
public boolean doMonitor(ServiceEmitter emitter) {
    // I have no idea why, but jvm/mem is slightly more than the sum of jvm/pool. Let's just include
    // them both.

    // jvm/mem/* www .  j  av a2s . co  m*/
    final Map<String, MemoryUsage> usages = ImmutableMap.of("heap",
            ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(), "nonheap",
            ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage());
    for (Map.Entry<String, MemoryUsage> entry : usages.entrySet()) {
        final String kind = entry.getKey();
        final MemoryUsage usage = entry.getValue();
        final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser1(kind);
        emitter.emit(builder.build("jvm/mem/max", usage.getMax()));
        emitter.emit(builder.build("jvm/mem/committed", usage.getCommitted()));
        emitter.emit(builder.build("jvm/mem/used", usage.getUsed()));
        emitter.emit(builder.build("jvm/mem/init", usage.getInit()));
    }

    // jvm/pool
    for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
        final String kind = pool.getType() == MemoryType.HEAP ? "heap" : "nonheap";
        final MemoryUsage usage = pool.getUsage();
        final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser1(kind)
                .setUser2(pool.getName());
        emitter.emit(builder.build("jvm/pool/max", usage.getMax()));
        emitter.emit(builder.build("jvm/pool/committed", usage.getCommitted()));
        emitter.emit(builder.build("jvm/pool/used", usage.getUsed()));
        emitter.emit(builder.build("jvm/pool/init", usage.getInit()));
    }

    // jvm/gc
    for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
        final Map<String, Long> diff = gcDiff.to(gc.getName(), ImmutableMap.of("jvm/gc/time",
                gc.getCollectionTime(), "jvm/gc/count", gc.getCollectionCount()));
        if (diff != null) {
            final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser1(gc.getName());
            for (Map.Entry<String, Long> entry : diff.entrySet()) {
                emitter.emit(builder.build(entry.getKey(), entry.getValue()));
            }
        }
    }

    return true;
}