@Override public Message read() { Message message = null; try { if (available) { T data = reader.getCurrent(); org.joda.time.Instant timestamp = reader.getCurrentTimestamp(); message = new DefaultMessage( WindowedValue.timestampedValueInGlobalWindow(data, timestamp), timestamp.getMillis()); } available = reader.advance(); } catch (Exception e) { close(); throw new RuntimeException(e); } return message; }
private boolean tryProduceNext() { try (Closeable ignored = MetricsEnvironment.scopedMetricsContainer(metricsContainer)) { if (closed) { return FAILED_TO_OBTAIN_NEXT; } else { checkState(next == null, "unexpected non-null value for next"); if (seekNext()) { next = WindowedValue.timestampedValueInGlobalWindow( reader.getCurrent(), reader.getCurrentTimestamp()); return SUCCESSFULLY_OBTAINED_NEXT; } else { close(); return FAILED_TO_OBTAIN_NEXT; } } } catch (final Exception e) { throw new RuntimeException("Failed to read data.", e); } }