List of usage examples for java.util.concurrent TimeUnit MICROSECONDS
TimeUnit MICROSECONDS
To view the source code for java.util.concurrent TimeUnit MICROSECONDS.
Click Source Link
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java
/** * Failure Testing:/*from w w w . j a v a 2 s. co m*/ * * Test that delay must be long not a string value. * Provide a delay as a written value not a long. 'ten'. * * This should throw a configuration exception which is being trapped and * verified to be the right exception, a NumberFormatException. * */ public void testConfigLoadingInValidDelayString() { SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("delay", "ten"); xmlconfig.addProperty("timeunit", TimeUnit.MICROSECONDS.toString()); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("Configuration should fail to validate"); } catch (ConfigurationException e) { Throwable cause = e.getCause(); assertEquals("Cause not correct", NumberFormatException.class, cause.getClass()); } }
From source file:com.clustercontrol.systemlog.service.SystemLogMonitor.java
@Override public synchronized void start() { _executor = new MonitoredThreadPoolExecutor(_threadSize, _threadSize, 0L, TimeUnit.MICROSECONDS, new LinkedBlockingQueue<Runnable>(_queueSize), new ThreadFactory() { private volatile int _count = 0; @Override/*from ww w.j av a 2 s. com*/ public Thread newThread(Runnable r) { return new Thread(r, "SystemLogFilter-" + _count++); } }, new SystemLogRejectionHandler()); }
From source file:com.hpcloud.util.Duration.java
public long toMicros() { return TimeUnit.MICROSECONDS.convert(length, timeUnit); }
From source file:cc.kave.commons.pointsto.evaluation.TimeEvaluation.java
private DescriptiveStatistics measurePointerAnalysis(List<Context> contexts, PointsToAnalysisFactory ptFactory, MutableLong sink) {/* ww w .j a va 2 s . com*/ DescriptiveStatistics stats = new DescriptiveStatistics(); for (Context context : contexts) { PointsToAnalysis ptAnalysis = ptFactory.create(); Stopwatch watch = Stopwatch.createStarted(); PointsToContext ptContext = ptAnalysis.compute(context); watch.stop(); sink.add(ptContext.hashCode()); long time = watch.elapsed(TimeUnit.MICROSECONDS); stats.addValue(time); analysisTimes.add(new AnalysisTimeEntry(ptFactory.getName(), context.getTypeShape().getTypeHierarchy().getElement(), stmtCounts.get(context), time)); } return stats; }
From source file:com.hpcloud.util.Duration.java
public long toMicroseconds() { return TimeUnit.MICROSECONDS.convert(length, timeUnit); }
From source file:com.datatorrent.contrib.hdht.HadoopFilePerformanceTest.java
private String stopTimer(Testfile fileType, String testType) throws IOException { timer.stop();/*from w ww . j a va 2s . c om*/ long elapsedMS = timer.elapsedTime(TimeUnit.MICROSECONDS); String testKey = testSize + "," + fileType.name() + "-" + testType; long fileSize = hdfs.getContentSummary(fileType.filepath()).getSpaceConsumed(); testSummary.put(testKey, "" + elapsedMS + "," + fileSize); return String.format("%,d", timer.elapsedTime(TimeUnit.NANOSECONDS)) + " ns ( " + timer.toString(6) + " )"; }
From source file:org.asoem.greyfish.impl.environment.AgentObjectPoolAT.java
private double measureAgentRecycling(final int objects, final Supplier<BasicAgent> agentSupplier) throws Exception { LoadingObjectPool<BasicAgent> objectPool = ConcurrentObjectPool.create(new Callable<BasicAgent>() { @Override// w ww. j av a 2 s . co m public BasicAgent call() throws Exception { return agentSupplier.get(); } }); final Stopwatch stopwatch = Stopwatch.createStarted(); for (int j = 0; j < objects; j++) { final BasicAgent clone = objectPool.borrow(); clone.initialize(); objectPool.release(clone); } return stopwatch.elapsed(TimeUnit.MICROSECONDS); }
From source file:com.ottogroup.bi.spqr.metrics.MetricsReporterFactory.java
/** * Attaches a {@link KafkaReporter} to provided {@link MetricsHandler} * @param metricsHandler//from w w w . j av a 2 s .c o m * @param id * @param period * @param zookeeperConnect * @param brokerList * @param clientId * @param topicId * @throws RequiredInputMissingException */ private static void attachKafkaReporter(final MetricsHandler metricsHandler, final String id, final int period, final String zookeeperConnect, final String brokerList, final String clientId, final String topicId) throws RequiredInputMissingException { ////////////////////////////////////////////////////////////////////////// // validate input if (StringUtils.isBlank(id)) throw new RequiredInputMissingException("Missing required metric reporter id"); if (metricsHandler == null) throw new RequiredInputMissingException("Missing required metrics handler"); if (StringUtils.isBlank(zookeeperConnect)) throw new RequiredInputMissingException("Missing required zookeeper connect"); if (StringUtils.isBlank(brokerList)) throw new RequiredInputMissingException("Missing required broker list"); if (StringUtils.isBlank(clientId)) throw new RequiredInputMissingException("Missing required client identifier"); if (StringUtils.isBlank(topicId)) throw new RequiredInputMissingException("Missing required topic identifier"); ////////////////////////////////////////////////////////////////////////// final KafkaReporter reporter = KafkaReporter.forRegistry(metricsHandler.getRegistry()) .brokerList("localhost:9092").clientId(clientId).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MICROSECONDS).topic(topicId).zookeeperConnect(zookeeperConnect) .build(); reporter.start((period > 0 ? period : 1), TimeUnit.SECONDS); metricsHandler.addScheduledReporter(id, reporter); }
From source file:org.asoem.greyfish.impl.environment.AgentObjectPoolAT.java
private double measureAgentCreation(final int objects, final Supplier<BasicAgent> agentSupplier) { final Stopwatch stopwatch = Stopwatch.createStarted(); for (int j = 0; j < objects; j++) { final BasicAgent clone = agentSupplier.get(); clone.initialize();//from w ww. j av a 2s. c om } return stopwatch.elapsed(TimeUnit.MICROSECONDS); }
From source file:io.horizondb.model.core.fields.TimestampField.java
/** * Returns the unit of time for the specified symbol. * //from w ww . java2s. c om * @param timeUnit the time unit * @return the unit of time for the specified symbol */ private TimeUnit getTimeUnit(String symbol) { switch (symbol) { case "": return this.sourceUnit; case "ns": return TimeUnit.NANOSECONDS; case "s": return TimeUnit.MICROSECONDS; case "ms": return TimeUnit.MILLISECONDS; case "s": return TimeUnit.SECONDS; default: throw new IllegalStateException("Unknown time unit: " + symbol); } }