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.nesscomputing.quartz.QuartzJobStatistics.java

QuartzJobStatistics(final MetricsRegistry metricsRegistry, final JobKey jobKey) {
    final String keyName = jobKey.getName()
            + (StringUtils.isBlank(jobKey.getGroup()) || JobKey.DEFAULT_GROUP.equals(jobKey.getGroup()) ? ""
                    : "-" + jobKey.getGroup());

    this.runtime = metricsRegistry.newTimer(new MetricName("ness.quartz.job", "statistics", keyName),
            TimeUnit.MILLISECONDS, TimeUnit.MINUTES);
}

From source file:Main.java

/**
 * Convert a millisecond duration to a string format
 *
 * @param millis/*  w  ww .  j  a v  a  2s.c  o  m*/
 *      A duration to convert to a string form
 * @return A string of the form "X Days Y Hours Z Minutes A Seconds".
 */
public static String getDurationBreakdown(long millis, final boolean showMS) {
    if (millis <= 0) {
        return "-";
    }

    final long days = TimeUnit.MILLISECONDS.toDays(millis);
    millis -= TimeUnit.DAYS.toMillis(days);
    final long hours = TimeUnit.MILLISECONDS.toHours(millis);
    millis -= TimeUnit.HOURS.toMillis(hours);
    final long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
    millis -= TimeUnit.MINUTES.toMillis(minutes);
    final long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
    millis -= TimeUnit.SECONDS.toMillis(seconds);

    final StringBuilder sb = new StringBuilder();
    if (days > 0) {
        sb.append(days);
        sb.append("d ");
    }
    if (hours > 0) {
        sb.append(String.format("%02d", hours));
        sb.append("h ");
    }
    if (minutes > 0) {
        sb.append(String.format("%02d", minutes));
        sb.append("min ");
    }
    if (seconds > 0) {
        sb.append(String.format("%02d", seconds));
        sb.append("s");
    }
    if ((seconds <= 0) && (millis > 0) && showMS) {
        sb.append(String.format("%02d", millis));
        sb.append("ms");
    }

    return sb.toString();
}

From source file:de.bund.bfr.math.Evaluator.java

private static <K> Cache<K, double[]> createCache() {
    return CacheBuilder.newBuilder().weigher((K key, double[] value) -> value.length).maximumWeight(1000000)
            .expireAfterAccess(1, TimeUnit.MINUTES).build();
}

From source file:net.geoprism.report.CacheDocumentManager.java

public static void start() {
    executor.scheduleWithFixedDelay(new CacheDocumentManager(), 0, INTERVAL_TIME, TimeUnit.MINUTES);
}

From source file:ch.cyberduck.core.bonjour.LimitedRendezvousListener.java

public LimitedRendezvousListener(final Set<RendezvousListener> listeners) {
    this(new TimedSemaphore(1L, TimeUnit.MINUTES,
            PreferencesFactory.get().getInteger("rendezvous.notification.limit")), listeners);
}

From source file:com.dangdang.ddframe.job.util.concurrent.ExecutorServiceObject.java

public ExecutorServiceObject(final String namingPattern, final int threadSize) {
    workQueue = new LinkedBlockingQueue<>();
    threadPoolExecutor = new ThreadPoolExecutor(threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue,
            new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join(namingPattern, "%s")).build());
    threadPoolExecutor.allowCoreThreadTimeOut(true);
}

From source file:org.opendatakit.configuration.TestWebServiceConfiguration.java

@Bean
public EmbeddedServletContainerFactory servletContainer() throws SQLException, PropertyVetoException {
    Log logger = LogFactory.getLog(TestWebServiceConfiguration.class);
    logger.info("Setting up servletContainer");

    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
    factory.setSessionTimeout(10, TimeUnit.MINUTES);
    return factory;
}

From source file:com.glaf.core.cache.guava.GuavaCache.java

public Cache<Object, Object> getCache() {
    if (cache == null) {
        cache = CacheBuilder.newBuilder().maximumSize(getCacheSize())
                .expireAfterAccess(getExpireMinutes(), TimeUnit.MINUTES).build();
    }//from  w  w  w  .  jav a2  s.co  m
    return cache;
}

From source file:com.infinitechaos.vpcviewer.config.CachingConfiguration.java

@Bean
public CacheManager cacheManager() {
    GuavaCacheManager cm = new GuavaCacheManager(VPC_LISTS_CACHE, VPC_CACHE, ROUTE_TABLE_CACHE, SUBNET_CACHE);
    cm.setAllowNullValues(false);//from  w w w .ja v a2 s .co m
    cm.setCacheBuilder(CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES));

    return cm;
}

From source file:com.assignment4.security.ValidateSaltFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    // Assume its HTTP
    HttpServletRequest httpReq = (HttpServletRequest) request;

    // Get the salt sent with the request
    String salt = (String) httpReq.getParameter("randId");
    // Validate that the salt is in the cache
    Cache<String, Boolean> csrfPreventionSaltCache = (Cache<String, Boolean>) httpReq.getSession()
            .getAttribute("csrfPreventionSaltCache");

    if (csrfPreventionSaltCache != null && salt == null
            && (null != request.getParameter("activationtoken") || null != request.getParameter("crypt"))) {

        csrfPreventionSaltCache = CacheBuilder.newBuilder().maximumSize(5000)
                .expireAfterWrite(20, TimeUnit.MINUTES).build();

        httpReq.getSession().setAttribute("csrfPreventionSaltCache", csrfPreventionSaltCache);

        // Generate the salt and store it in the users cache
        salt = RandomStringUtils.random(20, 0, 0, true, true, null, new SecureRandom());
        csrfPreventionSaltCache.put(salt, Boolean.TRUE);

        // Add the salt to the current request so it can be used
        // by the page rendered in this request
        httpReq.setAttribute("randId", salt);
    }/*from   www .j a v a 2s  . c  o m*/

    if (csrfPreventionSaltCache != null && salt != null && csrfPreventionSaltCache.getIfPresent(salt) != null) {

        // If the salt is in the cache, we move on
        chain.doFilter(request, response);
    } else {
        // Otherwise we throw an exception aborting the request flow
        throw new ServletException("Potential CSRF detected!! Inform a scary sysadmin ASAP.");
    }
}