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:org.lendingclub.mercator.dynect.DynectClient.java
public String getToken() { token = tokenRef.get();/* ww w . ja v a2 s .c o m*/ if (token == null || token.isExpired(5, TimeUnit.MINUTES)) { token = tokenSupplier.get(); } else { logger.debug(" Dyn token is still valid"); } tokenRef.set(token); return token.getValue(); }
From source file:io.cloudslang.lang.cli.services.ConsolePrinterImpl.java
@Override public synchronized void waitForAllPrintTasksToFinish() { try {// ww w .j a va 2s . c om if (lastTask != null) { lastTask.get(1, TimeUnit.MINUTES); } } catch (InterruptedException | ExecutionException | TimeoutException ignore) { } }
From source file:com.zuoxiaolong.blog.cache.config.GuavaCacheConfig.java
@Bean @Override// www .j a va 2s .com public CacheManager cacheManager() { SimpleCacheManager cacheManager = new SimpleCacheManager(); GuavaCache guavaCache = new GuavaCache(BLOG_CACHE, CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES) //5 .build()); cacheManager.setCaches(Arrays.asList(guavaCache)); return cacheManager; }
From source file:org.trendafilov.odesk.notifier.Main.java
public void startup() { ScheduledExecutorService executor = Executors.newScheduledThreadPool(2); executor.scheduleAtFixedRate(alertDeamon, 1, 1, TimeUnit.MINUTES); while (true) { executor.submit(newJobPooler);// w w w . j a v a 2 s . co m int randomDelay = 3 + (int) (Math.random() * 5); Logger.info(String.format("Sleeping for: [%s]", randomDelay)); try { Thread.sleep(randomDelay * 1000 * 60); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
From source file:gda.device.detector.mythen.data.MythenDataFileUtils.java
/** * Reads the specified Mythen processed data files. * //from w w w .j a v a2 s.co m * @param filenames * the names of the files to read * @return 3D double array of data */ public static double[][][] readMythenProcessedDataFiles(String filenames[]) { // 3D array of data; will be filled in by tasks (one task per file to be loaded) final double[][][] data = new double[filenames.length][][]; // thread pool for loading files // 4 threads seems to give good results ExecutorService executor = Executors.newFixedThreadPool(4); // create and execute a task for each file to be loaded for (int i = 0; i < filenames.length; i++) { final int index = i; final String filename = filenames[i]; Runnable r = new Runnable() { @Override public void run() { data[index] = readMythenProcessedDataFile(filename, false); } }; executor.execute(r); } // wait until executor has shut down executor.shutdown(); try { boolean terminated = executor.awaitTermination(1, TimeUnit.MINUTES); if (!terminated) { throw new Exception("Timed out waiting for files to load"); } } catch (Exception e) { throw new RuntimeException("Unable to load data", e); } return data; }
From source file:cz.muni.fi.crocs.EduHoc.SerialMain.java
public SerialMain(CommandLine cmd, MoteList motelist) { this.cmd = cmd; this.motelist = motelist; //get value of time, if not set, use default 15 time = TimeUnit.MINUTES.toMillis(Integer.parseInt(cmd.getOptionValue("T"))); }
From source file:com.groupon.odo.containers.HttpProxyContainer.java
@Bean public EmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(); int httpPort = Utils.getSystemPort(Constants.SYS_HTTP_PORT); factory.setPort(httpPort);/* w ww. j a v a 2 s . co m*/ factory.setSessionTimeout(10, TimeUnit.MINUTES); factory.addAdditionalTomcatConnectors(createSslConnector()); factory.addContextCustomizers(new TomcatContextCustomizer() { // The Context element represents a web application, which is run within a particular virtual host. // You may define as many Context elements as you wish. // Each such Context MUST have a unique context name within a virtual host. // The context path does not need to be unique (see parallel deployment below). // https://tomcat.apache.org/tomcat-7.0-doc/config/context.html @Override public void customize(Context context) { JarScanner jarScanner = new JarScanner() { @Override public void scan(ServletContext context, ClassLoader loader, JarScannerCallback scannerCallback, Set<String> args) { } }; context.setJarScanner(jarScanner); } }); try { TransparentProxy.getInstance(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return factory; }
From source file:com.skelril.skree.content.modifier.ModExtendCommand.java
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class); if (!optService.isPresent()) { src.sendMessage(Text.of(TextColors.DARK_RED, "Modifier service not found.")); return CommandResult.empty(); }/*w w w .jav a 2 s . com*/ ModifierService service = optService.get(); String modifier = args.<String>getOne("modifier").get(); int minutes = args.<Integer>getOne("minutes").get(); boolean wasActive = service.isActive(modifier); service.extend(modifier, TimeUnit.MINUTES.toMillis(minutes)); String friendlyName = StringUtils.capitalize(modifier.replace("_", " ").toLowerCase()); String friendlyTime = PrettyText.date(service.expiryOf(modifier)); String change = wasActive ? " extended" : " enabled"; String rawMessage = friendlyName + change + " till " + friendlyTime + "!"; MessageChannel.TO_ALL.send(Text.of(TextColors.GOLD, rawMessage)); GameChatterPlugin.inst().sendSystemMessage(rawMessage); return CommandResult.success(); }
From source file:net.i2cat.netconf.utils.TimerKeepAlive.java
public void start(int period) { this.period = period; log.info("KeepAlive timer started"); schedulerHandler = timer.scheduleAtFixedRate(this, period, period, TimeUnit.MINUTES); }
From source file:org.apache.cmueller.camel.apachecon.na2013.CxfDataFormatTest.java
@Test public void measureExecution() throws Exception { template.setDefaultEndpointUri("http://localhost:8999/DirectProxy"); String paylaod = IOUtils.toString(new FileInputStream("src/test/data/1K_buyStocks.xml"), "UTF-8"); warmUp(paylaod);// ww w. j a va 2 s . c o m getMockEndpoint("mock:end").expectedMessageCount(repeatCounter); getMockEndpoint("mock:end").setRetainFirst(0); getMockEndpoint("mock:end").setRetainLast(0); StopWatch watch = new StopWatch(); for (int i = 0; i < repeatCounter; i++) { template.sendBody(paylaod); } assertMockEndpointsSatisfied(1, TimeUnit.MINUTES); System.out.println("measureHeaderExecution duration: " + watch.stop() + "ms"); }