public void setStartDateTime(LocalDateTime startDateTime) { this.startDateTime = startDateTime; durationInMinutes = (startDateTime == null || endDateTime == null) ? null : (int) Duration.between(startDateTime, endDateTime).toMinutes(); }
public Timeslot withStartDateTime(LocalDateTime startDateTime) { this.startDateTime = startDateTime; durationInMinutes = (startDateTime == null || endDateTime == null) ? null : (int) Duration.between(startDateTime, endDateTime).toMinutes(); return this; }
public Timeslot withEndDateTime(LocalDateTime endDateTime) { this.endDateTime = endDateTime; durationInMinutes = (startDateTime == null || endDateTime == null) ? null : (int) Duration.between(startDateTime, endDateTime).toMinutes(); return this; } }
public void setEndDateTime(LocalDateTime endDateTime) { this.endDateTime = endDateTime; durationInMinutes = (startDateTime == null || endDateTime == null) ? null : (int) Duration.between(startDateTime, endDateTime).toMinutes(); }
/** * @return The deregisterCriticalServiceAfter as a {@link Optional} */ public Optional<String> getDeregisterCriticalServiceAfter() { if (deregisterCriticalServiceAfter == null) { return Optional.empty(); } return Optional.of(deregisterCriticalServiceAfter.toMinutes() + "m"); }
private void validateMaxWaitMins(final FlowTriggerBean flowTriggerBean) { Preconditions.checkArgument(flowTriggerBean.getTriggerDependencies().isEmpty() || flowTriggerBean.getMaxWaitMins() != null, "max wait min cannot be null unless no dependency is defined"); if (flowTriggerBean.getMaxWaitMins() != null) { Preconditions.checkArgument(flowTriggerBean.getMaxWaitMins() >= Constants .MIN_FLOW_TRIGGER_WAIT_TIME.toMinutes(), "max wait min must be at least " + Constants .MIN_FLOW_TRIGGER_WAIT_TIME.toMinutes() + " min(s)"); } }
private void writeConferenceSolution(int dayListSize, int roomListSize) { int labTimeslotCount = (int) timeslotOptions.stream() .filter(pair -> Duration.between(pair.getLeft(), pair.getRight()).toMinutes() >= 120).count(); int labRoomCount = roomListSize / 5; labTalkCount = (dayListSize * labTimeslotCount) * labRoomCount; int timeslotListSize = dayListSize * timeslotOptions.size(); int talkListSize = (dayListSize * (timeslotOptions.size() - labTimeslotCount)) * (roomListSize - labRoomCount) + labTalkCount; int speakerListSize = talkListSize * 2 / 3; String fileName = talkListSize + "talks-" + timeslotListSize + "timeslots-" + roomListSize + "rooms"; File outputFile = new File(outputDir, fileName + "." + solutionFileIO.getOutputFileExtension()); ConferenceSolution solution = createConferenceSolution( fileName, timeslotListSize, roomListSize, speakerListSize, talkListSize); solutionFileIO.write(solution, outputFile); }
public int getOverlapInMinutes(Timeslot other) { if (this == other) { return durationInMinutes; } LocalDateTime startMaximum = (startDateTime.compareTo(other.startDateTime) < 0) ? other.startDateTime : startDateTime; LocalDateTime endMinimum = (endDateTime.compareTo(other.endDateTime) < 0) ? endDateTime : other.endDateTime; return (int) Duration.between(startMaximum, endMinimum).toMinutes(); }
@Inject public ExecutorHealthChecker(final Props azkProps, final ExecutorLoader executorLoader, final ExecutorApiGateway apiGateway, final AlerterHolder alerterHolder) { this.healthCheckIntervalMin = azkProps .getLong(ConfigurationKeys.AZKABAN_EXECUTOR_HEALTHCHECK_INTERVAL_MIN, DEFAULT_EXECUTOR_HEALTHCHECK_INTERVAL.toMinutes()); this.executorMaxFailureCount = azkProps.getInt(ConfigurationKeys .AZKABAN_EXECUTOR_MAX_FAILURE_COUNT, DEFAULT_EXECUTOR_MAX_FAILURE_COUNT); this.alertEmails = azkProps.getStringList(ConfigurationKeys.AZKABAN_ADMIN_ALERT_EMAIL); this.scheduler = Executors.newSingleThreadScheduledExecutor(); this.executorLoader = executorLoader; this.apiGateway = apiGateway; this.alerterHolder = alerterHolder; }
public static String elapsedTime(Date d1, Date d2){ try{ Duration period = Duration.between(d1.toInstant(), d2.toInstant()); // Note: this will become easier with Java 9, using toDaysPart() etc. long days = period.toDays(); period = period.minusDays(days); long hours = period.toHours(); period = period.minusHours(hours); long minutes = period.toMinutes(); period = period.minusMinutes(minutes); long seconds = period.getSeconds(); return days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds"; } catch(java.lang.IllegalArgumentException e) { log.warn(e); } return ""; }
private long getSessionTimeoutInMinutes() { Duration sessionTimeout = getSession().getTimeout(); if (isZeroOrLess(sessionTimeout)) { return 0; } return Math.max(sessionTimeout.toMinutes(), 1); }
long minutes = p.toMinutes() % 60; long seconds = p.getSeconds() % 60; long milis = p.toMillis() % 1000;
private void ajaxFetchTrigger(final int projectId, final String flowId, final Session session, final HashMap<String, Object> ret) { final ScheduledFlowTrigger res = this.scheduler .getScheduledFlowTriggerJobs().stream().filter( scheduledFlowTrigger -> scheduledFlowTrigger.getFlowId().equals(flowId) && scheduledFlowTrigger.getProjectId () == projectId).findFirst().orElse(null); if (res != null) { final Map<String, Object> jsonObj = new HashMap<>(); jsonObj.put("cronExpression", res.getFlowTrigger().getSchedule().getCronExpression()); jsonObj.put("submitUser", res.getSubmitUser()); jsonObj.put("firstSchedTime", utils.formatDateTime(res.getQuartzTrigger().getStartTime().getTime())); jsonObj.put("nextExecTime", utils.formatDateTime(res.getQuartzTrigger().getNextFireTime().getTime())); Long maxWaitMin = null; if (res.getFlowTrigger().getMaxWaitDuration().isPresent()) { maxWaitMin = res.getFlowTrigger().getMaxWaitDuration().get().toMinutes(); } jsonObj.put("maxWaitMin", maxWaitMin); if (!res.getFlowTrigger().getDependencies().isEmpty()) { jsonObj.put("dependencies", res.getDependencyListJson()); } ret.put("flowTrigger", jsonObj); } }
public FlowTrigger toFlowTrigger(final FlowTriggerBean flowTriggerBean) { if (flowTriggerBean == null) { return null; } else { validateFlowTriggerBean(flowTriggerBean); if (flowTriggerBean.getMaxWaitMins() != null && flowTriggerBean.getMaxWaitMins() > Constants.DEFAULT_FLOW_TRIGGER_MAX_WAIT_TIME .toMinutes()) { flowTriggerBean.setMaxWaitMins(Constants.DEFAULT_FLOW_TRIGGER_MAX_WAIT_TIME.toMinutes()); } final Duration duration = flowTriggerBean.getMaxWaitMins() == null ? null : Duration .ofMinutes(flowTriggerBean.getMaxWaitMins()); return new FlowTrigger( new CronSchedule(flowTriggerBean.getSchedule().get(FlowTriggerProps.SCHEDULE_VALUE)), flowTriggerBean.getTriggerDependencies().stream() .map(d -> new FlowTriggerDependency(d.getName(), d.getType(), d.getParams())) .collect(Collectors.toList()), duration); } }
@Override public Argument build(Duration duration, ConfigRegistry config) { Duration d = duration; final boolean isNegative = d.isNegative(); if (isNegative) { d = d.negated(); } final long days = d.toDays(); if (days > Integer.MAX_VALUE) { throw new IllegalArgumentException( String.format("duration %s too large to be represented unambiguously as postgres interval", d)); } d = d.minusDays(days); final int hours = (int) d.toHours(); d = d.minusHours(hours); final int minutes = (int) d.toMinutes(); d = d.minusMinutes(minutes); if (d.getNano() % 1000 != 0) { throw new IllegalArgumentException( String.format("duration %s too precise to represented as postgres interval", d)); } double seconds = d.getSeconds() + d.getNano() / 1e9; final PGInterval interval = new PGInterval(0, 0, (int) days, hours, minutes, seconds); if (isNegative) { interval.scale(-1); } return ObjectArgument.of(interval, Types.OTHER); } }
@Test public void testFlowTriggerMaxWaitMinValidation() throws Exception { final NodeBeanLoader loader = new NodeBeanLoader(); final NodeBean nodeBean = loader.load(ExecutionsTestUtil.getFlowFile( TRIGGER_FLOW_YML_TEST_DIR, "flow_trigger_no_max_wait_min.flow")); assertThatThrownBy(() -> loader.toFlowTrigger(nodeBean.getTrigger())) .isInstanceOf(IllegalArgumentException.class) .hasMessage("max wait min cannot be null unless no dependency is defined"); final NodeBean nodeBean2 = loader.load(ExecutionsTestUtil.getFlowFile( TRIGGER_FLOW_YML_TEST_DIR, "flow_trigger_zero_max_wait_min.flow")); assertThatThrownBy(() -> loader.toFlowTrigger(nodeBean2.getTrigger())) .isInstanceOf(IllegalArgumentException.class).hasMessage("max wait min must be at least 1" + " min(s)"); NodeBean nodeBean3 = loader.load(ExecutionsTestUtil.getFlowFile( TRIGGER_FLOW_YML_TEST_DIR, "flow_trigger_large_max_wait_min.flow")); FlowTrigger flowTrigger = loader.toFlowTrigger(nodeBean3.getTrigger()); assertThat(flowTrigger.getMaxWaitDuration().orElse(null)) .isEqualTo(Constants.DEFAULT_FLOW_TRIGGER_MAX_WAIT_TIME); nodeBean3 = loader.load(ExecutionsTestUtil.getFlowFile( TRIGGER_FLOW_YML_TEST_DIR, "flow_trigger_no_max_wait_min_zero_dep.flow")); flowTrigger = loader.toFlowTrigger(nodeBean3.getTrigger()); assertThat(flowTrigger.getMaxWaitDuration().orElse(null)).isEqualTo(null); nodeBean3 = loader.load(ExecutionsTestUtil.getFlowFile( TRIGGER_FLOW_YML_TEST_DIR, "flow_trigger_max_wait_min_zero_dep.flow")); flowTrigger = loader.toFlowTrigger(nodeBean3.getTrigger()); assertThat(flowTrigger.getMaxWaitDuration().get().toMinutes()).isEqualTo(5); }
Eh107Configuration.class).unwrap(CacheRuntimeConfiguration.class); Client client1 = new Client("client1", 1); foosEhcacheConfig.getExpiryPolicy().getExpiryForCreation(42L, client1).toMinutes(); // <8>
.ofSeconds(t.getInstant().getEpochSecond()) .toHours(); long duration = Math.max(t.getDuration().toMinutes(), 0); transitionsList.add(epochHours); transitionsList.add(duration); info.transitions = transitionsList.stream().mapToLong(l -> l).toArray(); info.stdOffset = (int) Duration.ofMillis(timeZone.getRawOffset()) .toMinutes(); info.names = new String[] { timeZone.getDisplayName(false, TimeZone.SHORT, locale),
public P updatePlayerLastLogin(final P player) { Instant now = Instant.now(); if (player.getLastLogin() == null || Duration.between(player.getLastLogin(), now).toMinutes() > THRESHOLD) { player.setLastLogin(now); return playerRepository.save(player); } return player; } }