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.precioustech.fxtrading.tradingbot.strategies.FadeTheMoveStrategy.java

@PostConstruct
public void init() {
    for (TradeableInstrument<T> instrument : instruments) {
        Cache<DateTime, MarketDataPayLoad<T>> recentPricesCache = CacheBuilder.newBuilder()
                .expireAfterWrite(tradingConfig.getFadeTheMovePriceExpiry(), TimeUnit.MINUTES)
                .<DateTime, MarketDataPayLoad<T>>build();
        instrumentRecentPricesCache.put(instrument, recentPricesCache);
    }/*from   w w w  .  j a va 2s.c o  m*/
}

From source file:org.zenoss.zep.dao.impl.ConfigDaoImpl.java

private static int calculateMaximumDays(PartitionTableConfig config) {
    long partitionRange = config.getPartitionUnit().toMinutes(config.getPartitionDuration()) * MAX_PARTITIONS;
    return (int) TimeUnit.DAYS.convert(partitionRange, TimeUnit.MINUTES);
}

From source file:org.ow2.proactive.connector.iaas.cloud.provider.jclouds.JCloudsComputeServiceBuilder.java

/**
 * Sets the timeouts for the deployment.
 * //ww  w .  j  av a2  s  .  c o  m
 * @return Properties object with the timeout policy.
 */
private Properties getTimeoutPolicy() {
    Properties properties = new Properties();
    long scriptTimeout = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
    properties.setProperty("jclouds.ssh.max-retries", "100");
    properties.setProperty("jclouds.max-retries", "1000");
    properties.setProperty("jclouds.request-timeout", "10000");
    properties.setProperty("jclouds.connection-timeout", "18000");

    properties.setProperty(TIMEOUT_PORT_OPEN, scriptTimeout + "");
    properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");

    return properties;
}

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

@Test
public void measureSqlSimpleExecution() throws Exception {
    template.setDefaultEndpointUri("direct:start");
    List<Object> paylaod = new ArrayList<Object>();
    paylaod.add("IBM");
    paylaod.add("cmueller");
    paylaod.add(140.34);/*from w w w  .ja va  2  s.c  o m*/
    paylaod.add(2000);

    warmUp(paylaod);

    getMockEndpoint("mock:end").expectedMessageCount(repeatCounter / batchSite);
    getMockEndpoint("mock:end").setRetainFirst(0);
    getMockEndpoint("mock:end").setRetainLast(0);

    StopWatch watch = new StopWatch();
    for (int i = 0; i < repeatCounter; i++) {
        template.sendBodyAndHeader(paylaod, "AGG_KEY", "BATCH");
    }
    assertMockEndpointsSatisfied(5, TimeUnit.MINUTES);

    System.out.println("measureSqlSimpleExecution duration: " + watch.stop() + "ms");
}

From source file:com.ebay.pulsar.analytics.security.spring.PermissionControlCache.java

private PermissionControlCache() {
    permissionControl = new UserPermissionControl();
    userService = new UserService();
    cache = CacheBuilder.newBuilder().maximumSize(SIZE_CACHE).expireAfterWrite(TIME_EXPIRE, TimeUnit.MINUTES)
            .refreshAfterWrite(TIME_REFRESH, TimeUnit.MINUTES).build(new CacheLoader<String, PulsarSession>() {
                @Override//www .j a v a2  s  .  c om
                public PulsarSession load(String userName) throws Exception {
                    return loadFromUnderlying(userName);
                }

                @Override
                public Map<String, PulsarSession> loadAll(Iterable<? extends String> keys) {
                    Map<String, PulsarSession> m = Maps.newHashMap();
                    for (String key : keys) {
                        try {
                            PulsarSession ps = load(key);
                            m.put(key, ps);
                        } catch (Exception e) {
                        }
                        ;
                    }
                    return m;
                }

                @Override
                public ListenableFuture<PulsarSession> reload(final String userName, PulsarSession prev) {
                    // asynchronous!
                    ListenableFutureTask<PulsarSession> task = ListenableFutureTask
                            .create(new Callable<PulsarSession>() {
                                public PulsarSession call() {
                                    return loadFromUnderlying(userName);
                                }
                            });
                    EXECUTOR.submit(task);
                    return task;
                }
            });
}

From source file:de.xaniox.heavyspleef.core.uuid.UUIDManager.java

