List of usage examples for org.joda.time Instant toString
public String toString(DateTimeFormatter formatter)
From source file:com.google.cloud.dataflow.examples.opinionanalysis.util.PartitionedTableRef.java
License:Apache License
/** * input - a tupel that contains the data element (TableRow), the window, the timestamp, and the pane *//* w w w . j a v a 2 s .c o m*/ @Override public TableDestination apply(ValueInSingleWindow<TableRow> input) { String partition; if (this.isTimeField) { String sTime = (String) input.getValue().get(this.fieldName); Instant time = Instant.parse(sTime); partition = time.toString(partitionFormatter); } else { partition = ((Integer) input.getValue().get(this.fieldName)).toString(); } TableReference reference = new TableReference(); reference.setProjectId(this.projectId); reference.setDatasetId(this.datasetId); reference.setTableId(this.partitionPrefix + partition); return new TableDestination(reference, null); }
From source file:com.spotify.helios.cli.command.DeploymentGroupWatchCommand.java
License:Apache License
@Override int run(Namespace options, HeliosClient client, PrintStream out, boolean json, BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final boolean full = options.getBoolean(fullArg.getDest()); final Integer interval = options.getInt(intervalArg.getDest()); final DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_TIME_PATTERN); if (!json) {/*from www . j a v a2 s .c o m*/ out.println("Control-C to stop"); out.println("STATUS HOST STATE"); } final int timestampLength = String.format("[%s UTC]", DATE_TIME_PATTERN).length(); int rc = 0; while (rc == 0) { final Instant now = new Instant(); if (!json) { out.printf(Strings.repeat("-", MAX_WIDTH - timestampLength - 1) + " [%s UTC]%n", now.toString(formatter)); } rc = DeploymentGroupStatusCommand.run0(client, out, json, name, full); if (out.checkError()) { break; } Thread.sleep(1000 * interval); } return 0; }
From source file:com.spotify.helios.cli.command.JobWatchCommand.java
License:Apache License
static void watchJobsOnHosts(final PrintStream out, final boolean exact, final List<String> prefixes, final Set<JobId> jobIds, final int interval, final List<TargetAndClient> clients) throws InterruptedException, ExecutionException { out.println("Control-C to stop"); out.println("JOB HOST STATE THROTTLED?"); final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss"); while (true) { final Instant now = new Instant(); out.printf("-------------------- ------------------------------ -------- " + "---------- [%s UTC]%n", now.toString(formatter)); for (final TargetAndClient cc : clients) { final Optional<Target> target = cc.getTarget(); if (clients.size() > 1) { final String header; if (target.isPresent()) { final List<URI> endpoints = target.get().getEndpointSupplier().get(); header = format(" %s (%s)", target.get().getName(), endpoints); } else { header = ""; }//from w ww . jav a 2s . co m out.printf("---%s%n", header); } showReport(out, exact, prefixes, jobIds, formatter, cc.getClient()); } if (out.checkError()) { break; } Thread.sleep(1000 * interval); } }