Example usage for java.util.concurrent TimeUnit MINUTES

List of usage examples for java.util.concurrent TimeUnit MINUTES

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MINUTES.

Prototype

TimeUnit MINUTES

To view the source code for java.util.concurrent TimeUnit MINUTES.

Click Source Link

Document

Time unit representing sixty seconds.

Usage

From source file:com.streamsets.lib.security.http.PasswordHasher.java

public PasswordHasher(Configuration configuration) {
    hashVersion = configuration.get(HASH_VERSION_KEY, HASH_VERSION_DEFAULT);
    iterations = configuration.get(ITERATIONS_KEY, ITERATIONS_DEFAULT);
    keyLength = configuration.get(KEY_LENGTH_KEY, KEY_LENGTH_DEFAULT);
    // expire on access of 20mins it is 40 times over the validation time.
    verifyCache = CacheBuilder.newBuilder().expireAfterAccess(20, TimeUnit.MINUTES).build();
}

From source file:example.app.config.server.ExampleApplicationConfiguration.java

@Bean
ExpirationAttributesFactoryBean exampleExpirationAttributes() {
    ExpirationAttributesFactoryBean exampleExpirationAttributes = new ExpirationAttributesFactoryBean();

    exampleExpirationAttributes.setAction(ExpirationAction.LOCAL_DESTROY);
    exampleExpirationAttributes.setTimeout(Long.valueOf(TimeUnit.MINUTES.toMillis(2)).intValue());

    return exampleExpirationAttributes;
}

From source file:net.solarnetwork.central.dras.biz.alert.test.SimpleAlertBizTest.java

@Test
public void processEventCreatedAlert() throws Exception {
    Event event = setupEvent();/*from ww  w  .ja va  2s  .co m*/

    SimpleAlert alert = new SimpleAlert();
    alert.setAlertType(AlertBiz.ALERT_TYPE_ENTITY_CREATED);
    alert.setRegardingIdentity(event);

    Future<AlertProcessingResult> future = alertBiz.postAlert(alert);
    assertNotNull(future);
    AlertProcessingResult result = future.get(1, TimeUnit.MINUTES);
    assertNotNull(result);
    assertNotNull(result.getAlert());
    assertEquals(alert.getAlertType(), result.getAlert().getAlertType());
    assertNotNull(result.getAlertedUsers());
    assertEquals(1, result.getAlertedUsers().size());
    assertTrue(result.getAlertedUsers().contains(new User(TEST_USER_ID)));
}

From source file:org.carewebframework.logging.perf4j.PerformanceMonitor.java

/**
 * Starts the expiration timer.//w  w  w .j a va  2s . co  m
 */
@Override
public synchronized void startExpirationTimer() {
    if (isExpirationTimerTaskStopped()) {
        this.expirationTimerTaskFuture = this.scheduledExecutorService
                .scheduleAtFixedRate(new ExpirationTimerTask(), 0L, 1L, TimeUnit.MINUTES);
    } else {
        log.warn("PerformanceMonitorExpirationTimer already started");
    }
}

From source file:com.room5.server.spring_boot.jmx.JMXServerStatistics.java

/**
 * Current uptime:  http://localhost:9191/jolokia/read/com.room5.jmx:name=JMXServerStatistics/Uptime
 */// www. j  a v  a2  s.c  o m
@ManagedMetric(description = "Current system uptime.", displayName = "Current system uptime.", metricType = MetricType.COUNTER, currencyTimeLimit = 10)
public String getUptime() {
    long upTime = System.currentTimeMillis() - startTime;

    long days = TimeUnit.MILLISECONDS.toDays(upTime);
    long hoursRaw = TimeUnit.MILLISECONDS.toHours(upTime);
    long minutesRaw = TimeUnit.MILLISECONDS.toMinutes(upTime);

    //convert to string
    return String.format("%d days, %d hrs, %d min, %d sec", days, hoursRaw - TimeUnit.DAYS.toHours(days),
            minutesRaw - TimeUnit.HOURS.toMinutes(hoursRaw),
            TimeUnit.MILLISECONDS.toSeconds(upTime) - TimeUnit.MINUTES.toSeconds(minutesRaw));
}

From source file:ddf.test.itests.catalog.TestSecurityAuditPlugin.java

@Test
public void testBundleStartAndStop() throws Exception {
    String logFilePath = System.getProperty("karaf.log") + "/security.log";
    File securityLog = new File(logFilePath);

    getServiceManager().stopBundle("catalog-plugin-security-audit");
    WaitCondition.expect("Securitylog has log message: " + stoppedMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS).until(() -> getFileContent(securityLog).contains(stoppedMessage));

    getServiceManager().startBundle("catalog-plugin-security-audit");
    WaitCondition.expect("Securitylog has log message: " + startedMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS).until(() -> getFileContent(securityLog).contains(startedMessage));
}

From source file:fr.gael.dhus.search.SolrDao.java

