Example usage for org.joda.time Minutes Minutes

List of usage examples for org.joda.time Minutes Minutes

Introduction

In this page you can find the example usage for org.joda.time Minutes Minutes.

Prototype

private Minutes(int minutes) 

Source Link

Document

Creates a new instance representing a number of minutes.

Usage

From source file:org.forgerock.openidm.util.ConfigMacroUtil.java

License:Open Source License

/**
 * Defines the magnitudes that can be added to the timestamp
 *
 * @param token//w  w  w .  ja  v  a2s.c  o  m
 *            token of form "[number][magnitude]" (ex. "1d")
 * @return integer indicating the magnitude of the date for the calendar
 *         system
 */
public static ReadablePeriod getTimePeriod(String token) {
    String valString = token.substring(0, token.length() - 1);
    int value = Integer.parseInt(valString);
    char mag = token.charAt(token.length() - 1);

    ReadablePeriod period;

    switch (mag) {
    case 's':
        period = Seconds.seconds(value);
        break;
    case 'm':
        period = Minutes.minutes(value);
        break;
    case 'h':
        period = Hours.hours(value);
        break;
    case 'd':
        period = Days.days(value);
        break;
    case 'M':
        period = Months.months(value);
        break;
    case 'y':
        period = Years.years(value);
        break;
    default:
        logger.warn("Invalid date magnitude: {}. Defaulting to seconds.", mag);
        period = Seconds.seconds(value);
        break;
    }

    return period;
}

From source file:org.hawkular.metrics.core.jobs.JobsServiceImpl.java

License:Apache License

@Override
public List<JobDetails> start() {
    List<JobDetails> backgroundJobs = new ArrayList<>();

    deleteTenant = new DeleteTenant(session, metricsService);

    // Use a simple retry policy to make sure tenant deletion does complete in the event of failure. For now
    // we simply retry after 5 minutes. We can implement a more sophisticated strategy later on if need be.
    Func2<JobDetails, Throwable, RetryPolicy> deleteTenantRetryPolicy = (details, throwable) -> () -> {
        logger.warn("Execution of " + details + " failed", throwable);
        logger.info(details + " will be retried in 5 minutes");
        return Minutes.minutes(5).toStandardDuration().getMillis();
    };/*ww w  . j a v  a2  s  .  c o m*/
    scheduler.register(DeleteTenant.JOB_NAME, deleteTenant, deleteTenantRetryPolicy);

    TempTableCreator tempCreator = new TempTableCreator(metricsService, configurationService);
    scheduler.register(TempTableCreator.JOB_NAME, tempCreator);
    maybeScheduleTableCreator(backgroundJobs);

    TempDataCompressor tempJob = new TempDataCompressor(metricsService, configurationService);
    scheduler.register(TempDataCompressor.JOB_NAME, tempJob);

    //        CompressData compressDataJob = new CompressData(metricsService, configurationService);
    //        scheduler.register(CompressData.JOB_NAME, compressDataJob);
    maybeScheduleCompressData(backgroundJobs);

    deleteExpiredMetrics = new DeleteExpiredMetrics(metricsService, session, configurationService,
            this.metricExpirationDelay);
    scheduler.register(DeleteExpiredMetrics.JOB_NAME, deleteExpiredMetrics);
    maybeScheduleMetricExpirationJob(backgroundJobs);

    scheduler.start();

    return backgroundJobs;
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.IntegerColumnMinutesMapper.java

License:Apache License

@Override
public Minutes fromNonNullString(String s) {
    return Minutes.minutes(Integer.parseInt(s));
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.IntegerColumnMinutesMapper.java

License:Apache License

@Override
public Minutes fromNonNullValue(Integer value) {
    return Minutes.minutes(value);
}

From source file:org.rhq.metrics.simulator.plan.SimulationPlanner.java

License:Open Source License

private MetricsConfiguration createMinutesConfiguration() {
    MetricsConfiguration configuration = new MetricsConfiguration();
    configuration.setRawTTL(Minutes.minutes(168).toStandardSeconds().getSeconds());
    configuration.setRawRetention(Minutes.minutes(168).toStandardDuration());
    configuration.setRawTimeSliceDuration(Seconds.seconds(150).toStandardDuration());

    configuration.setOneHourTTL(Minutes.minutes(336).toStandardSeconds().getSeconds());
    configuration.setOneHourRetention(Minutes.minutes(336));
    configuration.setOneHourTimeSliceDuration(Minutes.minutes(15).toStandardDuration());

    configuration.setSixHourTTL(Minutes.minutes(744).toStandardSeconds().getSeconds());
    configuration.setSixHourRetention(Minutes.minutes(744).toStandardSeconds());
    configuration.setSixHourTimeSliceDuration(Minutes.minutes(60).toStandardDuration());

    configuration.setTwentyFourHourTTL(Minutes.minutes(8928).toStandardSeconds().getSeconds());
    configuration.setTwentyFourHourRetention(Minutes.minutes(8928).toStandardSeconds());

    return configuration;
}

From source file:org.rhq.metrics.simulator.plan.SimulationPlanner.java

License:Open Source License

private MetricsConfiguration createSecondsConfiguration() {
    MetricsConfiguration configuration = new MetricsConfiguration();
    configuration.setRawTTL(420);/*from www .  j  av  a 2s. c o m*/
    configuration.setRawRetention(Seconds.seconds(420).toStandardDuration());
    configuration.setRawTimeSliceDuration(Seconds.seconds(2).toStandardDuration().plus(500));

    configuration.setOneHourTTL(Seconds.seconds(840).getSeconds());
    configuration.setOneHourRetention(Seconds.seconds(840));
    configuration.setOneHourTimeSliceDuration(Seconds.seconds(15).toStandardDuration());

    configuration.setSixHourTTL(Seconds.seconds(1860).getSeconds());
    configuration.setSixHourRetention(Seconds.seconds(1860));
    configuration.setSixHourTimeSliceDuration(Seconds.seconds(60).toStandardDuration());

    configuration.setTwentyFourHourTTL(Minutes.minutes(365).toStandardSeconds().getSeconds());
    configuration.setTwentyFourHourRetention(Minutes.minutes(365));

    return configuration;
}

From source file:org.rhq.metrics.simulator.Simulator.java

License:Open Source License

/**
 * Run a multi-threaded simulation where multiple threads
 * collect metrics and run aggregation./*w  w  w . j  a  v a 2 s  .c o  m*/
 * The scheduling is done based on intervalType please review the
 * simulation plan for the timing.
 */
private void runThreadedSimulation(SimulationPlan plan) {
    this.initializeMetricsServer(plan);
    final ConsoleReporter consoleReporter = createConsoleReporter(metrics, plan.getMetricsReportInterval());

    final ScheduledExecutorService aggregators = Executors.newScheduledThreadPool(1,
            new SimulatorThreadFactory());
    final ScheduledExecutorService collectors = Executors
            .newScheduledThreadPool(plan.getNumMeasurementCollectors(), new SimulatorThreadFactory());
    final ExecutorService aggregationQueue = Executors.newSingleThreadExecutor(new SimulatorThreadFactory());
    final ScheduledExecutorService readers = Executors.newScheduledThreadPool(plan.getReaderThreadPoolSize(),
            new SimulatorThreadFactory());

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            shutdown(collectors, "collectors", 5);
            shutdown(readers, "readers", 5);
            shutdown(aggregators, "aggregators", 1);
            shutdown(aggregationQueue, "aggregationQueue", Integer.MAX_VALUE);
            metricsServer.shutdown();
            log.info("Wait for console reporter...");
            try {
                Thread.sleep(181000);
            } catch (InterruptedException e) {
            }
            consoleReporter.stop();
        }
    });

    MeasurementAggregator measurementAggregator = new MeasurementAggregator(metricsServer, this, metrics,
            aggregationQueue, plan.getNumMeasurementCollectors() * plan.getBatchSize());

    for (int i = 0; i < plan.getNumMeasurementCollectors(); ++i) {
        collectors
                .scheduleAtFixedRate(
                        new MeasurementCollector(plan.getBatchSize(), plan.getBatchSize() * i, metrics,
                                metricsServer, plan.getDateTimeService()),
                        0, plan.getCollectionInterval(), TimeUnit.MILLISECONDS);
    }

    if (plan.isAggregationEnabled()) {
        aggregators.scheduleAtFixedRate(measurementAggregator, 0, plan.getAggregationInterval(),
                TimeUnit.MILLISECONDS);
    }

    for (int i = 0; i < plan.getNumReaders(); ++i) {
        MeasurementReader reader = new MeasurementReader(plan.getSimulationRate(), metrics, metricsServer,
                plan.getBatchSize() * i, plan.getBatchSize());
        readers.scheduleAtFixedRate(reader, 30, 30, TimeUnit.SECONDS);
    }

    try {
        Thread.sleep(Minutes.minutes(plan.getSimulationTime()).toStandardDuration().getMillis());
    } catch (InterruptedException e) {
    }
    log.info("Simulation has completed. Initiating shutdown...");
    shutdown(0);
}

