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

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

Introduction

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

Prototype

public static <E> ImmutableList<E> of(E e1, E e2, E e3) 

Source Link

Usage

From source file:fi.jyu.ties454.cleaningAgents.example.Run.java

public static void main(String[] args) throws Exception {
    InputStream is = Run.class.getResourceAsStream("map3.txt");
    Floor map = Floor.readFromReader(new InputStreamReader(is, StandardCharsets.US_ASCII));

    List<GameAgent> cleaners = ImmutableList.of(new RichCleaner1(), new Cleaner2(), new PoorCleaner());
    //List<GameAgent> cleaners = ImmutableList.of(new PoorCleaner());
    List<GameAgent> soilers = ImmutableList.of(new Soiler1(), new Soiler2(), new Soiler3());

    // Random r = new Random(467545L);
    Random r = new Random(78978L);
    Game g = new Game(map, cleaners, soilers, 300, r);
    g.start();/*  ww w . j  a v  a  2 s .c om*/
}

From source file:org.jclouds.examples.rackspace.carina.CreateContainer.java

public static void main(String[] args) throws IOException {

    DockerApi dockerApi = getDockerApiFromCarinaDirectory(args[0]);

    /**// w  w w  .j a va2s.c  o m
     * Specifying .publishAllPorts(true) in the HostConfig when *creating* the container is the simplest and
     * arguably best way to publish the ports this container will be using. Using .portBindings to specify particular
     * ports is somewhat more involved.
     *
     * However, because of https://github.com/docker/docker/issues/4635, TCP and UDP will be exposed on different
     * ports.
     */
    Container container = dockerApi.getContainerApi().createContainer("mumble",
            Config.builder().image("extra/mumble")
                    .hostConfig(HostConfig.builder().publishAllPorts(true).build())
                    .env(ImmutableList.of("MAX_USERS=50", "SERVER_TEXT=Welcome to My Mumble Server",
                            "SUPW=" + UUID.randomUUID()))
                    .build());

    String id = container.id();

    dockerApi.getContainerApi().startContainer(id);

    for (Entry<String, List<Map<String, String>>> portList : dockerApi.getContainerApi().inspectContainer(id)
            .networkSettings().ports().entrySet()) {
        for (Map<String, String> port : portList.getValue()) {
            System.out.println(
                    "Port: " + portList.getKey() + " -> " + port.get("HostIp") + ":" + port.get("HostPort"));
        }
    }

    // Cleanup
    dockerApi.getContainerApi().stopContainer(id);
    dockerApi.getContainerApi().removeContainer(id);

    dockerApi.close();
}

From source file:org.apache.metron.statistics.StatisticalBinningPerformanceDriver.java

public static void main(String... argv) {
    DescriptiveStatistics perfStats = new DescriptiveStatistics();
    OnlineStatisticsProvider statsProvider = new OnlineStatisticsProvider();
    List<Double> values = new ArrayList<>();
    GaussianRandomGenerator gaussian = new GaussianRandomGenerator(new MersenneTwister(0L));
    for (int i = 0; i < NUM_DATA_POINTS; ++i) {
        //get the data point out of the [0,1] range
        double d = 1000 * gaussian.nextNormalizedDouble();
        values.add(d);//from w w  w  . j  a v  a 2s  .c o  m
        statsProvider.addValue(d);
    }

    for (int perfRun = 0; perfRun < NUM_RUNS; ++perfRun) {
        StellarStatisticsFunctions.StatsBin bin = new StellarStatisticsFunctions.StatsBin();
        long start = System.currentTimeMillis();
        Random r = new Random(0);
        for (int i = 0; i < TRIALS_PER_RUN; ++i) {
            //grab a random value and fuzz it a bit so we make sure there's no cheating via caching in t-digest.
            bin.apply(ImmutableList.of(statsProvider, values.get(r.nextInt(values.size())) - 3.5, PERCENTILES));
        }
        perfStats.addValue(System.currentTimeMillis() - start);
    }
    System.out.println("Min/25th/50th/75th/Max Milliseconds: " + perfStats.getMin() + " / "
            + perfStats.getPercentile(25) + " / " + perfStats.getPercentile(50) + " / "
            + perfStats.getPercentile(75) + " / " + perfStats.getMax());
}

