JobManager { static String toRichTimeDuration(long duration) { long days = TimeUnit.SECONDS.toDays(duration); duration -= TimeUnit.DAYS.toSeconds(days); long hours = TimeUnit.SECONDS.toHours(duration); duration -= TimeUnit.HOURS.toSeconds(hours); long minutes = TimeUnit.SECONDS.toMinutes(duration); duration -= TimeUnit.MINUTES.toSeconds(minutes); long seconds = TimeUnit.SECONDS.toSeconds(duration); StringBuilder builder = new StringBuilder(); if (days != 0) { builder.append(days + " days "); } if (days != 0 || hours != 0) { builder.append(hours + " hours "); } if (days != 0 || hours != 0 || minutes != 0) { builder.append(minutes + " minutes "); } builder.append(seconds + " seconds"); return builder.toString(); } JobManager(FlinkZeppelinContext z,
                    String flinkWebUrl,
                    String replacedFlinkWebUrl,
                    Properties properties); void addJob(InterpreterContext context, JobClient jobClient); void removeJob(String paragraphId); void sendFlinkJobUrl(InterpreterContext context); int getJobProgress(String paragraphId); void cancelJob(InterpreterContext context); void shutdown(); static final String LATEST_CHECKPOINT_PATH; static final String SAVEPOINT_PATH; static final String RESUME_FROM_SAVEPOINT; static final String RESUME_FROM_CHECKPOINT; static final String SAVEPOINT_DIR; }
@Test public void testRichDuration() { String richDuration = JobManager.toRichTimeDuration(18); assertEquals("18 seconds", richDuration); richDuration = JobManager.toRichTimeDuration(120); assertEquals("2 minutes 0 seconds", richDuration); richDuration = JobManager.toRichTimeDuration(60 * 60 + 1); assertEquals("1 hours 0 minutes 1 seconds", richDuration); richDuration = JobManager.toRichTimeDuration(60 * 60 + 60 + 1); assertEquals("1 hours 1 minutes 1 seconds", richDuration); richDuration = JobManager.toRichTimeDuration(24 * 60 * 60 + 60 + 1); assertEquals("1 days 0 hours 1 minutes 1 seconds", richDuration); }