@Test public void fromEventTest() { String name = "TestName"; String namepace = "TestNamespace"; MetricContext context = new MetricContext.Builder("name").build(); TimingEvent timingEventBuilder = new TimingEvent(new EventSubmitter.Builder(context, namepace).build(), name); GobblinTrackingEvent event = timingEventBuilder.build(); timingEventBuilder.close(); TimingEvent builderFromEvent = TimingEvent.fromEvent(event); Assert.assertEquals(TimingEvent.isTimingEvent(event), true); Assert.assertNotNull(builderFromEvent); Assert.assertEquals(builderFromEvent.getName(), name); Assert.assertTrue(builderFromEvent.getStartTime() <= System.currentTimeMillis()); Assert.assertTrue(builderFromEvent.getEndTime() >= builderFromEvent.getStartTime()); Assert.assertTrue(builderFromEvent.getDuration() >= 0); event = new GobblinTrackingEvent(); timingEventBuilder = TimingEvent.fromEvent(event); Assert.assertEquals(TimingEvent.isTimingEvent(event), false); Assert.assertEquals(timingEventBuilder, null); }
public static TimingEvent fromEvent(GobblinTrackingEvent event) { if(!isTimingEvent(event)) { return null; } Map<String, String> metadata = event.getMetadata(); TimingEvent timingEvent = new TimingEvent(null, event.getName()); metadata.forEach((key, value) -> { switch (key) { case METADATA_START_TIME: timingEvent.startTime = Long.parseLong(value); break; case METADATA_END_TIME: timingEvent.endTime = Long.parseLong(value); break; case METADATA_DURATION: timingEvent.duration = Long.parseLong(value); break; default: timingEvent.addMetadata(key, value); break; } }); return timingEvent; }
TimingEvent extends GobblinEventBuilder implements Closeable { public static TimingEvent fromEvent(GobblinTrackingEvent event) { if(!isTimingEvent(event)) { return null; } Map<String, String> metadata = event.getMetadata(); TimingEvent timingEvent = new TimingEvent(null, event.getName()); metadata.forEach((key, value) -> { switch (key) { case METADATA_START_TIME: timingEvent.startTime = Long.parseLong(value); break; case METADATA_END_TIME: timingEvent.endTime = Long.parseLong(value); break; case METADATA_DURATION: timingEvent.duration = Long.parseLong(value); break; default: timingEvent.addMetadata(key, value); break; } }); return timingEvent; } }
TimingEvent extends GobblinEventBuilder implements Closeable { public static TimingEvent fromEvent(GobblinTrackingEvent event) { if(!isTimingEvent(event)) { return null; } Map<String, String> metadata = event.getMetadata(); TimingEvent timingEvent = new TimingEvent(null, event.getName()); metadata.forEach((key, value) -> { switch (key) { case METADATA_START_TIME: timingEvent.startTime = Long.parseLong(value); break; case METADATA_END_TIME: timingEvent.endTime = Long.parseLong(value); break; case METADATA_DURATION: timingEvent.duration = Long.parseLong(value); break; default: timingEvent.addMetadata(key, value); break; } }); return timingEvent; } TimingEvent(EventSubmitter submitter, String name); }
TimingEvent extends GobblinEventBuilder implements Closeable { public static TimingEvent fromEvent(GobblinTrackingEvent event) { if(!isTimingEvent(event)) { return null; } Map<String, String> metadata = event.getMetadata(); TimingEvent timingEvent = new TimingEvent(null, event.getName()); metadata.forEach((key, value) -> { switch (key) { case METADATA_START_TIME: timingEvent.startTime = Long.parseLong(value); break; case METADATA_END_TIME: timingEvent.endTime = Long.parseLong(value); break; case METADATA_DURATION: timingEvent.duration = Long.parseLong(value); break; default: timingEvent.addMetadata(key, value); break; } }); return timingEvent; } TimingEvent(EventSubmitter submitter, String name); void stop(); @Deprecated void stop(Map<String, String> additionalMetadata); void doStop(); @Override void close(); static boolean isTimingEvent(GobblinTrackingEvent event); static TimingEvent fromEvent(GobblinTrackingEvent event); }
TimingEvent extends GobblinEventBuilder implements Closeable { public static TimingEvent fromEvent(GobblinTrackingEvent event) { if(!isTimingEvent(event)) { return null; } Map<String, String> metadata = event.getMetadata(); TimingEvent timingEvent = new TimingEvent(null, event.getName()); metadata.forEach((key, value) -> { switch (key) { case METADATA_START_TIME: timingEvent.startTime = Long.parseLong(value); break; case METADATA_END_TIME: timingEvent.endTime = Long.parseLong(value); break; case METADATA_DURATION: timingEvent.duration = Long.parseLong(value); break; default: timingEvent.addMetadata(key, value); break; } }); return timingEvent; } TimingEvent(EventSubmitter submitter, String name); void stop(); @Deprecated void stop(Map<String, String> additionalMetadata); void doStop(); @Override void close(); static boolean isTimingEvent(GobblinTrackingEvent event); static TimingEvent fromEvent(GobblinTrackingEvent event); static final String METADATA_START_TIME; static final String METADATA_END_TIME; static final String METADATA_DURATION; static final String METADATA_TIMING_EVENT; static final String METADATA_MESSAGE; static final String JOB_ORCHESTRATED_TIME; static final String JOB_START_TIME; static final String JOB_END_TIME; }