List of usage examples for java.util.concurrent TimeUnit MILLISECONDS
TimeUnit MILLISECONDS
To view the source code for java.util.concurrent TimeUnit MILLISECONDS.
Click Source Link
From source file:com.twitter.distributedlog.config.TestDynamicConfigurationFactory.java
private DynamicConfigurationFactory getConfigFactory(File configFile) { String streamConfigPath = configFile.getParent(); ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1); ConcurrentBaseConfiguration defaultConf = new ConcurrentConstConfiguration( new DistributedLogConfiguration()); return new DynamicConfigurationFactory(executorService, 100, TimeUnit.MILLISECONDS); }
From source file:com.blackducksoftware.integration.hub.docker.executor.Executor.java
public String[] executeCommand(final String commandString) throws IOException, InterruptedException, HubIntegrationException { final List<String> commandStringList = Arrays.asList(commandString.split(" ")); final ProcessBuilder builder = new ProcessBuilder(); builder.command(commandStringList.toArray(new String[commandStringList.size()])); builder.directory(new File(".")); final Process process = builder.start(); final boolean finished = process.waitFor(this.commandTimeout, TimeUnit.MILLISECONDS); if (!finished) { throw new HubIntegrationException(String.format( "Execution of command %s timed out (timeout: %d milliseconds)", commandString, commandTimeout)); }/*ww w . j a va 2 s . c o m*/ final int errCode = process.exitValue(); if (errCode == 0) { logger.debug(String.format("Execution of command: %s: Succeeded", commandString)); } else { throw new HubIntegrationException( String.format("Execution of command: %s: Error code: %d", commandString, errCode)); } final InputStream inputStream = process.getInputStream(); final String outputString = IOUtils.toString(inputStream, StandardCharsets.UTF_8); logger.debug(String.format("Command output:/n%s", outputString)); return outputString.split(System.lineSeparator()); }
From source file:de.codecentric.batch.metrics.GraphiteMetricsExporter.java
public GraphiteMetricsExporter(MetricRegistry metricRegistry, final MetricReader metricReader, String server, Integer port, String environment) { Graphite graphite = new Graphite(new InetSocketAddress(server, port)); MetricFilter filter = new MetricFilter() { @Override/*from ww w. ja va 2s . co m*/ public boolean matches(String name, Metric metric) { org.springframework.boot.actuate.metrics.Metric<?> bootMetric = metricReader.findOne(name); if (bootMetric.getTimestamp().after(lastExport)) { return true; } return false; } }; reporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith(environment) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(filter) .build(graphite); }
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);//w w w .ja v a 2 s .c o m recordSuccessfulRequests(2); recordFailedRequests(5); TimeUnit.SECONDS.sleep(TIME_DELAY); }
From source file:at.ac.univie.isc.asio.spring.ApplicationRunner.java
public ApplicationRunner run(final String... args) { assert context == null : "application already started"; context = builder.showBanner(false).run(args); Unchecked.sleep(100, TimeUnit.MILLISECONDS); // brief pause to allow initialization to complete System.out.printf(Locale.ENGLISH, ">> running application [%s (%s)]%n", context.getId(), context); return this; }
From source file:locksdemo.RedisLockService.java
@Override public Iterable<Lock> findAll() { Set<String> keys = redisOperations.keys(prefix + "*"); Set<Lock> locks = new LinkedHashSet<Lock>(); for (String key : keys) { Date expires = new Date( System.currentTimeMillis() + redisOperations.getExpire(key, TimeUnit.MILLISECONDS)); locks.add(new Lock(nameForKey(key), redisOperations.opsForValue().get(key), expires)); }/*ww w . ja v a 2 s.c o m*/ return locks; }
From source file:com.olacabs.fabric.compute.PipelineTestBench.java
/** * A constructor for getting an instance of {@code PipelineTestBench}. *//*from w ww . ja v a 2 s . c o m*/ public PipelineTestBench() { metricRegistry = SharedMetricRegistries.getOrCreate("metrics-registry"); metricRegistry.timer("consume-timer"); reporter = ConsoleReporter.forRegistry(metricRegistry).convertDurationsTo(TimeUnit.MILLISECONDS) .convertRatesTo(TimeUnit.SECONDS).filter(MetricFilter.ALL).build(); }
From source file:tools.datasync.db2db.sync.SyncManagerImpl.java
public void initiate() { try {//from w w w . j ava 2s .c o m seedOutExecutor = new ThreadPoolExecutor(1, 1, 100, TimeUnit.MILLISECONDS, queues.getSeedOutQueue()); seedInExecutor = new ThreadPoolExecutor(1, 1, 100, TimeUnit.MILLISECONDS, queues.getSeedInQueue()); } catch (Exception ex) { exceptionHandler.handle(ex, Level.SEVERE, "Initialization Failure"); } }
From source file:CreateTest.java
static void doTestPool(int nThreads) { done = false;/* ww w. j a v a 2 s .com*/ nCalls = new AtomicInteger(0); ThreadPoolExecutor tpe = new ThreadPoolExecutor(nThreads, nThreads, 50000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); Runnable r = new CreateTest(); for (int i = 0; i < target; i++) { tpe.execute(r); } tpe.shutdown(); try { tpe.awaitTermination(10000000L, TimeUnit.SECONDS); } catch (Exception e) { } }
From source file:net.firejack.platform.web.statistics.engine.BufferScheduleSwitcher.java
/***/ public void scheduleTasks() { executorService = new ScheduledThreadPoolExecutor(2); executorService.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); // Calendar calendar = DateTimeUtils.getSynchTime(synchTime); // if (calendar.before(Calendar.getInstance())) { // calendar.add(Calendar.DAY_OF_MONTH, 1); // }/* ww w. j a v a 2s . c om*/ // long delay = calendar.getTimeInMillis() - System.currentTimeMillis(); long delay = 0; executorService.scheduleAtFixedRate(new ImportTask(), delay, DateUtils.MILLIS_PER_DAY, TimeUnit.MILLISECONDS); }