List of usage examples for java.util.concurrent TimeUnit MINUTES
TimeUnit MINUTES
To view the source code for java.util.concurrent TimeUnit MINUTES.
Click Source Link
From source file:com.adeptj.modules.cache.caffeine.internal.CaffeineCacheService.java
@Reference(service = CaffeineCacheFactory.class, cardinality = MULTIPLE, policy = DYNAMIC) public void bindCaffeineCacheFactory(CaffeineCacheFactory cacheFactory) { CaffeineCacheConfig cacheConfig = cacheFactory.getCacheConfig(); this.caches.add( new CaffeineCache<>(cacheConfig.name(), Caffeine.newBuilder().maximumSize(cacheConfig.maximumSize()) .expireAfterWrite(cacheConfig.expireAfter(), TimeUnit.MINUTES).build())); }
From source file:jdbc.pool.LoadTest.java
/** * //from ww w .j a v a 2s . c o m */ private void startLoadTest() { try { poolManager_.getConnection("TMP"); TimeUnit.MINUTES.sleep(50); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { poolManager_.destroy(true); } // long lStartTime = System.currentTimeMillis(); // iThreadCounter_ = 0; // while ((System.currentTimeMillis() - lStartTime) <(iTimeInMinutes_ * 60 * 60 * 1000)) { // if (iThreadCounter_ < iThreads_) { // Thread th = new Thread(new JDBCPoolT(iThreadCounter_)); // th.start(); // iThreadCounter_++; // } // } }
From source file:com.jkoolcloud.tnt4j.streams.utils.StreamsCache.java
private static Cache<String, CacheValue> buildCache(long cSize, long duration) { return CacheBuilder.newBuilder().maximumSize(cSize).expireAfterAccess(duration, TimeUnit.MINUTES).build(); }
From source file:com.netflix.spinnaker.orca.clouddriver.tasks.image.UpsertImageTagsTask.java
@Override public long getTimeout() { return TimeUnit.MINUTES.toMillis(10); }
From source file:org.spring.data.gemfire.app.main.SpringGemFireClient.java
@Bean PoolFactoryBean gemfirePool(@Value("${gemfire.client.server.host:localhost}") String serverHost, @Value("${gemfire.client.server.port:40404}") int serverPort, @Value("${gemfire.client.server.max-connections:50}") int maxConnections) { PoolFactoryBean gemfirePool = new PoolFactoryBean(); gemfirePool.setFreeConnectionTimeout(intValue(TimeUnit.SECONDS.toMillis(30))); gemfirePool.setIdleTimeout(TimeUnit.MINUTES.toMillis(2)); gemfirePool.setKeepAlive(false);//from www .java2s .c o m gemfirePool.setMaxConnections(maxConnections); gemfirePool.setPingInterval(TimeUnit.SECONDS.toMillis(15)); gemfirePool.setReadTimeout(intValue(TimeUnit.SECONDS.toMillis(20))); gemfirePool.setRetryAttempts(1); gemfirePool.setPrSingleHopEnabled(true); gemfirePool.setThreadLocalConnections(false); gemfirePool.addServers(new ConnectionEndpoint(serverHost, serverPort)); return gemfirePool; }
From source file:com.examples.abelanav2.BucketNotificationServlet.java
@Override public final void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { // Decode the name and bucket of the notification BucketNotification notification;//from w w w .j a va 2s . c o m try { String jsonString = IOUtils.toString(req.getInputStream()); notification = new Gson().fromJson(jsonString, BucketNotification.class); } catch (IOException e) { log("Failed to decode the notification: " + e.getMessage()); resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } try { if (!req.getHeader("X-Goog-Channel-Token").equals(ConfigurationConstants.SECRET_NOTIF_TOKEN)) { resp.setStatus(HttpStatusCodes.STATUS_CODE_FORBIDDEN); return; } if (!req.getHeader("X-Goog-Resource-State").equals("exists")) { resp.getWriter().write("This is not a new photo addition."); resp.setStatus(HttpStatusCodes.STATUS_CODE_OK); return; } // Handle duplicated notifications, drop keys after 5 minutes Boolean inCache = false; Cache cache = null; try { CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory(); Map<Object, Object> properties = new HashMap<>(); properties.put(GCacheFactory.EXPIRATION_DELTA, TimeUnit.MINUTES.toSeconds(5)); properties.put(MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT, true); cache = cacheFactory.createCache(properties); inCache = (Boolean) cache.get(notification.getName()); } catch (CacheException e) { log("Failed to instantiate the Memcache, risk of duplicate notifications: " + e.getMessage()); } if (inCache == null || !inCache) { // Add a new task to the queue Queue queue = QueueFactory.getDefaultQueue(); queue.add(TaskOptions.Builder.withUrl("/notice/incoming-image") .param("bucket", notification.getBucket()).param("name", notification.getName())); if (cache != null) { cache.put(notification.getName(), true); } resp.getWriter().write("Task added to the queue"); log("Task created for bucket " + notification.getBucket() + " and file " + notification.getName()); } else { resp.getWriter().write("This is a duplicate notification"); log("Duplicate notification for bucket " + notification.getBucket() + " and file " + notification.getName()); } resp.setStatus(HttpStatusCodes.STATUS_CODE_OK); } catch (IOException e) { log("Error while writing the response"); resp.setStatus(HttpStatusCodes.STATUS_CODE_SERVER_ERROR); } }
From source file:ch.fihlon.moodini.business.token.control.TokenService.java
@Inject public TokenService(@NotNull final MoodiniConfiguration configuration, @NotNull final UserService userService) { this.configuration = configuration; this.tokenSecret = configuration.getTokenSecret().getBytes(Charsets.UTF_8); this.userService = userService; challengeCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(); }
From source file:org.apache.cmueller.camel.apachecon.na2013.SqlSimpleTest.java
private void warmUp(List<Object> paylaod) throws InterruptedException { 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 a v a 2 s . c o m*/ } assertMockEndpointsSatisfied(5, TimeUnit.MINUTES); getMockEndpoint("mock:end").reset(); }
From source file:com.eviware.loadui.impl.conversion.ReferenceToFileConverter.java
public ReferenceToFileConverter(AddressableRegistry addressableRegistry, ScheduledExecutorService executorService) { addressableRegistry.addEventListener(CollectionEvent.class, this); executorService.scheduleAtFixedRate(new RemoveOldFilesTask(), 5, 5, TimeUnit.MINUTES); if (!storage.isDirectory()) if (!storage.mkdirs()) throw new RuntimeException("Unable to create path: " + storage.getAbsolutePath()); }
From source file:com.techcavern.wavetact.eventListeners.MCStatusListener.java
public void run() { while (true) { try {/*from www. j a va 2 s . co m*/ JsonArray mcstatus = GeneralUtils.getJsonArray("https://status.mojang.com/check"); mcstatus.forEach(status -> { String name = status.getAsJsonObject().entrySet().iterator().next().getKey().toString(); if (name.equalsIgnoreCase("minecraft.net")) { name = "Website"; } else if (name.equalsIgnoreCase("api.mojang.com")) { name = "API"; } else if (name.equalsIgnoreCase("authserver.mojang.com")) { name = "AuthServer"; } else if (name.equalsIgnoreCase("sessionserver.mojang.com")) { name = "SessionServer"; } else { name = WordUtils.capitalize(name.replace(".minecraft.net", "").replace(".mojang.com", "")); } String value = status.getAsJsonObject().entrySet().iterator().next().getValue().getAsString(); if (value.equalsIgnoreCase("green")) { value = "Online"; } else if (value.equalsIgnoreCase("yellow")) { value = "Overloaded"; } else { value = "Offline"; } final String mcname = name; final String mcvalue = value; if (MCStatus.get(name) != null && !MCStatus.get(name).equalsIgnoreCase(value)) { Registry.networks.values().forEach(bot -> { bot.getUserChannelDao().getAllChannels().forEach(chan -> { Record prop = DatabaseUtils.getChannelProperty( IRCUtils.getNetworkNameByNetwork(bot), chan.getName(), "notifymc"); if (prop != null && prop.getValue(CHANNELPROPERTY.VALUE).equalsIgnoreCase("true")) { IRCUtils.sendMessage(bot, chan, "[MC Status] " + mcname + " is now " + mcvalue, ""); } }); }); } MCStatus.put(name, value); }); } catch (Exception e) { } try { TimeUnit.MINUTES.sleep(1); } catch (Exception e) { } } }