private LoadingCache<String, SearchResult> getResultsCache() {
    if (SolrDao.cache == null) {
        SolrDao.cache = CacheBuilder.newBuilder().concurrencyLevel(4).maximumSize(1000)
                .expireAfterWrite(10, TimeUnit.MINUTES).expireAfterAccess(10, TimeUnit.MINUTES)
                .build(new CacheLoader<String, SearchResult>() {
                    public SearchResult load(String key) {
                        String converted = key;
                        logger.info("Executing Query \""
                                + ("" + converted).substring(0, Math.min(("" + converted).length(), 512))
                                + " (...)\"");
                        return new SearchResult(getSolrServer(), converted);
                    }//from   ww  w.  j  a  va  2  s .  c  o m
                });
    }
    return SolrDao.cache;
}

From source file:net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.java

/**
 * Returns the formatted relative time for a given time.
 *
 * @param webInterface/* w w  w .j  av  a 2s.  c om*/
 *            The Sone web interface (for l10n access)
 * @param time
 *            The time to format the difference from (in milliseconds)
 * @return The formatted age
 */
public static Time getTime(WebInterface webInterface, long time) {
    if (time == 0) {
        return new Time(webInterface.getL10n().getString("View.Sone.Text.UnknownDate"),
                TimeUnit.HOURS.toMillis(12));
    }
    long age = System.currentTimeMillis() - time;
    String text;
    long refresh;
    if (age < 0) {
        text = webInterface.getL10n().getDefaultString("View.Time.InTheFuture");
        refresh = TimeUnit.MINUTES.toMillis(5);
    } else if (age < TimeUnit.SECONDS.toMillis(20)) {
        text = webInterface.getL10n().getDefaultString("View.Time.AFewSecondsAgo");
        refresh = TimeUnit.SECONDS.toMillis(10);
    } else if (age < TimeUnit.SECONDS.toMillis(45)) {
        text = webInterface.getL10n().getString("View.Time.HalfAMinuteAgo");
        refresh = TimeUnit.SECONDS.toMillis(20);
    } else if (age < TimeUnit.SECONDS.toMillis(90)) {
        text = webInterface.getL10n().getString("View.Time.AMinuteAgo");
        refresh = TimeUnit.MINUTES.toMillis(1);
    } else if (age < TimeUnit.MINUTES.toMillis(30)) {
        text = webInterface.getL10n().getString("View.Time.XMinutesAgo", "min",
                String.valueOf(TimeUnit.MILLISECONDS.toMinutes(age + TimeUnit.SECONDS.toMillis(30))));
        refresh = TimeUnit.MINUTES.toMillis(1);
    } else if (age < TimeUnit.MINUTES.toMillis(45)) {
        text = webInterface.getL10n().getString("View.Time.HalfAnHourAgo");
        refresh = TimeUnit.MINUTES.toMillis(10);
    } else if (age < TimeUnit.MINUTES.toMillis(90)) {
        text = webInterface.getL10n().getString("View.Time.AnHourAgo");
        refresh = TimeUnit.HOURS.toMillis(1);
    } else if (age < TimeUnit.HOURS.toMillis(21)) {
        text = webInterface.getL10n().getString("View.Time.XHoursAgo", "hour",
                String.valueOf(TimeUnit.MILLISECONDS.toHours(age + TimeUnit.MINUTES.toMillis(30))));
        refresh = TimeUnit.HOURS.toMillis(1);
    } else if (age < TimeUnit.HOURS.toMillis(42)) {
        text = webInterface.getL10n().getString("View.Time.ADayAgo");
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(6)) {
        text = webInterface.getL10n().getString("View.Time.XDaysAgo", "day",
                String.valueOf(TimeUnit.MILLISECONDS.toDays(age + TimeUnit.HOURS.toMillis(12))));
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(11)) {
        text = webInterface.getL10n().getString("View.Time.AWeekAgo");
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(28)) {
        text = webInterface.getL10n().getString("View.Time.XWeeksAgo", "week",
                String.valueOf((TimeUnit.MILLISECONDS.toHours(age) + 84) / (7 * 24)));
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(42)) {
        text = webInterface.getL10n().getString("View.Time.AMonthAgo");
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(330)) {
        text = webInterface.getL10n().getString("View.Time.XMonthsAgo", "month",
                String.valueOf((TimeUnit.MILLISECONDS.toDays(age) + 15) / 30));
        refresh = TimeUnit.DAYS.toMillis(1);
    } else if (age < TimeUnit.DAYS.toMillis(540)) {
        text = webInterface.getL10n().getString("View.Time.AYearAgo");
        refresh = TimeUnit.DAYS.toMillis(7);
    } else {
        text = webInterface.getL10n().getString("View.Time.XYearsAgo", "year",
                String.valueOf((long) ((TimeUnit.MILLISECONDS.toDays(age) + 182.64) / 365.28)));
        refresh = TimeUnit.DAYS.toMillis(7);
    }
    return new Time(text, refresh);
}

From source file:edu.umd.cs.buildServer.BuildServerDaemon.java

/**
 * @return
 */
protected int getConnectionTimeout() {
    return (int) TimeUnit.MILLISECONDS.convert(3, TimeUnit.MINUTES);
}