Package org.joda.time

Examples of org.joda.time.Duration


  public void testSpanTwoDaysOfOfficeHoursB() {
    DateTime lastCalculated = new DateTime(2009, 6, 22, 12, 5, 0, 0);
    DateTime now = new DateTime(2009, 6, 24, 9, 5, 0, 0);

    Duration elapsedTime = calculator.calculateElapsedTime(lastCalculated, now, SLAWorkingHours.OFFICE_HOURS_9_TO_5_30);
    Assert.assertEquals("PT14H", elapsedTime.toPeriod().toString());
  }
View Full Code Here


  public void testSpanTwoDaysOfOfficeHoursC() {
    DateTime lastCalculated = new DateTime(2009, 6, 22, 7, 0, 0, 0);
    DateTime now = new DateTime(2009, 6, 23, 19, 0, 0, 0);

    Duration elapsedTime = calculator.calculateElapsedTime(lastCalculated, now, SLAWorkingHours.OFFICE_HOURS_9_TO_5_30);
    Assert.assertEquals("PT17H", elapsedTime.toPeriod().toString());
  }
View Full Code Here

  public void testSpanTwoDaysOfOfficePlusWeekendHours() {
    DateTime lastCalculated = new DateTime(2009, 6, 19, 7, 0, 0, 0);
    DateTime now = new DateTime(2009, 6, 22, 19, 0, 0, 0);

    Duration elapsedTime = calculator.calculateElapsedTime(lastCalculated, now, SLAWorkingHours.OFFICE_HOURS_9_TO_5_30);
    Assert.assertEquals("PT17H", elapsedTime.toPeriod().toString());
  }
View Full Code Here

  public void testSpanWeekendAndBankHoliday() {
    DateTime lastCalculated = new DateTime(2008, 12, 31, 7, 0, 0, 0);
    DateTime now = new DateTime(2009, 1, 5, 19, 0, 0, 0);

    Duration elapsedTime = calculator.calculateElapsedTime(lastCalculated, now, SLAWorkingHours.OFFICE_HOURS_9_TO_5_30);
    Assert.assertEquals("PT25H30M", elapsedTime.toPeriod().toString());
  }
View Full Code Here

  public void testOutOfOfficeHours() {
    DateTime lastCalculated = new DateTime(2009, 6, 19, 19, 0, 0, 0);
    DateTime now = new DateTime(2009, 6, 19, 21, 0, 0, 0);

    Duration elapsedTime = calculator.calculateElapsedTime(lastCalculated, now, SLAWorkingHours.OFFICE_HOURS_9_TO_5_30);
    Assert.assertEquals("PT0S", elapsedTime.toPeriod().toString());
  }
View Full Code Here

      this.exec = Execs.scheduledSingleThreaded("DatabaseRuleManager-Exec--%d");

      createDefaultRule(dbi, getRulesTable(), config.get().getDefaultRule(), jsonMapper);
      ScheduledExecutors.scheduleWithFixedDelay(
          exec,
          new Duration(0),
          config.get().getPollDuration().toStandardDuration(),
          new Runnable()
          {
            @Override
            public void run()
View Full Code Here

    final long windowMillis = windowPeriod.toStandardDuration().getMillis();

    log.info(
        "Expect to run at [%s]",
        new DateTime().plus(
            new Duration(
                System.currentTimeMillis(),
                segmentGranularity.increment(truncatedNow).getMillis() + windowMillis
            )
        )
    );

    ScheduledExecutors
        .scheduleAtFixedRate(
            scheduledExecutor,
            new Duration(
                System.currentTimeMillis(),
                segmentGranularity.increment(truncatedNow).getMillis() + windowMillis
            ),
            new Duration(truncatedNow, segmentGranularity.increment(truncatedNow)),
            new ThreadRenamingCallable<ScheduledExecutors.Signal>(
                String.format(
                    "%s-overseer-%d",
                    schema.getDataSource(),
                    config.getShardSpec().getPartitionNum()
View Full Code Here

    final long windowMillis = config.getWindowPeriod().toStandardDuration().getMillis();

    log.info(
        "Expect to run at [%s]",
        new DateTime().plus(
            new Duration(
                System.currentTimeMillis(),
                schema.getGranularitySpec().getSegmentGranularity().increment(truncatedNow).getMillis() + windowMillis
            )
        )
    );

    ScheduledExecutors
        .scheduleAtFixedRate(
            flushScheduledExec,
            new Duration(
                System.currentTimeMillis(),
                schema.getGranularitySpec().getSegmentGranularity().increment(truncatedNow).getMillis() + windowMillis
            ),
            new Duration(truncatedNow, segmentGranularity.increment(truncatedNow)),
            new ThreadRenamingCallable<ScheduledExecutors.Signal>(
                String.format(
                    "%s-flusher-%d",
                    getSchema().getDataSource(),
                    getConfig().getShardSpec().getPartitionNum()
View Full Code Here

        return;
      }

      poller = new PollingCallable();
      ScheduledExecutors.scheduleWithFixedDelay(
          exec, new Duration(0), config.get().getPollDuration().toStandardDuration(), poller
      );

      started = true;
    }
  }
View Full Code Here

          didProvision = true;
        }
      }

      if (!currentlyProvisioning.isEmpty()) {
        Duration durSinceLastProvision = new Duration(lastProvisionTime, new DateTime());

        log.info("%s provisioning. Current wait time: %s", currentlyProvisioning, durSinceLastProvision);

        if (durSinceLastProvision.isLongerThan(config.getMaxScalingDuration().toStandardDuration())) {
          log.makeAlert("Worker node provisioning taking too long!")
             .addData("millisSinceLastProvision", durSinceLastProvision.getMillis())
             .addData("provisioningCount", currentlyProvisioning.size())
             .emit();

          autoScalingStrategy.terminateWithIds(Lists.newArrayList(currentlyProvisioning));
          currentlyProvisioning.clear();
View Full Code Here

TOP

Related Classes of org.joda.time.Duration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.