From source file:fi.jyu.ties454.assignment3.group0.task4.Fight.java

public static void main(String[] args) throws Exception {

    Fight AcleansBdirts = new Fight() {

        @Override// w w  w  .j a v a2  s. c o m
        protected List<GameAgent> getFreshCleaners() {
            // cleaners of A here
            return ImmutableList.of(new MyCleaner(), new MyCleaner(), new MyCleaner());
        }

        @Override
        protected List<GameAgent> getFreshDirtiers() {
            // dirters of B here
            return ImmutableList.of(new MyDirtier(), new MyDirtier());
        }

    };
    final double cleanersScoreA = AcleansBdirts.start();
    final double dirtiersScoreB = maxScore - cleanersScoreA;

    Fight BcleansAdirts = new Fight() {

        @Override
        protected List<GameAgent> getFreshCleaners() {
            return ImmutableList.of(new MyCleaner(), new MyCleaner(), new MyCleaner());
        }

        @Override
        protected List<GameAgent> getFreshDirtiers() {
            return ImmutableList.of(new MyDirtier(), new MyDirtier());
        }

    };

    final double cleanersScoreB = BcleansAdirts.start();
    final double dirtiersScoreA = maxScore - cleanersScoreB;

    System.out.println("FIGHT ENDED");
    System.out.printf("accumulated score for team A. Cleaners: %f, Dirtiers: %f\n", cleanersScoreA,
            dirtiersScoreA);
    System.out.printf("accumulated score for team B. Cleaners: %f, Dirtiers: %f\n", cleanersScoreB,
            dirtiersScoreB);
    System.out.println("Lower scores are better.");
}

From source file:es.upm.oeg.tools.quality.ldsniffer.util.HistrogramInputDataGenerator.java

public static void main(String[] args) {

    String endpoint = "http://infra2.dia.fi.upm.es:8899/sparql";
    //String iri = "http://linkeddata.es/resource/ldqm/QualityIndicator/Averageiridereferenceability";
    String subject = "http://linkeddata.es/resource/ldqm/QualityIndicator/Averagesubjectdereferenceability";
    String predicate = "http://linkeddata.es/resource/ldqm/QualityIndicator/Averagepredicatedereferenceability";
    String object = "http://linkeddata.es/resource/ldqm/QualityIndicator/Averageobjectdereferenceability";

    histrogram(endpoint, ImmutableList.of(subject, predicate, object));

}

From source file:org.apache.beam.runners.dataflow.worker.DataflowRunnerHarness.java

