Example usage for java.util.concurrent TimeUnit MILLISECONDS

List of usage examples for java.util.concurrent TimeUnit MILLISECONDS

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MILLISECONDS.

Prototype

TimeUnit MILLISECONDS

To view the source code for java.util.concurrent TimeUnit MILLISECONDS.

Click Source Link

Document

Time unit representing one thousandth of a second.

Usage

From source file:com.joyent.manta.client.MetricReporterSupplier.java

private static Slf4jReporter buildSlf4jReporter(final MantaClientMetricConfiguration metricConfig) {
    return Slf4jReporter.forRegistry(metricConfig.getRegistry()).convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).prefixedWith(metricConfig.getClientId().toString())
            .outputTo(LoggerFactory.getLogger(FMT_METRIC_LOGGER_NAME))
            // .shutdownExecutorOnStop()
            // .markWith()
            // .withLoggingLevel()
            .build();// w w  w .  j  a v a2  s . c o  m
}

From source file:com.dron.SenderState.java

public void run() {
    while (running) {
        try {//from  w  ww.  j a va2s.  com
            TimeUnit.MILLISECONDS.sleep(timeDelay);
        } catch (InterruptedException ex) {
        }
        sendState();
    }
}

From source file:net.myrrix.common.math.SolverLoadTest.java

@Test
public void testLoad() {
    RealMatrix symmetric = randomSymmetricMatrix(500);
    Stopwatch stopwatch = new Stopwatch().start();
    int iterations = 100;
    for (int i = 0; i < iterations; i++) {
        MatrixUtils.getSolver(symmetric);
    }/*from w  ww  .j  av a2 s  .  c om*/
    stopwatch.stop();
    long elapsedMS = stopwatch.elapsed(TimeUnit.MILLISECONDS);
    log.info("{}ms elapsed", elapsedMS);
    assertTrue(elapsedMS < 300 * iterations);
}

From source file:org.sbq.batch.mains.ActivityEmulator.java

private ActivityEmulator() {
    super();// w  ww .  jav a  2s .c  o  m
    blockingQueue = new LinkedBlockingQueue<Runnable>();
    executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, blockingQueue);
    appCtx = new AnnotationConfigApplicationContext(ActivityEmulatorConfiguration.class);
    userService = appCtx.getBean(UserService.class);
    Map<String, AtomicBoolean> writableUserStatusByLogin = new HashMap<String, AtomicBoolean>();
    for (User user : userService.findAllUsers()) {
        writableUserStatusByLogin.put(user.getLogin(), new AtomicBoolean(false));
    }
    userStatusByLogin = Collections.unmodifiableMap(writableUserStatusByLogin);
}

From source file:com.heliosapm.opentsdb.server.MemoryReporter.java

/**
 * Creates a new MemoryReporter/*from w  ww  . j  a  va 2 s .  c  o  m*/
 * @param frequency The frequency in seconds of the memory reporting
 */
public MemoryReporter(int frequency) {
    super("MemoryReporter-" + frequency);
    setDaemon(true);
    sleepTime = TimeUnit.MILLISECONDS.convert(frequency, TimeUnit.SECONDS);
}

From source file:ch.ivyteam.ivy.maven.TestIarDeployMojo.java

@Test
public void deployPackedIar() throws Exception {
    IarDeployMojo mojo = rule.getMojo();

    File deployedIar = getTarget(mojo.deployIarFile, mojo);
    File deployMarkerFile = new DeploymentMarkerFiles(deployedIar).doDeploy();
    assertThat(deployedIar).doesNotExist();
    assertThat(deployMarkerFile).doesNotExist();

    DelayedOperation mockEngineDeployThread = new DelayedOperation(500, TimeUnit.MILLISECONDS);
    Callable<Void> engineOperation = () -> {
        assertThat(deployMarkerFile).as("deployment must be initialized").exists();
        deployMarkerFile.delete(); //deployment finished
        return null;
    };//  www.  j a va2 s.c om
    mockEngineDeployThread.execute(engineOperation);
    mojo.execute();
    mockEngineDeployThread.failOnExecption();

    assertThat(deployedIar).as("IAR must exist in engine deploy directory").exists();
}

From source file:io.mandrel.frontier.Revisitor.java

@Override
public void run() {

    while (true) {

        if (!run.get()) {
            log.trace("Waiting...");
            try {
                TimeUnit.MILLISECONDS.sleep(2000);
            } catch (InterruptedException e) {
                // Don't care
                log.trace("", e);
            }//  w ww  . j  a v a 2s.co m
            continue;
        }

        metadatastore.byPages(1000, entries -> {
            try {
                if (entries != null) {
                    entries.forEach(entry -> {
                        if (frontier.revisit().isScheduledForRevisit(entry)) {
                            frontier.schedule(entry.getUri());
                        }
                    });
                }
            } catch (Exception e) {
                log.debug("Uhhh...", e);
                return false;
            }
            return CollectionUtils.isNotEmpty(entries);
        });
    }
}

From source file:com.microsoft.office.core.EventsAsyncTestCase.java

@BeforeClass
public static void retrieveCalendar() throws Exception {
    final ICalendars cals = Me.getCalendars();
    final CountDownLatch cdl = new CountDownLatch(1);
    // an empty iterator will be returned for any entity set unless you call fetch()
    Futures.addCallback(cals.fetchAsync(), new FutureCallback<Void>() {
        @Override/*w  ww.j  a  v  a2  s  .  c  o  m*/
        public void onFailure(Throwable t) {
            cdl.countDown();
        }

        @Override
        public void onSuccess(Void result) {
            Iterator<ICalendar> iterator = cals.iterator();
            if (iterator.hasNext()) {
                calendar = iterator.next();
            }
            cdl.countDown();
        }
    });

    cdl.await(60000, TimeUnit.MILLISECONDS);
    if (calendar == null) {
        fail("No calendar found");
    }
}

From source file:com.arpnetworking.metrics.generator.metric.UniformMetricGenerator.java

/**
 * {@inheritDoc}/*from   ww  w. j  av  a  2 s. c o m*/
 */
@Override
public void generate(final Metrics metrics) {
    metrics.setTimer(_nameGenerator.getName(), Math.round(_generator.nextUniform(_min, _max, true)),
            TimeUnit.MILLISECONDS);
}

From source file:com.sangupta.dryrun.redis.OpsForValue.java

@Override
public void set(K key, V value, long timeout, TimeUnit unit) {
    if (TimeUnit.MILLISECONDS.equals(unit)) {
        int millis = ((Long) timeout).intValue();
        this.bridge.psetex(rawKey(key), millis, rawValue(value));
        return;//  w  ww .ja  va 2 s.c o  m
    }

    Long seconds = unit.toSeconds(timeout);
    this.bridge.setex(rawKey(key), seconds.intValue(), rawValue(value));
}