List of usage examples for java.time Duration ofMinutes
public static Duration ofMinutes(long minutes)
From source file:com.orange.cloud.servicebroker.filter.core.filters.AbstractServiceBrokerFilterTest.java
@Test public void create_service_instance() { final String applicationName = getApplicationName(); final String brokerName = getBrokerName(); final String applicationUrl = getAppUrl(applicationName, domainTest); final Map<String, String> environmentVariables = serviceBrokerAppEnvironmentVariables(); String serviceInstanceName = getServiceInstanceName(); final String serviceName = getFilteredServiceBrokerOffering(); final String planName = getFilteredServiceBrokerPlan(); givenSpace()/*w w w .ja v a 2 s . c o m*/ .then(pushThenStartServiceBrokerApp(this.cloudFoundryOperations, applicationName, getApplicationPath(), domainTest, environmentVariables)) .then(createPrivateServiceBroker(this.cloudFoundryOperations, brokerName, brokerFilterUser, brokerFilterPassword, applicationUrl)) .then(createServiceInstance(this.cloudFoundryOperations, serviceName, planName, serviceInstanceName)) .then(this.cloudFoundryOperations.services() .getInstance(GetServiceInstanceRequest.builder().name(serviceInstanceName).build())) .map(ServiceInstance::getName).as(StepVerifier::create).expectNext(serviceInstanceName) .expectComplete().verify(Duration.ofMinutes(5)); }
From source file:io.pravega.controller.task.Stream.StreamMetadataTasks.java
private CompletableFuture<Void> checkGenerateStreamCut(String scope, String stream, OperationContext context, RetentionPolicy policy, StreamCutRecord latestCut, long recordingTime) { switch (policy.getRetentionType()) { case TIME:/*from www .j a v a 2 s . c om*/ if (latestCut == null || recordingTime - latestCut.getRecordingTime() > Duration .ofMinutes(Config.MINIMUM_RETENTION_FREQUENCY_IN_MINUTES).toMillis()) { return generateStreamCut(scope, stream, context).thenCompose(newRecord -> streamMetadataStore .addStreamCutToRetentionSet(scope, stream, newRecord, context, executor)); } else { return CompletableFuture.completedFuture(null); } case SIZE: default: throw new NotImplementedException("Size based retention"); } }
From source file:org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundry2620AndEarlierTaskLauncher.java
private Mono<GetDropletResponse> waitForDropletProcessing(String dropletId) { return requestGetDroplet(dropletId) .filter(response -> !response.getState().equals(org.cloudfoundry.client.v3.droplets.State.PENDING)) .repeatWhenEmpty(50, DelayUtils.exponentialBackOff(Duration.ofSeconds(10), Duration.ofMinutes(1), Duration.ofMinutes(10))); }
From source file:org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundry2620AndEarlierTaskLauncher.java
private Mono<GetPackageResponse> waitForPackageProcessing(String packageId) { return requestGetPackage(packageId).filter(response -> response.getState().equals(State.READY)) .repeatWhenEmpty(50, DelayUtils.exponentialBackOff(Duration.ofSeconds(5), Duration.ofMinutes(1), Duration.ofMinutes(10))); }
From source file:azkaban.project.NodeBeanLoaderTest.java
private void validateFlowTrigger(final FlowTrigger flowTrigger, final long maxWaitMins, final String cronExpression, final int numDependencies) { assertThat(flowTrigger.getMaxWaitDuration().orElse(null)).isEqualTo(Duration.ofMinutes(maxWaitMins)); assertThat(flowTrigger.getSchedule().getCronExpression()).isEqualTo(cronExpression); assertThat(flowTrigger.getDependencies().size()).isEqualTo(numDependencies); }
From source file:fll.scheduler.TournamentSchedule.java
/** * Output the detailed schedule for a team for the day. * /*from ww w . j ava 2 s.c om*/ * @throws DocumentException */ private void outputTeamSchedule(final SchedParams params, final Document detailedSchedules, final TeamScheduleInfo si) throws DocumentException { final Paragraph para = new Paragraph(); para.add(new Chunk( String.format("Detailed schedule for Team #%d - %s", si.getTeamNumber(), si.getTeamName()), TEAM_TITLE_FONT)); para.add(Chunk.NEWLINE); para.add(new Chunk(String.format("Organization: %s", si.getOrganization()), TEAM_TITLE_FONT)); para.add(Chunk.NEWLINE); para.add(new Chunk("Division: ", TEAM_HEADER_FONT)); para.add(new Chunk(si.getAwardGroup(), TEAM_VALUE_FONT)); para.add(Chunk.NEWLINE); for (final String subjectiveStation : subjectiveStations) { para.add(new Chunk(subjectiveStation + ": ", TEAM_HEADER_FONT)); final LocalTime start = si.getSubjectiveTimeByName(subjectiveStation).getTime(); final LocalTime end = start.plus(params.getStationByName(subjectiveStation).getDuration()); para.add(new Chunk(String.format("%s - %s", formatTime(start), formatTime(end)), TEAM_VALUE_FONT)); para.add(Chunk.NEWLINE); } for (int round = 0; round < getNumberOfRounds(); ++round) { para.add(new Chunk(String.format(PERF_HEADER_FORMAT, round + 1) + ": ", TEAM_HEADER_FONT)); final LocalTime start = si.getPerfTime(round); final LocalTime end = start.plus(Duration.ofMinutes(params.getPerformanceMinutes())); para.add(new Chunk(String.format("%s - %s %s %d", formatTime(start), formatTime(end), si.getPerfTableColor(round), si.getPerfTableSide(round)), TEAM_VALUE_FONT)); para.add(Chunk.NEWLINE); } para.add(Chunk.NEWLINE); para.add(new Chunk( "Performance rounds must start on time, and will start without you. Please ensure your team arrives at least 5 minutes ahead of scheduled time, and checks in.", TEAM_HEADER_FONT)); para.add(Chunk.NEWLINE); para.add(new Chunk( "Note that there may be more judging and a head to head round after this judging, please see the main tournament schedule for these details.", TEAM_HEADER_FONT)); para.add(Chunk.NEWLINE); para.add(Chunk.NEWLINE); para.add(Chunk.NEWLINE); para.setKeepTogether(true); detailedSchedules.add(para); }
From source file:fll.scheduler.TournamentSchedule.java
/** * Compute the general schedule and return it as a string *//*from w ww . jav a 2s.c o m*/ public String computeGeneralSchedule() { LocalTime minPerf = null; LocalTime maxPerf = null; // division -> date final Map<String, LocalTime> minSubjectiveTimes = new HashMap<>(); final Map<String, LocalTime> maxSubjectiveTimes = new HashMap<>(); for (final TeamScheduleInfo si : _schedule) { final String judgingStation = si.getJudgingGroup(); for (final SubjectiveTime stime : si.getSubjectiveTimes()) { final LocalTime currentMin = minSubjectiveTimes.get(judgingStation); if (null == currentMin) { minSubjectiveTimes.put(judgingStation, stime.getTime()); } else { if (stime.getTime().isBefore(currentMin)) { minSubjectiveTimes.put(judgingStation, stime.getTime()); } } final LocalTime currentMax = maxSubjectiveTimes.get(judgingStation); if (null == currentMax) { maxSubjectiveTimes.put(judgingStation, stime.getTime()); } else { if (stime.getTime().isAfter(currentMax)) { maxSubjectiveTimes.put(judgingStation, stime.getTime()); } } } for (int i = 0; i < getNumberOfRounds(); ++i) { if (null != si.getPerfTime(i)) { if (null == minPerf || si.getPerfTime(i).isBefore(minPerf)) { minPerf = si.getPerfTime(i); } if (null == maxPerf || si.getPerfTime(i).isAfter(maxPerf)) { maxPerf = si.getPerfTime(i); } } } } // print out the general schedule final Formatter output = new Formatter(); final Set<String> stations = new HashSet<String>(); stations.addAll(minSubjectiveTimes.keySet()); stations.addAll(maxSubjectiveTimes.keySet()); for (final String station : stations) { final LocalTime earliestStart = minSubjectiveTimes.get(station); final LocalTime latestStart = maxSubjectiveTimes.get(station); final Duration subjectiveDuration = Duration.ofMinutes(SolverParams.DEFAULT_SUBJECTIVE_MINUTES); final LocalTime latestEnd = latestStart.plus(subjectiveDuration); output.format( "Subjective times for judging station %s: %s - %s (assumes default subjective time of %d minutes)%n", station, formatTime(earliestStart), formatTime(latestEnd), SolverParams.DEFAULT_SUBJECTIVE_MINUTES); } if (null != minPerf && null != maxPerf) { final Duration performanceDuration = Duration.ofMinutes(SolverParams.DEFAULT_PERFORMANCE_MINUTES); final LocalTime performanceEnd = maxPerf.plus(performanceDuration); output.format("Performance times: %s - %s (assumes default performance time of %d minutes)%n", formatTime(minPerf), formatTime(performanceEnd), SolverParams.DEFAULT_PERFORMANCE_MINUTES); } return output.toString(); }
From source file:org.apache.gobblin.service.modules.orchestration.AzkabanClient.java
private void refreshSession() throws AzkabanClientException { Preconditions.checkArgument(this.sessionCreationTime != 0); if ((System.nanoTime() - this.sessionCreationTime) > Duration.ofMinutes(this.sessionExpireInMin) .toNanos()) {/* www .j av a 2 s . co m*/ log.info("Session expired. Generating a new session."); this.initializeSession(); } }
From source file:org.apache.james.mailbox.store.mail.model.MessageIdMapperTest.java
@Test public void setFlagsShouldWorkWithConcurrencyWithAdd() throws Exception { Assume.assumeTrue(mapperProvider.getSupportedCapabilities() .contains(MapperProvider.Capabilities.THREAD_SAFE_FLAGS_UPDATE)); message1.setUid(mapperProvider.generateMessageUid()); message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox)); sut.save(message1);/*w ww . j a v a 2s.co m*/ int threadCount = 2; int updateCount = 10; ConcurrentTestRunner.builder() .operation((threadNumber, step) -> sut.setFlags(message1.getMessageId(), ImmutableList.of(message1.getMailboxId()), new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD)) .threadCount(threadCount).operationCount(updateCount).runSuccessfullyWithin(Duration.ofMinutes(1)); List<MailboxMessage> messages = sut.find(ImmutableList.of(message1.getMessageId()), MessageMapper.FetchType.Body); assertThat(messages).hasSize(1); assertThat(messages.get(0).createFlags().getUserFlags()).hasSize(threadCount * updateCount); }
From source file:org.apache.james.mailbox.store.mail.model.MessageIdMapperTest.java
@Test public void setFlagsShouldWorkWithConcurrencyWithRemove() throws Exception { Assume.assumeTrue(mapperProvider.getSupportedCapabilities() .contains(MapperProvider.Capabilities.THREAD_SAFE_FLAGS_UPDATE)); message1.setUid(mapperProvider.generateMessageUid()); message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox)); sut.save(message1);/*from ww w .j a v a2s . co m*/ int threadCount = 4; int updateCount = 20; ConcurrentTestRunner.builder().operation((threadNumber, step) -> { if (step < updateCount / 2) { sut.setFlags(message1.getMessageId(), ImmutableList.of(message1.getMailboxId()), new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD); } else { sut.setFlags(message1.getMessageId(), ImmutableList.of(message1.getMailboxId()), new Flags("custom-" + threadNumber + "-" + (updateCount - step - 1)), FlagsUpdateMode.REMOVE); } }).threadCount(threadCount).operationCount(updateCount).runSuccessfullyWithin(Duration.ofMinutes(1)); List<MailboxMessage> messages = sut.find(ImmutableList.of(message1.getMessageId()), MessageMapper.FetchType.Body); assertThat(messages).hasSize(1); assertThat(messages.get(0).createFlags().getUserFlags()).isEmpty(); }