/** Fetches and processes work units from the Dataflow service. */
public static void main(String[] unusedArgs) throws Exception {
    @Nullable//from   w  w w  .j a  v a  2  s.com
    RunnerApi.Pipeline pipeline = DataflowWorkerHarnessHelper.getPipelineFromEnv();

    // This descriptor is used for all services except logging. They are isolated to keep
    // critical traffic protected from best effort traffic.
    ApiServiceDescriptor controlApiService = DataflowWorkerHarnessHelper.getControlDescriptor();
    ApiServiceDescriptor loggingApiService = DataflowWorkerHarnessHelper.getLoggingDescriptor();

    LOG.info("{} started, using port {} for control, {} for logging.", DataflowRunnerHarness.class,
            controlApiService, loggingApiService);

    DataflowWorkerHarnessHelper.initializeLogging(DataflowRunnerHarness.class);
    DataflowWorkerHarnessOptions pipelineOptions = DataflowWorkerHarnessHelper
            .initializeGlobalStateAndPipelineOptions(DataflowRunnerHarness.class);
    DataflowWorkerHarnessHelper.configureLogging(pipelineOptions);

    // Initialized registered file systems.
    FileSystems.setDefaultPipelineOptions(pipelineOptions);

    DataflowPipelineDebugOptions dataflowOptions = pipelineOptions.as(DataflowPipelineDebugOptions.class);
    ServerFactory serverFactory;
    if (DataflowRunner.hasExperiment(dataflowOptions, "beam_fn_api_epoll_domain_socket")) {
        serverFactory = ServerFactory.createEpollDomainSocket();
    } else if (DataflowRunner.hasExperiment(dataflowOptions, "beam_fn_api_epoll")) {
        serverFactory = ServerFactory.createEpollSocket();
    } else {
        serverFactory = ServerFactory.createDefault();
    }
    ServerStreamObserverFactory streamObserverFactory = ServerStreamObserverFactory
            .fromOptions(pipelineOptions);

    Server servicesServer = null;
    Server loggingServer = null;
    try (BeamFnLoggingService beamFnLoggingService = new BeamFnLoggingService(loggingApiService,
            DataflowWorkerLoggingInitializer.getSdkLoggingHandler()::publish, streamObserverFactory::from,
            GrpcContextHeaderAccessorProvider.getHeaderAccessor());
            BeamFnControlService beamFnControlService = new BeamFnControlService(controlApiService,
                    streamObserverFactory::from, GrpcContextHeaderAccessorProvider.getHeaderAccessor());
            BeamFnDataGrpcService beamFnDataService = new BeamFnDataGrpcService(pipelineOptions,
                    controlApiService, streamObserverFactory::from,
                    GrpcContextHeaderAccessorProvider.getHeaderAccessor());
            GrpcStateService beamFnStateService = GrpcStateService.create()) {

        servicesServer = serverFactory.create(
                ImmutableList.of(beamFnControlService, beamFnDataService, beamFnStateService),
                controlApiService);

        loggingServer = serverFactory.create(ImmutableList.of(beamFnLoggingService), loggingApiService);

        start(pipeline, pipelineOptions, beamFnControlService, beamFnDataService, controlApiService,
                beamFnStateService);
        servicesServer.shutdown();
        loggingServer.shutdown();
    } finally {
        if (servicesServer != null) {
            servicesServer.awaitTermination(30, TimeUnit.SECONDS);
            servicesServer.shutdownNow();
        }
        if (loggingServer != null) {
            loggingServer.awaitTermination(30, TimeUnit.SECONDS);
            loggingServer.shutdownNow();
        }
    }
}

From source file:com.github.explainable.benchmark.ConjunctionToSql.java

public static void main(String[] args) {
    Relation user = RelationImpl.create("user", ImmutableList.of("uid", "name", "hobby"));
    Relation friend = RelationImpl.create("friend", ImmutableList.of("uid1", "uid2"));

    Term uid1 = dist();/*www. j  ava  2s.  com*/
    Term uid2 = set();
    System.out.println(new ConjunctionToSql().addAtom(Atom.asMultisetAtom(user, uid2, dist(), set()))
            .addAtom(Atom.asSetAtom(friend, constant(4L), uid1)).addAtom(Atom.asSetAtom(friend, uid1, uid2))
            .toString());
}

From source file:com.facebook.presto.hive.HiveRecordCursorProviders.java

public static List<HiveRecordCursorProvider> getDefaultProviders() {
    return ImmutableList.of(new ColumnarTextHiveRecordCursorProvider(),
            new ColumnarBinaryHiveRecordCursorProvider(), new GenericHiveRecordCursorProvider());
}

From source file:org.zalando.intellij.swagger.completion.field.model.Fields.java

public static List<Field> contact() {
    return ImmutableList.of(new StringField("name"), new StringField("url"), new StringField("email"));
}

From source file:org.wisdom.framework.mustache.Cat.java

public static List<Cat> cats() {
    return ImmutableList.of(new Cat("romeo", 2), new Cat("gros minet", 8), new Cat("tom", 12));
}