List of usage examples for java.util.concurrent TimeUnit SECONDS
TimeUnit SECONDS
To view the source code for java.util.concurrent TimeUnit SECONDS.
Click Source Link
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); }/* w ww .ja v a2 s. c o m*/ 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:com.ngdata.hbaseindexer.indexer.IndexingEventListener.java
/** * Instantiate with the underlying indexer, and the name of the table for which events are to be intercepted. * //from w w w. j a v a2 s .co m * @param indexer indexer engine that will create index documents from incoming event data * @param targetTableNameExpression name of the table for which updates are to be indexed */ public IndexingEventListener(Indexer indexer, final String targetTableNameExpression) { this.indexer = indexer; incomingEventsMeter = Metrics.newMeter(metricName(getClass(), "Incoming events", indexer.getName()), "Rate of incoming SEP events", TimeUnit.SECONDS); applicableEventsMeter = Metrics.newMeter(metricName(getClass(), "Applicable events", indexer.getName()), "Rate of incoming SEP events that are considered applicable", TimeUnit.SECONDS); final Pattern tableNamePattern = Pattern.compile(targetTableNameExpression); tableEqualityPredicate = new Predicate<SepEvent>() { @Override public boolean apply(@Nullable SepEvent event) { return tableNamePattern.matcher(new String(event.getTable(), Charsets.UTF_8)).matches(); } }; }
From source file:io.apiman.test.integration.rest.apis.metrics.AbstractIntervalMetricsIT.java
protected void recordMetricsInFollowingMinute() throws InterruptedException { // wait until current minute expires long millisWithinMinute = System.currentTimeMillis() % TimeUnit.MINUTES.toMillis(1); long waitFor = TimeUnit.MINUTES.toMillis(1) - millisWithinMinute; LOG.info(String.format("Waiting %d seconds current minute expires.", TimeUnit.MILLISECONDS.toSeconds(waitFor))); Thread.sleep(waitFor);//from ww w.j ava2s . co m recordSuccessfulRequests(2); recordFailedRequests(5); TimeUnit.SECONDS.sleep(TIME_DELAY); }
From source file:com.boundary.sdk.metric.MeasureRouteBuilderTest.java
@Test public void testSendMetric() throws InterruptedException { Measurement measurement = new Measurement(); measurement.setSource("26"); measurement.setMetric("API_RESPONSE_TIME"); measurement.setMeasure(100);/* w ww . j av a 2s. co m*/ out.setExpectedMessageCount(1); in.sendBody(measurement); out.await(20, TimeUnit.SECONDS); out.assertIsSatisfied(); }
From source file:actors.DeployLogRelay.java
/** * Public constructor.//from ww w . jav a2s. c om * * @param channel Play channel to send data to * @param deploymentId the deployment id */ public DeployLogRelay(final Concurrent.Channel<String> channel, final long deploymentId) { _channel = channel; _deployment = Deployment.getById(deploymentId); context().system().scheduler().schedule(FiniteDuration.apply(1, TimeUnit.SECONDS), FiniteDuration.apply(3, TimeUnit.SECONDS), self(), "check", context().dispatcher(), self()); }
From source file:org.fcrepo.examples.models.integration.ExampleNodeTypesIT.java
public ExampleNodeTypesIT() { connectionManager = new PoolingHttpClientConnectionManager(); connectionManager.setMaxTotal(Integer.MAX_VALUE); connectionManager.setDefaultMaxPerRoute(20); connectionManager.closeIdleConnections(3, TimeUnit.SECONDS); client = HttpClientBuilder.create().setConnectionManager(connectionManager).build(); modelSetsDirectory = new File(modelSetsPath); if (!modelSetsDirectory.exists()) { throw new Error("Cannot find model sets"); }/*from ww w.java2s . co m*/ }
From source file:org.apache.cxf.systest.jaxrs.JAXRSCxfContinuationsTest.java
private void doTestContinuation(String pathSegment) throws Exception { ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); CountDownLatch startSignal = new CountDownLatch(1); CountDownLatch doneSignal = new CountDownLatch(1); executor.execute(new BookWorker("http://localhost:" + PORT + "/bookstore/" + pathSegment + "/1", "1", "CXF in Action1", startSignal, doneSignal)); startSignal.countDown();//from w w w . jav a 2s . co m doneSignal.await(60, TimeUnit.SECONDS); executor.shutdownNow(); assertEquals("Not all invocations have completed", 0, doneSignal.getCount()); }
From source file:com.garethahealy.jolokiajvmhawkular.core.EmbeddedHawkularMetricsAgent.java
public static void premain(String agentArgs) { CustomJvmAgent.premain(agentArgs);/*from w w w .j a va2 s . co m*/ try { LOG.info("About to load BackendManager..."); Field jolokiaHttpHandlerField = FieldUtils.getDeclaredField(server.getClass(), "jolokiaHttpHandler", true); JolokiaHttpHandler jolokiaHttpHandler = (JolokiaHttpHandler) jolokiaHttpHandlerField.get(server); Field backendManagerField = FieldUtils.getDeclaredField(jolokiaHttpHandler.getClass(), "backendManager", true); BackendManager backendManager = (BackendManager) backendManagerField.get(jolokiaHttpHandler); HawkularClient client = getHawkularClient(); if (client == null) { LOG.error( "HawkularClient is null. Not starting HawkularMetricsService via ScheduledExecutorService."); } else { BasicThreadFactory factory = new BasicThreadFactory.Builder().namingPattern("hawkular-metrics-%d") .daemon(true).priority(Thread.MAX_PRIORITY).build(); ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(factory); exec.scheduleAtFixedRate( new HawkularMetricsRunnable(new HawkularMetricsService(backendManager, client)), 15, 15, TimeUnit.SECONDS); LOG.info("Started HawkularMetricsService via ScheduledExecutorService."); } } catch (IllegalAccessException e) { LOG.error("{}", e); } }
From source file:ch.icclab.cyclops.timeseries.InfluxDBClient.java
/** * Ask for connection to InfluxDB// ww w . j a v a 2s. c om * @return session */ private InfluxDB obtainSession() { // http client builder OkHttpClient.Builder builder = new OkHttpClient().newBuilder(); // preferred time outs builder.connectTimeout(credentials.getInfluxDBQueryTimeout(), TimeUnit.SECONDS); builder.writeTimeout(credentials.getInfluxDBQueryTimeout(), TimeUnit.SECONDS); builder.readTimeout(credentials.getInfluxDBQueryTimeout(), TimeUnit.SECONDS); // establish influxDB connection with our own builder return InfluxDBFactory.connect(credentials.getInfluxDBURL(), credentials.getInfluxDBUsername(), credentials.getInfluxDBPassword(), builder); }
From source file:hudson.model.DependencyGraphTest.java
/** * Tests triggering downstream projects with DependencyGraph.Dependency *///from w ww .j av a 2 s. c o m public void testTriggerJob() throws Exception { hudson.quietPeriod = 3; Project p = createFreeStyleProject(), down1 = createFreeStyleProject(), down2 = createFreeStyleProject(); // Add one standard downstream job: p.addPublisher(new BuildTrigger(Collections.singletonList(down1), Result.SUCCESS)); // Add one downstream job with custom Dependency impl: p.getBuildersList().add(new TestDeclarer(Result.UNSTABLE, down2)); hudson.rebuildDependencyGraph(); // First build won't trigger down1 (Unstable doesn't meet threshold) // but will trigger down2 (build #1 is odd). Build b = (Build) p.scheduleBuild2(0, new Cause.UserCause()).get(); String log = getLog(b); Queue.Item q = hudson.getQueue().getItem(down1); assertNull("down1 should not be triggered: " + log, q); assertNull("down1 should not be triggered: " + log, down1.getLastBuild()); q = hudson.getQueue().getItem(down2); assertNotNull("down2 should be in queue (quiet period): " + log, q); Run r = (Run) q.getFuture().get(6, TimeUnit.SECONDS); assertNotNull("down2 should be triggered: " + log, r); assertNotNull("down2 should have MailMessageIdAction", r.getAction(MailMessageIdAction.class)); // Now change to success result.. p.getBuildersList().replace(new TestDeclarer(Result.SUCCESS, down2)); hudson.rebuildDependencyGraph(); // ..and next build will trigger down1 (Success meets threshold), // but not down2 (build #2 is even) b = (Build) p.scheduleBuild2(0, new Cause.UserCause()).get(); log = getLog(b); q = hudson.getQueue().getItem(down2); assertNull("down2 should not be triggered: " + log, q); assertEquals("down2 should not be triggered: " + log, 1, down2.getLastBuild().getNumber()); q = hudson.getQueue().getItem(down1); assertNotNull("down1 should be in queue (quiet period): " + log, q); r = (Run) q.getFuture().get(6, TimeUnit.SECONDS); assertNotNull("down1 should be triggered", r); }