From source file:org.smartdeveloperhub.harvesters.it.backend.Fixture.java

License:Apache License

public static Issue defaultIssue() {
    final Issue issue = new Issue();
    issue.setAssignee("assignee");
    issue.setBlockedIssues(ImmutableSet.of("bi1", "bi2"));
    issue.setChanges(Fixture.defaultChangeLog());
    issue.setChildIssues(ImmutableSet.of("ci1", "ci2"));
    issue.setClosed(new DateTime());
    issue.setCreationDate(new DateTime());
    issue.setCommits(ImmutableSet.of("c1", "c2"));
    issue.setComponents(ImmutableSet.of("cc1", "cc2"));
    issue.setDescription("description");
    issue.setDueTo(new DateTime());
    issue.setEstimatedTime(Minutes.minutes(60).toStandardDuration());
    issue.setId("id");
    issue.setOpened(new DateTime());
    issue.setPriority(Priority.VERY_HIGH);
    issue.setReporter("reporter");
    issue.setSeverity(Severity.BLOCKER);
    issue.setStatus(Status.CLOSED);/*from   ww w  . ja  v a2 s .c o m*/
    issue.setTags(ImmutableSet.of("t1", "t2"));
    issue.setType(Type.BUG);
    issue.setVersions(ImmutableSet.of("v1", "v2"));
    return issue;
}

From source file:org.smartdeveloperhub.harvesters.it.backend.Fixture.java

License:Apache License

public static Item estimatedTimeChangeItem() {
    return Item.builder().estimatedTime().oldValue(Minutes.minutes(1).toStandardDuration())
            .newValue(Minutes.minutes(3).toStandardDuration()).build();
}

From source file:org.smartdeveloperhub.harvesters.it.testing.generator.WorkDay.java

License:Apache License

WorkDay(final Random random) {
    this.random = random;
    this.start = new LocalTime(8, 0);
    this.end = new LocalTime(20, 0);
    this.duration = Minutes.minutes(60 * 6 + random.nextInt(30 * 6));
}