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:eu.tango.energymodeller.energypredictor.workloadpredictor.CpuRecentHistoryWorkloadPredictor.java
/** * This takes the settings and reads them into memory and sets defaults * as needed./*from w w w. ja v a 2s. co m*/ * @param config The settings to read. */ private void readSettings(PropertiesConfiguration config) { cpuUtilObservationTimeMin = config.getInt( "energy.modeller.energy.predictor.cpu.utilisation.observe_time.min", cpuUtilObservationTimeMin); config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.min", cpuUtilObservationTimeMin); cpuUtilObservationTimeSec = config.getInt( "energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec", cpuUtilObservationTimeSec); config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec", cpuUtilObservationTimeSec); cpuUtilObservationTimeSecTotal = cpuUtilObservationTimeSec + (int) TimeUnit.MINUTES.toSeconds(cpuUtilObservationTimeMin); }
From source file:ddf.test.itests.catalog.TestFanout.java
private void startCswSource() throws Exception { getServiceManager().waitForHttpEndpoint(CSW_PATH + "?_wadl"); getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, getCswSourceProperties(CSW_SOURCE_ID, CSW_PATH.getUrl(), getServiceManager())); long timeout = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10); boolean available = false; FederatedSource source = null;//from ww w . j ava 2s.c om while (!available) { if (source == null) { source = getServiceManager().getServiceReferences(FederatedSource.class, null).stream() .map(getServiceManager()::getService).filter(src -> CSW_SOURCE_ID.equals(src.getId())) .findFirst().orElse(null); } else { available = source.isAvailable(); } if (System.currentTimeMillis() > timeout) { fail("CSW source failed to initialize in time."); } Thread.sleep(1000); } }
From source file:it.mbcraft.command_server.engine.CommandServer.java
/** * Stops the server./*from w w w. j a v a 2 s . co m*/ */ @Override public void stop() { try { wasStopped = true; server.shutdown(1, TimeUnit.MICROSECONDS); server.awaitTermination(1, TimeUnit.MINUTES); server = null; } catch (InterruptedException ex) { if (!wasStopped) { Logger.getLogger(CommandServer.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.liferay.portal.search.elasticsearch.internal.connection.ElasticsearchFixture.java
public ClusterHealthResponse getClusterHealthResponse(HealthExpectations healthExpectations) { AdminClient adminClient = getAdminClient(); ClusterAdminClient clusterAdminClient = adminClient.cluster(); ClusterHealthRequestBuilder clusterHealthRequestBuilder = clusterAdminClient.prepareHealth(); ClusterHealthRequest clusterHealthRequest = clusterHealthRequestBuilder.request(); clusterHealthRequest.timeout(new TimeValue(10, TimeUnit.MINUTES)); clusterHealthRequest.waitForActiveShards(healthExpectations.activeShards); clusterHealthRequest.waitForNodes(String.valueOf(healthExpectations.numberOfNodes)); clusterHealthRequest.waitForRelocatingShards(0); clusterHealthRequest.waitForStatus(healthExpectations.status); ActionFuture<ClusterHealthResponse> health = clusterAdminClient.health(clusterHealthRequest); return health.actionGet(); }
From source file:com.twitter.hraven.hadoopJobMonitor.metrics.HadoopJobMonitorMetrics.java
static HadoopJobMonitorMetrics create(Configuration conf) { MetricsSystem ms = DefaultMetricsSystem.instance(); HadoopJobMonitorMetrics metricObject = new HadoopJobMonitorMetrics(); MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(metricObject); final MetricsSource s = sb.build(); ms.register("HadoopJobMonitorMetrics", "The Metrics of HadoopJobMonitor service", s); ScheduledExecutorService heartbeatExecutor = Executors .newSingleThreadScheduledExecutor(new SimpleThreadFactory()); heartbeatExecutor.scheduleAtFixedRate(metricObject.new Heart(), 0, 1, TimeUnit.MINUTES); return metricObject; }
From source file:DIA_Umpire_To_Skyline.FileThread.java
public void GenerateSkylineFiles() { try {/*from w ww. j a v a 2 s .c om*/ long time = System.currentTimeMillis(); DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs); if (!new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ1Name() + ".mzXML").exists() | !new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ2Name() + ".mzXML") .exists() | !new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ3Name() + ".mzXML") .exists()) { throw new RuntimeException(); } Logger.getRootLogger().info( "================================================================================================="); Logger.getRootLogger().info("Processing " + mzXMLFile); if (!DiaFile.RawMGFExist()) { if (!DiaFile.LoadDIASetting()) { Logger.getRootLogger().info("Loading DIA setting failed, job is incomplete"); System.exit(1); } if (!DiaFile.LoadParams()) { Logger.getRootLogger().info("Loading parameters failed, job is incomplete"); System.exit(1); } DiaFile.BuildStructure(); if (!DiaFile.MS1FeatureMap.ReadPeakCluster()) { Logger.getRootLogger().info("Loading peak and structure failed, job is incomplete"); System.exit(1); } DiaFile.CreateSkylingImportFolder(); DiaFile.GenerateRawMGF(); DiaFile.ClearStructure(); } DiaFile.ConvertRawMGF(msconvertpath); ChangeScanTitlePepXML(); DiaFile = null; System.gc(); time = System.currentTimeMillis() - time; Logger.getRootLogger() .info(mzXMLFile + " processed time:" + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time), TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)), TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time)))); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); } }
From source file:com.reactivetechnologies.analytics.core.handlers.ModelCombinerComponent.java
/** * Runs a cluster wide model collection, and generates a combined (ensembled/voted/evaluated) classifier model. * The generated model is persisted in database, only if it is different than the ones already present. * @return Persisted model Id, or "" if not persisted in this run * @throws EngineException//from w w w . ja v a2s . co m */ public CombinerResult runTask() throws EngineException { log.info("[ensembleModelTask] task starting.."); String modelId = ""; CombinerResult result = CombinerResult.IGNORED; try { boolean done = tryMemberSnapshot(10, TimeUnit.MINUTES); if (done) { modelId = ensembleModels(); if (modelId != null) { result = CombinerResult.MODEL_CREATED; result.setModelId(modelId); } } else { log.info("[ensembleModelTask] task ignored.. "); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); log.debug("", e); } catch (TimeoutException e) { log.warn("[ensembleModelTask] task timed out. Generated model may be inconsistent", e); result = CombinerResult.MODEL_CREATED; } catch (EngineException e) { if (e.getCause() instanceof DuplicateKeyException) { log.warn(e.getMessage()); //log.debug(e.getMessage(), e.getCause()); result = CombinerResult.MODEL_EXISTS; result.setModelId(e.getCause().getMessage()); } else throw e; } return result; }
From source file:com.topekalabs.synchronization.LockTest.java
private void testWithContentionHelper(int numThreads, ExecutorService es) { final long timeout = 4000; final int numIncs = 500; final int expectedIncs = numIncs * numThreads; final MutableInt a = new MutableInt(); final MutableInt b = new MutableInt(); final Lock lock; try {//from w w w . j a v a2 s . co m lock = lockClass.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { throw new RuntimeException(ex); } Callable<Integer> callable = new Callable<Integer>() { @Override public Integer call() throws Exception { for (int incCount = 0; incCount < numIncs; incCount++) { lock.lock(); int tempB = b.intValue(); a.increment(); Thread.sleep(1); a.add(b.intValue() - tempB); b.increment(); lock.unlock(); } return 1; } }; List<Callable<Integer>> callables = CollectionUtils.fillEmptyCollection(new ArrayList<Callable<Integer>>(), callable, numThreads); try { List<Future<Integer>> futures = es.invokeAll(callables); ThreadUtils.done(futures, timeout, TimeUnit.MINUTES); } catch (InterruptedException | TimeoutException | ExecutionException ex) { ErrorThrower.kill(ex); } Assert.assertEquals("Incorrect number of increments.", expectedIncs, a.intValue()); Assert.assertEquals("Incorrect number of increments.", expectedIncs, b.intValue()); }
From source file:com.graphaware.importer.context.BaseImportContext.java
/** * {@inheritDoc}/*w w w . j av a 2s.co m*/ */ @Override public final void shutdown() { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); executor.scheduleAtFixedRate(new Runnable() { @Override public void run() { LOG.info("I am still alive!"); } }, 1, 1, TimeUnit.MINUTES); preShutdown(); indexProvider().shutdown(); inserter().shutdown(); postShutdown(); executor.shutdownNow(); }
From source file:gov.llnl.lc.smt.command.help.SmtHelp.java
/** * Describe the method here/*w w w.j ava 2s . c om*/ * * @see gov.llnl.lc.smt.command.SmtCommand#doCommand(gov.llnl.lc.smt.command.config.SmtConfig) * * @param config * @return * @throws Exception ***********************************************************/ @Override public boolean doCommand(SmtConfig config) throws Exception { boolean exit = false; if (!exit) { logger.severe("Starting the SMT HELP GUI Application Now"); (new SmtHelpRunner(this)).run(); } else logger.severe("Could not start the SMT HELP GUI Application, check service updater"); // infinite wait loop while (!exit) TimeUnit.MINUTES.sleep(5); return true; }