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:name.nirav.mp.service.analytics.EntityExtractionService.java

public EntityExtractionService(OpenCalaisConfig config, PredictionDB db) {
    this.config = config;
    this.calaisConfig = new CalaisConfig();
    this.calaisConfig.set(CalaisConfig.ConnParam.READ_TIMEOUT, config.readTimeout);
    this.calaisConfig.set(CalaisConfig.ConnParam.CONNECT_TIMEOUT, config.readTimeout);
    this.db = db;
    this.client = new CalaisRestClient(config.licenseKey);
    this.rateLimiter = RateLimiter.create(4);
    Timer timer = new Timer("Calais-ban-reset");
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            LocalDateTime now = LocalDateTime.now();
            if (now.getHour() >= 23) {
                LOG.info("It is close to midnight {}, resetting callCount", now.getHour());
                callCount = 0;/*from ww w . j  a  v a2  s  .  c  o m*/
            }
        }
    }, 1000, TimeUnit.MINUTES.toMillis(30));
}

From source file:io.stallion.monitoring.HealthTracker.java

public static void start() {
    BasicThreadFactory factory = new BasicThreadFactory.Builder()
            .namingPattern("stallion-health-tracker-thread-%d").build();
    instance().timedChecker = new ScheduledThreadPoolExecutor(2, factory);
    instance().timedChecker.scheduleAtFixedRate(instance().metrics, 0, 1, TimeUnit.MINUTES);
    instance().timedChecker.scheduleAtFixedRate(instance().dailyMetrics, 0, 24 * 60, TimeUnit.MINUTES);
}

From source file:com.garethahealy.karaf.commands.ensemble.healthy.EnsembleHealthyAction.java

@Override
protected Object doExecute() throws Exception {
    if (tick <= 0) {
        tick = TimeUnit.SECONDS.toMillis(5);
    }/*from   ww w.  j a  v  a2 s.  c  om*/

    if (wait <= 0) {
        wait = TimeUnit.MINUTES.toMillis(1);
    }

    //Sort them to be alphabetical
    Collections.sort(containers);

    log.trace("Checking ensemble of {} for {} every {}ms until {}ms.", StringUtils.join(containers, ','), tick,
            wait);

    Boolean hasTimedOut = waitForEnsembleHealthy();
    if (hasTimedOut) {
        throw new TimeoutException("Took longer than wait value");
    }

    return null;
}

From source file:spring.travel.site.Application.java

@Bean
public Cache<String, DailyForecast> weatherCache() {
    return CacheBuilder.newBuilder().expireAfterWrite(60, TimeUnit.MINUTES).build();
}

From source file:org.apache.cmueller.camel.apachecon.na2013.CxfDataFormatTest.java

private void warmUp(String paylaod) throws Exception {
    getMockEndpoint("mock:end").expectedMessageCount(repeatCounter);
    getMockEndpoint("mock:end").setRetainFirst(0);
    getMockEndpoint("mock:end").setRetainLast(0);

    for (int i = 0; i < repeatCounter; i++) {
        template.sendBody(paylaod);/*from w  w  w  .  j ava  2s . c o  m*/
    }

    assertMockEndpointsSatisfied(1, TimeUnit.MINUTES);
    getMockEndpoint("mock:end").reset();
}

From source file:co.cask.cdap.passport.http.client.PassportClient.java

private PassportClient(URI baseUri) {
    Preconditions.checkNotNull(baseUri);
    this.baseUri = baseUri;
    //Cache valid responses from Servers for 10 mins
    responseCache = CacheBuilder.newBuilder().maximumSize(10000).expireAfterAccess(10, TimeUnit.MINUTES)
            .build();/*from  ww w. j av  a2  s. c o  m*/
    accountCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterAccess(10, TimeUnit.MINUTES).build();
}

From source file:se.curity.examples.oauth.jwt.JwkManager.java

public JwkManager(URI jwksUri, long minKidReloadTimeInSeconds, HttpClient httpClient) {
    this._jwksUri = jwksUri;
    _jsonWebKeyByKID = new TimeBasedCache<>(Duration.ofSeconds(minKidReloadTimeInSeconds), this::reload);
    _httpClient = httpClient;/*from w ww  .  j  a  va2 s . c  o  m*/

    // invalidate the cache periodically to avoid stale state
    _executor.scheduleAtFixedRate(this::ensureCacheIsFresh, 5, 15, TimeUnit.MINUTES);
}

From source file:co.mafiagame.engine.executor.CommandExecutor.java

@PostConstruct
public void init() {
    commandsMap = new HashMap<>();
    commands.forEach(c -> commandsMap.put(c.commandName(), c));
    singleThread = new ThreadPoolExecutor(10, 10, keepAlive, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
}

From source file:de.anycook.api.MessageApi.java

@GET
@Produces(MediaType.APPLICATION_JSON)//from w  ww  . ja  v  a 2s  .  c om
public void get(@Suspended final AsyncResponse asyncResponse, @QueryParam("lastChange") Long lastChange) {
    asyncResponse.setTimeoutHandler(asyncResponse1 -> asyncResponse1.resume(Response.ok().build()));

    asyncResponse.setTimeout(5, TimeUnit.MINUTES);

    User user = session.getUser();

    if (lastChange == null) {
        try {
            List<MessageSession> sessions = MessageSession.getSessionsFromUser(user.getId());
            GenericEntity<List<MessageSession>> entity = new GenericEntity<List<MessageSession>>(sessions) {
            };
            asyncResponse.resume(entity);
        } catch (SQLException e) {
            logger.error(e, e);
            asyncResponse.resume(new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR));
        }
        return;
    }

    Date changeDate = new Date(lastChange);
    try {
        List<MessageSession> sessions = MessageSession.getSessionsFromUser(user.getId(), changeDate);
        GenericEntity<List<MessageSession>> entity = new GenericEntity<List<MessageSession>>(sessions) {
        };
        if (!sessions.isEmpty()) {
            asyncResponse.resume(entity);
        } else {
            MessageSessionProvider.INSTANCE.suspend(user.getId(), asyncResponse);
        }
    } catch (SQLException | DBMessage.SessionNotFoundException e) {
        logger.error(e, e);
        asyncResponse.resume(new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR));
    }

}

From source file:com.microsoft.alm.plugin.authentication.AuthHelper.java

/**
 * This method wraps the normal Async call to authenticate and waits on the result.
 *///from w ww  . j a  v a 2s.co m
public static AuthenticationInfo getAuthenticationInfoSynchronously(final AuthenticationProvider provider,
        final String gitRemoteUrl) {
    final SettableFuture<AuthenticationInfo> future = SettableFuture.create();

    provider.authenticateAsync(gitRemoteUrl, new AuthenticationListener() {
        @Override
        public void authenticating() {
            // do nothing
        }

        @Override
        public void authenticated(final AuthenticationInfo authenticationInfo, final Throwable throwable) {
            if (throwable != null) {
                future.setException(throwable);
            } else {
                future.set(authenticationInfo);
            }
        }
    });

    // Wait for the authentication info object to be ready
    // Don't wait any longer than 15 minutes for the user to authenticate
    Throwable t = null;
    try {
        return future.get(15, TimeUnit.MINUTES);
    } catch (InterruptedException ie) {
        t = ie;
    } catch (ExecutionException ee) {
        t = ee;
    } catch (TimeoutException te) {
        t = te;
    } finally {
        if (t != null) {
            logger.error("getAuthenticationInfoSynchronously: failed to get authentication info from user");
            logger.warn("getAuthenticationInfoSynchronously", t);
        }
    }
    return null;
}