List of usage examples for com.google.common.collect ImmutableList of
public static <E> ImmutableList<E> of(E element)
From source file:com.pingcap.tikv.Main.java
public static void main(String[] args) { TiConfiguration conf = TiConfiguration.createDefault(ImmutableList.of("127.0.0.1:" + 2379)); TiSession session = TiSession.create(conf); PDClient client = PDClient.createRaw(session); RegionManager mgr = new RegionManager(client); Snapshot snapshot = new Snapshot(mgr, session); Catalog cat = new Catalog(snapshot); cat.listDatabases();//from w w w.j a v a 2 s. co m }
From source file:io.imply.druid.query.ExampleMain.java
public static void main(String[] args) throws Exception { final String host = args.length == 0 ? "localhost:8082" : args[0]; try (final DruidClient druidClient = DruidClient.create(host)) { // Create a simple select query using the Druids query builder. final int threshold = 50; final SelectQuery selectQuery = Druids.newSelectQueryBuilder().dataSource("wikiticker") .intervals(ImmutableList.of(new Interval("1000/3000"))) .filters(new AndDimFilter( ImmutableList.<DimFilter>of(new SelectorDimFilter("countryName", "United States", null), new SelectorDimFilter("cityName", "San Francisco", null)))) .dimensions(ImmutableList.of("page", "user")).pagingSpec(new PagingSpec(null, threshold)) .build();/*from www. j av a 2s . c o m*/ // Fetch the results. final long startTime = System.currentTimeMillis(); final Sequence<Result<SelectResultValue>> resultSequence = druidClient.execute(selectQuery); final List<Result<SelectResultValue>> resultList = Sequences.toList(resultSequence, Lists.<Result<SelectResultValue>>newArrayList()); final long fetchTime = System.currentTimeMillis() - startTime; // Print the results. int resultCount = 0; for (final Result<SelectResultValue> result : resultList) { for (EventHolder eventHolder : result.getValue().getEvents()) { System.out.println(eventHolder.getEvent()); resultCount++; } } // Print statistics. System.out.println(String.format("Fetched %,d rows in %,dms.", resultCount, fetchTime)); } }
From source file:fi.jyu.ties454.assignment3.group0.task2.Run.java
public static void main(String[] args) throws Exception { // now a clean map is loaded InputStream is = Run.class.getResourceAsStream("rectangleRoomClean.txt"); if (is == null) { System.err.println("Did you copy the resource folder as instructed?"); System.exit(1);/*ww w . ja va 2 s . co m*/ } Floor map = Floor.readFromReader(new InputStreamReader(is, StandardCharsets.US_ASCII)); List<GameAgent> cleaners = ImmutableList.of(new MyCleaner()); // more friends to play with List<GameAgent> dirtiers = ImmutableList.of(new MyDirtier()); // Create a game with the map and the cleaners. There are also // constructors which take more arguments. They will be used in later // exercises. Game g = new Game(map, cleaners, dirtiers); // Start the game. This will also show the a 'graphical' representation // of the state of the rooms. // The agent will start on a random location on the map. g.start(); }
From source file:fi.jyu.ties454.assignment3.group0.task1.Run.java
public static void main(String[] args) throws Exception { /*/* ww w . j av a 2s .c o m*/ * Load the map from the text file 'rectangleRoom.txt'. This file has to * be in the resources folder. Note that you must have copied that * folder according to the instructions given. */ InputStream is = Run.class.getResourceAsStream("rectangleRoom.txt"); if (is == null) { System.err.println("Did you copy the resource folder as instructed?"); System.exit(1); } Floor map = Floor.readFromReader(new InputStreamReader(is, StandardCharsets.US_ASCII)); // The game needs a list of cleaners. For the first task only one // cleaner is used. List<GameAgent> cleaners = ImmutableList.of(new MyCleaner()); // Create a game with the map and the cleaners. There are also // constructors which take more arguments. They will be used in later // exercises. Game g = new Game(map, cleaners); // Start the game. This will also show the a 'graphical' representation // of the state of the rooms. // The agent will start on a random location on the map. g.start(); }
From source file:com.icosilune.fnexample.simple.Example.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("womp womp"); NodeGraph graph = new NodeGraph(new TimestampContextFactory()); List<AbstractFn> fns = ImmutableList .copyOf(Iterables.concat(ImmutableList.of(new TimestampFn()), Fn_Index.INSTANCES.values())); // need to add constants & sinks List<NodeFactory.NodeKey> nodeKeys = new ArrayList<>(); nodeKeys.add(NodeFactory.ConstantNodeKey.create(FnType.fromString("double"), 0.0)); nodeKeys.add(NodeFactory.SinkNodeKey.create(FnType.fromString("double"))); nodeKeys.addAll(NodeFactory.FnNodeKey.fromInstances(fns)); NodeGraphEvaluatorPanel graphPanel = new NodeGraphEvaluatorPanel(graph, nodeKeys); // AbstractNode node1 = new FnNode(graph, new Fn_Multiply()); // AbstractNode node2 = new ConstantNode(graph, FnType.fromString("double"), 10.0); // AbstractNode node3 = new ConstantNode(graph, FnType.fromString("double"), 10.0); // AbstractNode sink = new SinkNode(graph, FnType.fromString("double")); // graph.addNode(node1); // graph.addNode(node2); // graph.addNode(node3); // graph.addNode(sink); ///*from w ww . j a v a 2 s. c o m*/ // graph.addConnection(node1, node2, "output", "x"); // graph.addConnection(node1, node2, "output", "y"); // graph.addConnection(sink, node1, "out", "in"); graphPanel.setPreferredSize(new Dimension(500, 500)); frame.add(graphPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:com.github.jsdossier.tools.WriteDeps.java
public static void main(String[] args) throws CmdLineException, IOException { Flags flags = new Flags(); CmdLineParser parser = new CmdLineParser(flags); parser.setUsageWidth(79);/* w w w. j a v a 2s.c o m*/ parser.parseArgument(args); FileSystem fs = FileSystems.getDefault(); Path closure = fs.getPath(flags.closure); Path output = fs.getPath(flags.output); ImmutableList<SourceFile> depsFile = ImmutableList .of(SourceFile.fromFile(closure.resolve("deps.js").toString())); ImmutableList<SourceFile> sourceFiles = FluentIterable.from(flags.inputs) .transform(new Function<String, SourceFile>() { @Override public SourceFile apply(String input) { return SourceFile.fromFile(input); } }).toList(); DepsGenerator generator = new DepsGenerator(depsFile, sourceFiles, DepsGenerator.InclusionStrategy.DO_NOT_DUPLICATE, closure.toAbsolutePath().toString(), new PrintStreamErrorManager(System.err)); try (BufferedWriter writer = Files.newBufferedWriter(output, UTF_8)) { writer.write(generator.computeDependencyCalls()); writer.flush(); } }
From source file:com.hortonworks.atlas.client.AtlasEntityConnector.java
public static void main(String[] args) throws Exception { if (args.length < 0) throw new Exception("Please pass the atlas base url"); String baseurl = args[0];/* www . j a v a 2 s . com*/ String inp_type_name = args[1]; String inp_value = args[2]; String out_type_name = args[3]; String out_value = args[4]; System.out.println(baseurl); System.out.println(inp_type_name); System.out.println(inp_value); System.out.println(" Baseurl" + baseurl); AtlasEntitySearch aES = new AtlasEntitySearch(baseurl); AtlasEntityConnector aec = new AtlasEntityConnector(); aec.ac = aES.getAtlasClient(); try { Referenceable inpref = aES.getReferenceByName(inp_type_name, inp_value); Referenceable outref = aES.getReferenceByName(out_type_name, out_value); Referenceable proc = aec.loadProcess(AtlasTypeDefCreator.Type_New_Life, "AsteroidConnector", "This connects 2 Asteroids", ImmutableList.of(inpref.getId()), ImmutableList.of(outref.getId()), "Red"); aec.createEntity(proc); System.out.println(" The 2 objects are connected"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:io.wcm.devops.conga.tooling.cli.CongaCli.java
/** * CLI entry point//from w ww . j av a 2 s .c o m * @param args Command line arguments * @throws Exception */ //CHECKSTYLE:OFF public static void main(String[] args) throws Exception { //CHECKSTYLE:ON CommandLine commandLine = new DefaultParser().parse(CLI_OPTIONS, args); if (commandLine.hasOption("?")) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(150); formatter.printHelp("java -cp io.wcm.devops.conga.tooling.cli-<version>.jar " + "io.wcm.devops.conga.tooling.cli.CongaCli <arguments>", CLI_OPTIONS); return; } String templateDir = commandLine.getOptionValue("templateDir", "templates"); String roleDir = commandLine.getOptionValue("roleDir", "roles"); String environmentDir = commandLine.getOptionValue("environmentDir", "environments"); String targetDir = commandLine.getOptionValue("target", "target"); String[] environments = StringUtils.split(commandLine.getOptionValue("environments", null), ","); ResourceLoader resourceLoader = new ResourceLoader(); List<ResourceCollection> roleDirs = ImmutableList .of(resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + roleDir)); List<ResourceCollection> templateDirs = ImmutableList .of(resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + templateDir)); List<ResourceCollection> environmentDirs = ImmutableList .of(resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + environmentDir)); File targetDirecotry = new File(targetDir); Generator generator = new Generator(roleDirs, templateDirs, environmentDirs, targetDirecotry); generator.setDeleteBeforeGenerate(true); generator.generate(environments); }
From source file:com.opengamma.margining.example.EurexPrismaEtdMarginClient.java
public static void main(String[] args) throws IOException { // Initialize environment with data MarginEnvironment environment = MarginEnvironmentFactory .buildBasicEnvironment(new EurexPrismaReplication()); // Use file resolver utility to discover data from standard Eurex directory structure MarketDataFileResolver fileResolver = new MarketDataFileResolver("marketData", s_valuationDate); // Create ETD data load request, pointing to classpath, and load EurexEtdMarketDataLoadRequest etdDataLoadRequest = MarketDataLoaders.etdRequest(fileResolver); EurexMarketDataLoadRequest loadRequest = EurexMarketDataLoadRequest.etdMarketDataRequest(s_valuationDate, etdDataLoadRequest);//from www . ja v a 2s .c o m environment.getMarginData().loadData(loadRequest); // Obtain portfolio, loaded from a trade file on the classpath URL tradeFile = FileResources.byPath("trade/etdTrades.csv"); OgmLinkResolver linkResolver = environment.getInjector().getInstance(OgmLinkResolver.class); MarginPortfolio portfolio = PortfolioLoader.load(ImmutableList.of(tradeFile), linkResolver); // Build PV calculation request EurexPrismaReplicationRequest pvRequest = getPvCalculationRequest(); // Build IM calculation request EurexPrismaReplicationRequest imRequest = getImCalculationRequest(); // Grab calculator MarginCalculator calculator = environment.getMarginCalculator(); // Run PV request s_logger.info("Running PV request"); MarginResults pvResults = calculator.calculate(portfolio, pvRequest); // Print results Table<TradeWrapper<?>, TradeMeasure, Result<?>> tradePvResults = pvResults.getTradeResults().getResults(); String stringPvTable = TradeMeasureResultFormatter.formatter().truncateAfter(200).format(tradePvResults); System.out.println("PV results:\n" + stringPvTable); // Run IM request s_logger.info("Running IM request"); MarginResults imResults = calculator.calculate(portfolio, imRequest); // Print results String imResultTable = PortfolioMeasureResultFormatter.formatter().format(imResults.getPortfolioResults()); System.out.println("Portfolio results:\n" + imResultTable); System.out.println("IM result: " + imResults.getPortfolioResults().getValues().get("Total", EurexPrismaReplicationRequests.portfolioMeasures().im())); System.out.println("Historical VAR result: " + imResults.getPortfolioResults().getValues().get("Total", EurexPrismaReplicationRequests .portfolioMeasures().var("PFI01_HP2_T0-99999~FILTERED_HISTORICAL_VAR_2"))); CheckResults.checkMarginResults(imResults); }
From source file:com.opengamma.margining.example.EurexPrismaOtcMarginClient.java
public static void main(String[] args) throws IOException { // Initialize environment with data MarginEnvironment environment = MarginEnvironmentFactory .buildBasicEnvironment(new EurexPrismaReplication()); // Use file resolver utility to discover data from standard Eurex directory structure MarketDataFileResolver fileResolver = new MarketDataFileResolver("marketData", s_valuationDate); // Create fixings and holidays load request, and load MarketDataLoaders.loadGeneralData(environment.getMarginData(), fileResolver); // Create OTC data load request, pointing to classpath, and load EurexOtcMarketDataLoadRequest otcDataLoadRequest = MarketDataLoaders.otcRequest(fileResolver); EurexMarketDataLoadRequest loadRequest = EurexMarketDataLoadRequest.otcMarketDataRequest(s_valuationDate, otcDataLoadRequest);/*w w w . ja v a 2 s.co m*/ environment.getMarginData().loadData(loadRequest); // Obtain portfolio, loaded from a trade file on the classpath URL tradeFile = FileResources.byPath("trade/swapTrade.csv"); OgmLinkResolver linkResolver = environment.getInjector().getInstance(OgmLinkResolver.class); MarginPortfolio portfolio = PortfolioLoader.load(ImmutableList.of(tradeFile), linkResolver); // Build PV calculation request EurexPrismaReplicationRequest pvRequest = getPvCalculationRequest(); // Build IM calculation request EurexPrismaReplicationRequest imRequest = getImCalculationRequest(); // Grab calculator MarginCalculator calculator = environment.getMarginCalculator(); // Run PV request s_logger.info("Running PV request"); MarginResults pvResults = calculator.calculate(portfolio, pvRequest); // Print results Table<TradeWrapper<?>, TradeMeasure, Result<?>> tradePvResults = pvResults.getTradeResults().getResults(); String stringPvTable = TradeMeasureResultFormatter.formatter().truncateAfter(200).format(tradePvResults); System.out.println("PV results:\n" + stringPvTable); // Run IM request s_logger.info("Running IM request"); MarginResults imResults = calculator.calculate(portfolio, imRequest); // Print results String imResultTable = PortfolioMeasureResultFormatter.formatter().format(imResults.getPortfolioResults()); System.out.println("Portfolio results:\n" + imResultTable); System.out.println("IM result: " + imResults.getPortfolioResults().getValues().get("Total", EurexPrismaReplicationRequests.portfolioMeasures().im())); CheckResults.checkMarginResults(imResults); }