public UUIDManager() {
    // Use fast Entity#getUniqueId() when onlineMode = true
    // so we don't have to query the mojang servers
    this.onlineMode = Bukkit.getOnlineMode();
    this.recentOriginalLookup = System.currentTimeMillis();

    this.profileNameCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
            .build(new CacheLoader<String, GameProfile>() {

                @SuppressWarnings("deprecation")
                @Override/*  ww w.  j a  v a 2 s  . c om*/
                public GameProfile load(String key) throws Exception {
                    GameProfile profile;

                    List<GameProfile> profiles = fetchGameProfiles(new String[] { key });

                    if (profiles.size() != 0) {
                        profile = profiles.get(0);
                    } else {
                        OfflinePlayer player = Bukkit.getOfflinePlayer(key);
                        profile = new GameProfile(player.getUniqueId(), player.getName());
                    }

                    validateContain(profile);
                    return profile;
                }

                private void validateContain(GameProfile profile) {
                    Map<UUID, GameProfile> map = profileUUIDCache.asMap();
                    if (!map.containsKey(profile.getUniqueIdentifier())) {
                        profileUUIDCache.put(profile.getUniqueIdentifier(), profile);
                    }
                }
            });

    this.profileUUIDCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
            .build(new CacheLoader<UUID, GameProfile>() {

                @Override
                public GameProfile load(UUID key) throws Exception {
                    GameProfile profile = fetchGameProfile(key);

                    if (profile == null) {
                        OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(key);
                        profile = new GameProfile(player.getUniqueId(), player.getName());
                    }

                    validateContain(profile);
                    return profile;
                }

                private void validateContain(GameProfile profile) {
                    Map<String, GameProfile> map = profileNameCache.asMap();
                    if (!map.containsKey(profile.getUniqueIdentifier())) {
                        profileUUIDCache.put(profile.getUniqueIdentifier(), profile);
                    }
                }
            });
}

From source file:com.gooddata.warehouse.WarehouseServiceAT.java

@Test(groups = "warehouse", dependsOnGroups = "account")
public void createWarehouse() throws Exception {
    final Warehouse wh = new Warehouse(title, warehouseToken);
    wh.setEnvironment(Environment.TESTING);
    warehouse = service.createWarehouse(wh).get(60, TimeUnit.MINUTES);
    s3Credentials = new WarehouseS3Credentials(S3_CREDENTIALS_REGION, S3_CREDENTIALS_ACCESS_KEY, "secret");
    String jdbc = warehouse.getConnectionUrl();
}

From source file:com.datatorrent.demos.dimensions.ads.AdsDimensionStoreOperatorTest.java

