List of usage examples for com.google.common.collect Lists newArrayList
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
From source file:ivory.app.PreprocessEnglishWikipediaSimple.java
public static void main(String[] args) throws Exception { Map<String, String> map = new ImmutableMap.Builder<String, String>() .put(PreprocessCollection.COLLECTION_NAME, "Wikipedia") .put(PreprocessCollection.DOCNO_MAPPING, WikipediaDocnoMapping.class.getCanonicalName()) .put(PreprocessCollection.INPUTFORMAT, WikipediaPageInputFormat.class.getCanonicalName()) .put(PreprocessCollection.TOKENIZER, GalagoTokenizer.class.getCanonicalName()) .put(PreprocessCollection.MIN_DF, "2").build(); List<String> s = Lists.newArrayList(args); for (Map.Entry<String, String> e : map.entrySet()) { s.add("-" + e.getKey()); s.add(e.getValue());//from w ww . ja v a2 s. c o m } ToolRunner.run(new PreprocessTrec45(), s.toArray(new String[s.size()])); }
From source file:io.soabase.example.admin.ExampleAdminConsoleMain.java
@SuppressWarnings("ParameterCanBeLocal") public static void main(String[] args) throws Exception { TabComponent component = TabComponentBuilder.builder().withId("custom").withName("Custom Tab") .withContentResourcePath("admin/custom/assets/custom.html").addingAssetsPath("/admin/custom/assets") .addingJavascriptUriPath("/admin/custom/assets/js/custom.js") .addingCssUriPath("/admin/custom/assets/css/custom.css").build(); List<Metric> metrics = Lists.newArrayList(new Metric("random", "gauges['goodbye-random'].value")); MetricComponent customMetric = new MetricComponent("custom-metric", MetricType.STANDARD, "Custom", "Value", metrics);/*from www . ja v a 2s . c o m*/ AdminConsoleApp<ExampleAdminConfiguration> app = AdminConsoleAppBuilder.<ExampleAdminConfiguration>builder() .withAppName("Example").withCompanyName("My Company") .withConfigurationClass(ExampleAdminConfiguration.class).addingTabComponent(component) .addingMetricComponent(customMetric) .addingBundle( new BundleSpec<>(new CuratorBundle<ExampleAdminConfiguration>(), BundleSpec.Phase.PRE_SOA)) .addingBundle( new BundleSpec<>(new SqlBundle<ExampleAdminConfiguration>(), BundleSpec.Phase.PRE_SOA)) .build(); app.run(ExampleAppBase.setSystemAndAdjustArgs("admin/config.json")); }
From source file:org.apache.kylin.engine.streaming.cli.MonitorCLI.java
public static void main(String[] args) { Preconditions.checkArgument(args[0].equals("monitor")); int i = 1;//from ww w. j a v a 2 s. com List<String> receivers = null; String host = null; String tableName = null; String authorization = null; String cubeName = null; String projectName = "default"; while (i < args.length) { String argName = args[i]; switch (argName) { case "-receivers": receivers = Lists.newArrayList(StringUtils.split(args[++i], ";")); break; case "-host": host = args[++i]; break; case "-tableName": tableName = args[++i]; break; case "-authorization": authorization = args[++i]; break; case "-cubeName": cubeName = args[++i]; break; case "-projectName": projectName = args[++i]; break; default: throw new RuntimeException("invalid argName:" + argName); } i++; } Preconditions.checkArgument(receivers != null && receivers.size() > 0); final StreamingMonitor streamingMonitor = new StreamingMonitor(); if (tableName != null) { logger.info(String.format("check query tableName:%s host:%s receivers:%s", tableName, host, StringUtils.join(receivers, ";"))); Preconditions.checkNotNull(host); Preconditions.checkNotNull(authorization); Preconditions.checkNotNull(tableName); streamingMonitor.checkCountAll(receivers, host, authorization, projectName, tableName); } if (cubeName != null) { logger.info(String.format("check cube cubeName:%s receivers:%s", cubeName, StringUtils.join(receivers, ";"))); streamingMonitor.checkCube(receivers, cubeName, host); } System.exit(0); }
From source file:edu.tufts.eaftan.hprofparser.Parse.java
public static void main(String[] args) { List<String> argList = Lists.newArrayList(args); if (argList.size() < 1) { System.out.println("Usage: java Parse [--handler=<handler class>] inputfile"); System.exit(1);/*from w w w .j a v a 2 s .c o m*/ } Class<? extends RecordHandler> handlerClass = DEFAULT_HANDLER; for (String arg : argList) { if (arg.startsWith("--handler=")) { String handlerClassName = arg.substring("--handler=".length()); try { handlerClass = (Class<? extends RecordHandler>) Class.forName(handlerClassName); } catch (ClassNotFoundException e) { System.err.println("Could not find class " + handlerClassName); System.exit(1); } } } RecordHandler handler = null; try { handler = handlerClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { System.err.println("Could not instantiate " + handlerClass); System.exit(1); } HprofParser parser = new HprofParser(handler); try { parser.parse(new File(argList.get(argList.size() - 1))); } catch (IOException e) { System.err.println(e); } }
From source file:com.youtube.indianmovies.commandline.live.ListBroadcasts.java
/** * List broadcasts for the user's channel. * * @param args command line args (not used). *//*from w w w . j a v a 2 s .co m*/ public static void main(String[] args) { // This OAuth 2.0 access scope allows for read-only access to the // authenticated user's account, but not other types of account access. List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube.readonly"); try { // Authorize the request. Credential credential = Auth.authorize(scopes, "listbroadcasts"); // This object is used to make YouTube Data API requests. youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential) .setApplicationName("youtube-cmdline-listbroadcasts-sample").build(); // Create a request to list broadcasts. YouTube.LiveBroadcasts.List liveBroadcastRequest = youtube.liveBroadcasts().list("id,snippet"); // Indicate that the API response should not filter broadcasts // based on their status. liveBroadcastRequest.setBroadcastStatus("all"); // Execute the API request and return the list of broadcasts. LiveBroadcastListResponse returnedListResponse = liveBroadcastRequest.execute(); List<LiveBroadcast> returnedList = returnedListResponse.getItems(); // Print information from the API response. System.out.println("\n================== Returned Broadcasts ==================\n"); for (LiveBroadcast broadcast : returnedList) { System.out.println(" - Id: " + broadcast.getId()); System.out.println(" - Title: " + broadcast.getSnippet().getTitle()); System.out.println(" - Description: " + broadcast.getSnippet().getDescription()); System.out.println(" - Published At: " + broadcast.getSnippet().getPublishedAt()); System.out.println(" - Scheduled Start Time: " + broadcast.getSnippet().getScheduledStartTime()); System.out.println(" - Scheduled End Time: " + broadcast.getSnippet().getScheduledEndTime()); System.out.println("\n-------------------------------------------------------------\n"); } } catch (GoogleJsonResponseException e) { System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("IOException: " + e.getMessage()); e.printStackTrace(); } catch (Throwable t) { System.err.println("Throwable: " + t.getMessage()); t.printStackTrace(); } }
From source file:com.youtube.indianmovies.data.AddSubscription.java
/** * Subscribe the user's YouTube account to a user-selected channel. * * @param args command line args (not used). *///from ww w . j a va 2 s . c om public static void main(String[] args) { // This OAuth 2.0 access scope allows for full read/write access to the // authenticated user's account. List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube"); try { // Authorize the request. Credential credential = Auth.authorize(scopes, "addsubscription"); // This object is used to make YouTube Data API requests. youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential) .setApplicationName("youtube-cmdline-addsubscription-sample").build(); // We get the user selected channel to subscribe. // Retrieve the channel ID that the user is subscribing to. String channelId = getChannelId(); System.out.println("You chose " + channelId + " to subscribe."); // Create a resourceId that identifies the channel ID. ResourceId resourceId = new ResourceId(); resourceId.setChannelId(channelId); resourceId.setKind("youtube#channel"); // Create a snippet that contains the resourceId. SubscriptionSnippet snippet = new SubscriptionSnippet(); snippet.setResourceId(resourceId); // Create a request to add the subscription and send the request. // The request identifies subscription metadata to insert as well // as information that the API server should return in its response. Subscription subscription = new Subscription(); subscription.setSnippet(snippet); YouTube.Subscriptions.Insert subscriptionInsert = youtube.subscriptions() .insert("snippet,contentDetails", subscription); Subscription returnedSubscription = subscriptionInsert.execute(); // Print information from the API response. System.out.println("\n================== Returned Subscription ==================\n"); System.out.println(" - Id: " + returnedSubscription.getId()); System.out.println(" - Title: " + returnedSubscription.getSnippet().getTitle()); } catch (GoogleJsonResponseException e) { System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("IOException: " + e.getMessage()); e.printStackTrace(); } catch (Throwable t) { System.err.println("Throwable: " + t.getMessage()); t.printStackTrace(); } }
From source file:com.youtube.indianmovies.commandline.live.CreateBroadcast.java
/** * Create and insert a liveBroadcast resource. *///ww w.ja v a 2s.c o m public static void main(String[] args) { // This OAuth 2.0 access scope allows for full read/write access to the // authenticated user's account. List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube"); try { // Authorize the request. Credential credential = Auth.authorize(scopes, "createbroadcast"); // This object is used to make YouTube Data API requests. youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential) .setApplicationName("youtube-cmdline-createbroadcast-sample").build(); // Prompt the user to enter a title for the broadcast. String title = getBroadcastTitle(); System.out.println("You chose " + title + " for broadcast title."); // Create a snippet with the title and scheduled start and end // times for the broadcast. Currently, those times are hard-coded. LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet(); broadcastSnippet.setTitle(title); broadcastSnippet.setScheduledStartTime(new DateTime("2024-01-30T00:00:00.000Z")); broadcastSnippet.setScheduledEndTime(new DateTime("2024-01-31T00:00:00.000Z")); // Set the broadcast's privacy status to "private". See: // https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#status.privacyStatus LiveBroadcastStatus status = new LiveBroadcastStatus(); status.setPrivacyStatus("private"); LiveBroadcast broadcast = new LiveBroadcast(); broadcast.setKind("youtube#liveBroadcast"); broadcast.setSnippet(broadcastSnippet); broadcast.setStatus(status); // Construct and execute the API request to insert the broadcast. YouTube.LiveBroadcasts.Insert liveBroadcastInsert = youtube.liveBroadcasts().insert("snippet,status", broadcast); LiveBroadcast returnedBroadcast = liveBroadcastInsert.execute(); // Print information from the API response. System.out.println("\n================== Returned Broadcast ==================\n"); System.out.println(" - Id: " + returnedBroadcast.getId()); System.out.println(" - Title: " + returnedBroadcast.getSnippet().getTitle()); System.out.println(" - Description: " + returnedBroadcast.getSnippet().getDescription()); System.out.println(" - Published At: " + returnedBroadcast.getSnippet().getPublishedAt()); System.out .println(" - Scheduled Start Time: " + returnedBroadcast.getSnippet().getScheduledStartTime()); System.out.println(" - Scheduled End Time: " + returnedBroadcast.getSnippet().getScheduledEndTime()); // Prompt the user to enter a title for the video stream. title = getStreamTitle(); System.out.println("You chose " + title + " for stream title."); // Create a snippet with the video stream's title. LiveStreamSnippet streamSnippet = new LiveStreamSnippet(); streamSnippet.setTitle(title); // Define the content distribution network settings for the // video stream. The settings specify the stream's format and // ingestion type. See: // https://developers.google.com/youtube/v3/live/docs/liveStreams#cdn CdnSettings cdnSettings = new CdnSettings(); cdnSettings.setFormat("1080p"); cdnSettings.setIngestionType("rtmp"); LiveStream stream = new LiveStream(); stream.setKind("youtube#liveStream"); stream.setSnippet(streamSnippet); stream.setCdn(cdnSettings); // Construct and execute the API request to insert the stream. YouTube.LiveStreams.Insert liveStreamInsert = youtube.liveStreams().insert("snippet,cdn", stream); LiveStream returnedStream = liveStreamInsert.execute(); // Print information from the API response. System.out.println("\n================== Returned Stream ==================\n"); System.out.println(" - Id: " + returnedStream.getId()); System.out.println(" - Title: " + returnedStream.getSnippet().getTitle()); System.out.println(" - Description: " + returnedStream.getSnippet().getDescription()); System.out.println(" - Published At: " + returnedStream.getSnippet().getPublishedAt()); // Construct and execute a request to bind the new broadcast // and stream. YouTube.LiveBroadcasts.Bind liveBroadcastBind = youtube.liveBroadcasts().bind(returnedBroadcast.getId(), "id,contentDetails"); liveBroadcastBind.setStreamId(returnedStream.getId()); returnedBroadcast = liveBroadcastBind.execute(); // Print information from the API response. System.out.println("\n================== Returned Bound Broadcast ==================\n"); System.out.println(" - Broadcast Id: " + returnedBroadcast.getId()); System.out.println(" - Bound Stream Id: " + returnedBroadcast.getContentDetails().getBoundStreamId()); } catch (GoogleJsonResponseException e) { System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("IOException: " + e.getMessage()); e.printStackTrace(); } catch (Throwable t) { System.err.println("Throwable: " + t.getMessage()); t.printStackTrace(); } }
From source file:com.youtube.indianmovies.data.PlaylistUpdates.java
/** * Authorize the user, create a playlist, and add an item to the playlist. * * @param args command line args (not used). *///from w w w.ja v a 2s . com public static void main(String[] args) { // This OAuth 2.0 access scope allows for full read/write access to the // authenticated user's account. List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube"); try { // Authorize the request. Credential credential = Auth.authorize(scopes, "playlistupdates"); // This object is used to make YouTube Data API requests. youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential) .setApplicationName("youtube-cmdline-playlistupdates-sample").build(); // Create a new, private playlist in the authorized user's channel. String playlistId = insertPlaylist(); // If a valid playlist was created, add a video to that playlist. insertPlaylistItem(playlistId, VIDEO_ID); } catch (GoogleJsonResponseException e) { System.err.println( "There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("IOException: " + e.getMessage()); e.printStackTrace(); } catch (Throwable t) { System.err.println("Throwable: " + t.getMessage()); t.printStackTrace(); } }
From source file:brooklyn.demo.StormSampleApp.java
public static void main(String[] argv) { List<String> args = Lists.newArrayList(argv); String port = CommandLineUtil.getCommandLineOption(args, "--port", "8081+"); String location = CommandLineUtil.getCommandLineOption(args, "--location", DEFAULT_LOCATION); BrooklynLauncher launcher = BrooklynLauncher.newInstance().application( EntitySpec.create(StartableApplication.class, StormSampleApp.class).displayName("Storm App")) .webconsolePort(port).location(location).start(); Entities.dumpInfo(launcher.getApplications()); }
From source file:com.google.api.services.samples.calendar.sync.SyncTokenSample.java
public static void main(String[] args) { try {/*from w ww .j a v a 2 s . c om*/ List<String> scopes = Lists.newArrayList(CalendarScopes.CALENDAR_READONLY); client = Utils.createCalendarClient(scopes); eventDataStore = Utils.getDataStoreFactory().getDataStore("EventStore"); syncSettingsDataStore = Utils.getDataStoreFactory().getDataStore("SyncSettings"); run(); } catch (Throwable t) { t.printStackTrace(); System.exit(1); } }