List of usage examples for org.joda.time Instant equals
public boolean equals(Object readableInstant)
From source file:com.google.cloud.dataflow.sdk.runners.worker.WindmillTimeUtils.java
License:Apache License
/** * Convert a harness timestamp to a Windmill timestamp. *//*from ww w. j av a2s . c o m*/ static long harnessToWindmillTimestamp(Instant timestamp) { if (timestamp.equals(BoundedWindow.TIMESTAMP_MAX_VALUE)) { // End of time. return Long.MAX_VALUE; } else { return timestamp.getMillis() * 1000; } }
From source file:org.apache.beam.runners.jet.processors.StatefulParDoP.java
License:Apache License
private boolean flushTimers(long watermark) { if (timerInternals.currentInputWatermarkTime().isBefore(watermark)) { try {//from w w w . j ava 2s. com Instant watermarkInstant = new Instant(watermark); timerInternals.advanceInputWatermark(watermarkInstant); if (watermarkInstant.equals(BoundedWindow.TIMESTAMP_MAX_VALUE)) { timerInternals.advanceProcessingTime(watermarkInstant); timerInternals.advanceSynchronizedProcessingTime(watermarkInstant); } fireEligibleTimers(timerInternals); } catch (Exception e) { throw new RuntimeException("Failed advancing processing time", e); } } return outputManager.tryFlush(); }
From source file:org.apache.beam.sdk.io.kinesis.KinesisReader.java
License:Apache License
/** * Returns total size of all records that remain in Kinesis stream after current watermark. If the * watermark was not already set then it returns {@link * UnboundedSource.UnboundedReader#BACKLOG_UNKNOWN}. When currently processed record is not * further behind than {@link #upToDateThreshold} then this method returns 0. *///from w w w. j av a 2s. c om @Override public long getTotalBacklogBytes() { Instant watermark = getWatermark(); if (watermark.equals(BoundedWindow.TIMESTAMP_MIN_VALUE)) { return UnboundedSource.UnboundedReader.BACKLOG_UNKNOWN; } if (watermark.plus(upToDateThreshold).isAfterNow()) { return 0L; } if (backlogBytesLastCheckTime.plus(backlogBytesCheckThreshold).isAfterNow()) { return lastBacklogBytes; } try { lastBacklogBytes = kinesis.getBacklogBytes(source.getStreamName(), watermark); backlogBytesLastCheckTime = Instant.now(); } catch (TransientKinesisException e) { LOG.warn("Transient exception occurred.", e); } LOG.info("Total backlog bytes for {} stream with {} watermark: {}", source.getStreamName(), watermark, lastBacklogBytes); return lastBacklogBytes; }
From source file:org.apache.beam.sdk.transforms.windowing.BoundedWindow.java
License:Apache License
/** * Formats a {@link Instant} timestamp with additional Beam-specific metadata, such as indicating * whether the timestamp is the end of the global window or one of the distinguished values {@link * #TIMESTAMP_MIN_VALUE} or {@link #TIMESTAMP_MIN_VALUE}. *///from w w w .jav a2 s. c o m public static String formatTimestamp(Instant timestamp) { if (timestamp.equals(TIMESTAMP_MIN_VALUE)) { return timestamp.toString() + " (TIMESTAMP_MIN_VALUE)"; } else if (timestamp.equals(TIMESTAMP_MAX_VALUE)) { return timestamp.toString() + " (TIMESTAMP_MAX_VALUE)"; } else if (timestamp.equals(GlobalWindow.INSTANCE.maxTimestamp())) { return timestamp.toString() + " (end of global window)"; } else { return timestamp.toString(); } }
From source file:org.joda.example.time.Examples.java
License:Apache License
private void runInstant() { System.out.println("Instant"); System.out.println("======="); System.out//from w ww.j a v a2s. c o m .println("Instant stores a point in the datetime continuum as millisecs from 1970-01-01T00:00:00Z"); System.out.println("Instant is immutable and thread-safe"); System.out.println(" in = new Instant()"); Instant in = new Instant(); System.out.println("Millisecond time: in.getMillis(): " + in.getMillis()); System.out.println("ISO string version: in.toString(): " + in.toString()); System.out.println("ISO chronology: in.getChronology(): " + in.getChronology()); System.out.println("UTC time zone: in.getDateTimeZone(): " + in.getZone()); System.out.println("Change millis: in.withMillis(0): " + in.withMillis(0L)); System.out.println(""); System.out.println("Convert to Instant: in.toInstant(): " + in.toInstant()); System.out.println("Convert to DateTime: in.toDateTime(): " + in.toDateTime()); System.out.println("Convert to MutableDT: in.toMutableDateTime(): " + in.toMutableDateTime()); System.out.println("Convert to Date: in.toDate(): " + in.toDate()); System.out.println(""); System.out.println(" in2 = new Instant(in.getMillis() + 10)"); Instant in2 = new Instant(in.getMillis() + 10); System.out.println("Equals ms and chrono: in.equals(in2): " + in.equals(in2)); System.out.println("Compare millisecond: in.compareTo(in2): " + in.compareTo(in2)); System.out.println("Compare millisecond: in.isEqual(in2): " + in.isEqual(in2)); System.out.println("Compare millisecond: in.isAfter(in2): " + in.isAfter(in2)); System.out.println("Compare millisecond: in.isBefore(in2): " + in.isBefore(in2)); }