@Test
public void testQuery() throws Exception {
    File file = new File(testInfo.getDir());
    FileUtils.deleteDirectory(file);//from   w ww. j  a  v a 2 s.c  o m

    AdsDimensionStoreOperator hdsOut = new AdsDimensionStoreOperator() {
        @Override
        public void setup(OperatorContext arg0) {
            super.setup(arg0);
            super.writeExecutor = super.queryExecutor = MoreExecutors.sameThreadExecutor(); // synchronous processing
        }
    };
    TFileImpl hdsFile = new TFileImpl.DefaultTFileImpl();
    hdsOut.setFileStore(hdsFile);
    hdsFile.setBasePath(testInfo.getDir());
    hdsOut.setAggregator(new AdInfo.AdInfoAggregator());
    hdsOut.setMaxCacheSize(1);
    hdsOut.setFlushIntervalCount(0);
    hdsOut.setup(null);

    hdsOut.setDebug(false);

    CollectorTestSink<AdsDimensionStoreOperator.TimeSeriesQueryResult> queryResults = new CollectorTestSink<AdsDimensionStoreOperator.TimeSeriesQueryResult>();
    @SuppressWarnings({ "unchecked", "rawtypes" })
    CollectorTestSink<Object> tmp = (CollectorTestSink) queryResults;
    hdsOut.queryResult.setSink(tmp);

    hdsOut.beginWindow(1);

    long baseTime = System.currentTimeMillis();
    long baseMinute = TimeUnit.MILLISECONDS.convert(TimeUnit.MINUTES.convert(baseTime, TimeUnit.MILLISECONDS),
            TimeUnit.MINUTES);

    // Check aggregation for ae1 and ae2 as they have same key.
    AdInfo.AdInfoAggregateEvent ae1 = new AdInfo.AdInfoAggregateEvent();
    ae1.publisherId = 1;
    ae1.advertiserId = 2;
    ae1.adUnit = 3;
    ae1.timestamp = baseMinute;
    ae1.clicks = 10;
    hdsOut.input.process(ae1);

    AdInfo.AdInfoAggregateEvent ae2 = new AdInfo.AdInfoAggregateEvent();
    ae2.publisherId = 1;
    ae2.advertiserId = 2;
    ae2.adUnit = 3;
    ae2.timestamp = baseMinute;
    ae2.clicks = 20;
    hdsOut.input.process(ae2);

    AdInfo.AdInfoAggregateEvent ae3 = new AdInfo.AdInfoAggregateEvent();
    ae3.publisherId = 1;
    ae3.advertiserId = 2;
    ae3.adUnit = 3;
    ae3.timestamp = baseMinute + TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
    ae3.clicks = 40;
    hdsOut.input.process(ae3);

    hdsOut.endWindow();

    hdsOut.beginWindow(2);

    JSONObject keys = new JSONObject();
    keys.put("publisherId", String.valueOf(1));
    keys.put("advertiserId", String.valueOf(2));
    keys.put("adUnit", String.valueOf(3));

    JSONObject query = new JSONObject();
    query.put("numResults", "20");
    query.put("keys", keys);
    query.put("id", "query1");
    query.put("startTime", baseMinute);
    query.put("endTime", baseMinute + TimeUnit.MILLISECONDS.convert(20, TimeUnit.MINUTES));

    hdsOut.query.process(query.toString());

    Assert.assertEquals("timeSeriesQueries " + hdsOut.timeSeriesQueries, 1, hdsOut.timeSeriesQueries.size());
    AdsDimensionStoreOperator.TimeSeriesQuery aq = hdsOut.timeSeriesQueries.values().iterator().next();
    Assert.assertEquals("numTimeUnits " + hdsOut.timeSeriesQueries, baseMinute, aq.startTime);

    hdsOut.endWindow();

    Assert.assertEquals("queryResults " + queryResults.collectedTuples, 1, queryResults.collectedTuples.size());
    TimeSeriesQueryResult r = queryResults.collectedTuples.iterator().next();
    Assert.assertEquals("result points " + r, 2, r.data.size());

    // ae1 object is stored as referenced in cache, and when new tuple is aggregated,
    // the new values are updated in ae1 itself, causing following check to fail.
    //Assert.assertEquals("clicks", ae1.clicks + ae2.clicks, r.data.get(0).clicks);
    Assert.assertEquals("clicks", 10 + ae2.clicks, r.data.get(0).clicks);
    Assert.assertEquals("clicks", ae3.clicks, r.data.get(1).clicks);

    Assert.assertNotSame("deserialized", ae1, r.data.get(1));
    Assert.assertSame("from cache", ae3, r.data.get(1));

}

From source file:cloudfoundry.norouter.f5.Agent.java

public Agent(String poolNamePrefix, IControlClient client, RouteRegistrar routeRegistrar) {
    this.poolNamePrefix = poolNamePrefix;
    this.client = client;
    this.routeRegistrar = routeRegistrar;
    scheduler.scheduleAtFixedRate(this::removeStalePools, 30, 30, TimeUnit.MINUTES);
}

From source file:cn.keke.travelmix.HttpClientHelper.java

public static HttpClient getNewHttpClient() {
    try {/*from   ww  w .  j av a  2 s  .  c  o  m*/
        SSLSocketFactory sf = new EasySSLSocketFactory();

        // TODO test, if SyncBasicHttpParams is needed
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpProtocolParams.setHttpElementCharset(params, HTTP.UTF_8);
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSocketBufferSize(params, 8192);
        HttpConnectionParams.setLinger(params, 1);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);
        HttpConnectionParams.setSoReuseaddr(params, true);
        HttpConnectionParams.setTcpNoDelay(params, true);
        HttpClientParams.setCookiePolicy(params, CookiePolicy.IGNORE_COOKIES);
        HttpClientParams.setAuthenticating(params, false);
        HttpClientParams.setRedirecting(params, false);

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
        registry.register(new Scheme("https", 443, sf));

        ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager(registry, 20, TimeUnit.MINUTES);
        ccm.setMaxTotal(100);
        ccm.setDefaultMaxPerRoute(20);

        return new DefaultHttpClient(ccm, params);
    } catch (Exception e) {
        LOG.warn("Failed to create custom http client. Default http client is created", e);
        return new DefaultHttpClient();
    }
}