@Test (enabled=false) public void testCurrentTimeWithinWindow() throws ParseException { int windowStartInHours = 2; int windowEndInHours = 5; int delayInMinutes = 0; String outputScheduledString = AzkabanAjaxAPIClient.getScheduledTimeInAzkabanFormat(windowStartInHours, windowEndInHours, delayInMinutes); Assert.assertTrue(isWithinWindow(windowStartInHours, windowEndInHours, outputScheduledString)); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") public static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes) { if (windowStartHour < 0 || windowEndHour > 23 || windowStartHour >= windowEndHour) { throw new IllegalArgumentException("Window start should be less than window end, and both should be between " + "0 and 23"); } if (delayMinutes < 0 || delayMinutes > 59) { throw new IllegalArgumentException("Delay in minutes should be between 0 and 59 (inclusive)"); } Calendar windowStartTime = Calendar.getInstance(); windowStartTime.set(Calendar.HOUR_OF_DAY, windowStartHour); windowStartTime.set(Calendar.MINUTE, 0); windowStartTime.set(Calendar.SECOND, 0); Calendar windowEndTime = Calendar.getInstance(); windowEndTime.set(Calendar.HOUR_OF_DAY, windowEndHour); windowEndTime.set(Calendar.MINUTE, 0); windowEndTime.set(Calendar.SECOND, 0); Calendar now = Calendar.getInstance(); if (now.after(windowStartTime) && now.before(windowEndTime)) { now.add(Calendar.MINUTE, delayMinutes); return new SimpleDateFormat("hh,mm,a,z").format(now.getTime()); } int allowedSchedulingWindow = (int)((windowEndTime.getTimeInMillis() - windowStartTime.getTimeInMillis()) / MILLISECONDS_IN_HOUR); int randomHourInWindow = new Random(System.currentTimeMillis()).nextInt(allowedSchedulingWindow); int randomMinute = new Random(System.currentTimeMillis()).nextInt(60); windowStartTime.add(Calendar.HOUR, randomHourInWindow); windowStartTime.set(Calendar.MINUTE, randomMinute); return new SimpleDateFormat("hh,mm,a,z").format(windowStartTime.getTime()); }
AzkabanAjaxAPIClient { @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") public static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes) { if (windowStartHour < 0 || windowEndHour > 23 || windowStartHour >= windowEndHour) { throw new IllegalArgumentException("Window start should be less than window end, and both should be between " + "0 and 23"); } if (delayMinutes < 0 || delayMinutes > 59) { throw new IllegalArgumentException("Delay in minutes should be between 0 and 59 (inclusive)"); } Calendar windowStartTime = Calendar.getInstance(); windowStartTime.set(Calendar.HOUR_OF_DAY, windowStartHour); windowStartTime.set(Calendar.MINUTE, 0); windowStartTime.set(Calendar.SECOND, 0); Calendar windowEndTime = Calendar.getInstance(); windowEndTime.set(Calendar.HOUR_OF_DAY, windowEndHour); windowEndTime.set(Calendar.MINUTE, 0); windowEndTime.set(Calendar.SECOND, 0); Calendar now = Calendar.getInstance(); if (now.after(windowStartTime) && now.before(windowEndTime)) { now.add(Calendar.MINUTE, delayMinutes); return new SimpleDateFormat("hh,mm,a,z").format(now.getTime()); } int allowedSchedulingWindow = (int)((windowEndTime.getTimeInMillis() - windowStartTime.getTimeInMillis()) / MILLISECONDS_IN_HOUR); int randomHourInWindow = new Random(System.currentTimeMillis()).nextInt(allowedSchedulingWindow); int randomMinute = new Random(System.currentTimeMillis()).nextInt(60); windowStartTime.add(Calendar.HOUR, randomHourInWindow); windowStartTime.set(Calendar.MINUTE, randomMinute); return new SimpleDateFormat("hh,mm,a,z").format(windowStartTime.getTime()); } }
AzkabanAjaxAPIClient { @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") public static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes) { if (windowStartHour < 0 || windowEndHour > 23 || windowStartHour >= windowEndHour) { throw new IllegalArgumentException("Window start should be less than window end, and both should be between " + "0 and 23"); } if (delayMinutes < 0 || delayMinutes > 59) { throw new IllegalArgumentException("Delay in minutes should be between 0 and 59 (inclusive)"); } Calendar windowStartTime = Calendar.getInstance(); windowStartTime.set(Calendar.HOUR_OF_DAY, windowStartHour); windowStartTime.set(Calendar.MINUTE, 0); windowStartTime.set(Calendar.SECOND, 0); Calendar windowEndTime = Calendar.getInstance(); windowEndTime.set(Calendar.HOUR_OF_DAY, windowEndHour); windowEndTime.set(Calendar.MINUTE, 0); windowEndTime.set(Calendar.SECOND, 0); Calendar now = Calendar.getInstance(); if (now.after(windowStartTime) && now.before(windowEndTime)) { now.add(Calendar.MINUTE, delayMinutes); return new SimpleDateFormat("hh,mm,a,z").format(now.getTime()); } int allowedSchedulingWindow = (int)((windowEndTime.getTimeInMillis() - windowStartTime.getTimeInMillis()) / MILLISECONDS_IN_HOUR); int randomHourInWindow = new Random(System.currentTimeMillis()).nextInt(allowedSchedulingWindow); int randomMinute = new Random(System.currentTimeMillis()).nextInt(60); windowStartTime.add(Calendar.HOUR, randomHourInWindow); windowStartTime.set(Calendar.MINUTE, randomMinute); return new SimpleDateFormat("hh,mm,a,z").format(windowStartTime.getTime()); }  }
AzkabanAjaxAPIClient { @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") public static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes) { if (windowStartHour < 0 || windowEndHour > 23 || windowStartHour >= windowEndHour) { throw new IllegalArgumentException("Window start should be less than window end, and both should be between " + "0 and 23"); } if (delayMinutes < 0 || delayMinutes > 59) { throw new IllegalArgumentException("Delay in minutes should be between 0 and 59 (inclusive)"); } Calendar windowStartTime = Calendar.getInstance(); windowStartTime.set(Calendar.HOUR_OF_DAY, windowStartHour); windowStartTime.set(Calendar.MINUTE, 0); windowStartTime.set(Calendar.SECOND, 0); Calendar windowEndTime = Calendar.getInstance(); windowEndTime.set(Calendar.HOUR_OF_DAY, windowEndHour); windowEndTime.set(Calendar.MINUTE, 0); windowEndTime.set(Calendar.SECOND, 0); Calendar now = Calendar.getInstance(); if (now.after(windowStartTime) && now.before(windowEndTime)) { now.add(Calendar.MINUTE, delayMinutes); return new SimpleDateFormat("hh,mm,a,z").format(now.getTime()); } int allowedSchedulingWindow = (int)((windowEndTime.getTimeInMillis() - windowStartTime.getTimeInMillis()) / MILLISECONDS_IN_HOUR); int randomHourInWindow = new Random(System.currentTimeMillis()).nextInt(allowedSchedulingWindow); int randomMinute = new Random(System.currentTimeMillis()).nextInt(60); windowStartTime.add(Calendar.HOUR, randomHourInWindow); windowStartTime.set(Calendar.MINUTE, randomMinute); return new SimpleDateFormat("hh,mm,a,z").format(windowStartTime.getTime()); }  static String authenticateAndGetSessionId(String username, String password, String azkabanServerUrl); static String getProjectId(String sessionId, AzkabanProjectConfig azkabanProjectConfig); static String createAzkabanProject(String sessionId, String zipFilePath,
      AzkabanProjectConfig azkabanProjectConfig); static void deleteAzkabanProject(String sessionId, AzkabanProjectConfig azkabanProjectConfig); static String replaceAzkabanProject(String sessionId, String zipFilePath,
      AzkabanProjectConfig azkabanProjectConfig); static void scheduleAzkabanProject(String sessionId, String azkabanProjectId,
      AzkabanProjectConfig azkabanProjectConfig); static void executeAzkabanProject(String sessionId, String azkabanProjectId,
      AzkabanProjectConfig azkabanProjectConfig); @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes); }
AzkabanAjaxAPIClient { @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") public static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes) { if (windowStartHour < 0 || windowEndHour > 23 || windowStartHour >= windowEndHour) { throw new IllegalArgumentException("Window start should be less than window end, and both should be between " + "0 and 23"); } if (delayMinutes < 0 || delayMinutes > 59) { throw new IllegalArgumentException("Delay in minutes should be between 0 and 59 (inclusive)"); } Calendar windowStartTime = Calendar.getInstance(); windowStartTime.set(Calendar.HOUR_OF_DAY, windowStartHour); windowStartTime.set(Calendar.MINUTE, 0); windowStartTime.set(Calendar.SECOND, 0); Calendar windowEndTime = Calendar.getInstance(); windowEndTime.set(Calendar.HOUR_OF_DAY, windowEndHour); windowEndTime.set(Calendar.MINUTE, 0); windowEndTime.set(Calendar.SECOND, 0); Calendar now = Calendar.getInstance(); if (now.after(windowStartTime) && now.before(windowEndTime)) { now.add(Calendar.MINUTE, delayMinutes); return new SimpleDateFormat("hh,mm,a,z").format(now.getTime()); } int allowedSchedulingWindow = (int)((windowEndTime.getTimeInMillis() - windowStartTime.getTimeInMillis()) / MILLISECONDS_IN_HOUR); int randomHourInWindow = new Random(System.currentTimeMillis()).nextInt(allowedSchedulingWindow); int randomMinute = new Random(System.currentTimeMillis()).nextInt(60); windowStartTime.add(Calendar.HOUR, randomHourInWindow); windowStartTime.set(Calendar.MINUTE, randomMinute); return new SimpleDateFormat("hh,mm,a,z").format(windowStartTime.getTime()); }  static String authenticateAndGetSessionId(String username, String password, String azkabanServerUrl); static String getProjectId(String sessionId, AzkabanProjectConfig azkabanProjectConfig); static String createAzkabanProject(String sessionId, String zipFilePath,
      AzkabanProjectConfig azkabanProjectConfig); static void deleteAzkabanProject(String sessionId, AzkabanProjectConfig azkabanProjectConfig); static String replaceAzkabanProject(String sessionId, String zipFilePath,
      AzkabanProjectConfig azkabanProjectConfig); static void scheduleAzkabanProject(String sessionId, String azkabanProjectId,
      AzkabanProjectConfig azkabanProjectConfig); static void executeAzkabanProject(String sessionId, String azkabanProjectId,
      AzkabanProjectConfig azkabanProjectConfig); @edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "DMI_RANDOM_USED_ONLY_ONCE", justification = "As expected for randomization") static String getScheduledTimeInAzkabanFormat(int windowStartHour, int windowEndHour, int delayMinutes);  }