Examples of TimeUnit


Examples of java.util.concurrent.TimeUnit

     * {@inheritDoc}
     */
    public void updated(Dictionary properties) throws ConfigurationException {
        boolean writeDisabled = DEFAULT_WRITE_DISABLED;
        int writeDelayValue = DEFAULT_WRITE_DELAY_VALUE;
        TimeUnit writeDelayUnit = DEFAULT_WRITE_DELAY_TIMEUNIT;

        if (properties != null) {
            Object wd = properties.get(KEY_WRITE_DISABLED);
            if (wd == null) {
                throw new ConfigurationException(KEY_WRITE_DISABLED, "Missing write disabled value!");
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    }

    @Test
    public void appliesDelay() throws InterruptedException {
        // given
        TimeUnit timeUnit = mock(TimeUnit.class);

        // when
        new HttpResponse().withDelay(new Delay(timeUnit, 10)).applyDelay();

        // then
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    }

    @Test(expected = RuntimeException.class)
    public void applyDelayHandlesException() throws InterruptedException {
        // given
        TimeUnit timeUnit = mock(TimeUnit.class);
        doThrow(new InterruptedException("TEST EXCEPTION")).when(timeUnit).sleep(10);

        // when
        new HttpResponse().withDelay(new Delay(timeUnit, 10)).applyDelay();
    }
View Full Code Here

Examples of java.util.concurrent.TimeUnit

            } else {
                throw new ServletException("Couldn't find a MetricRegistry instance.");
            }
        }

        final TimeUnit rateUnit = parseTimeUnit(context.getInitParameter(RATE_UNIT),
                                                TimeUnit.SECONDS);
        final TimeUnit durationUnit = parseTimeUnit(context.getInitParameter(DURATION_UNIT),
                                                    TimeUnit.SECONDS);
        final boolean showSamples = Boolean.parseBoolean(context.getInitParameter(SHOW_SAMPLES));
        MetricFilter filter = (MetricFilter) context.getAttribute(METRIC_FILTER);
        if (filter == null) {
          filter = MetricFilter.ALL;
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    protected void waitUntilCompleted() {
        while (!completed.get()) {
            try {
                if (duration > 0) {
                    TimeUnit unit = getTimeUnit();
                    LOG.info("Waiting for: " + duration + " " + unit);
                    latch.await(duration, unit);
                    completed.set(true);
                } else {
                    latch.await();
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    protected void waitUntilCompleted() {
        while (!completed.get()) {
            try {
                if (duration > 0) {
                    TimeUnit unit = getTimeUnit();
                    LOG.info("Waiting for: " + duration + " " + unit);
                    latch.await(duration, unit);
                    completed.set(true);
                } else {
                    latch.await();
View Full Code Here

Examples of java.util.concurrent.TimeUnit

   * Helper to create an invoker pool
   */
  protected static ExecutorService createInvokerPool(Args options) {
    int workerThreads = options.workerThreads;
    int stopTimeoutVal = options.stopTimeoutVal;
    TimeUnit stopTimeoutUnit = options.stopTimeoutUnit;

    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
    ExecutorService invoker = new ThreadPoolExecutor(workerThreads,
      workerThreads, stopTimeoutVal, stopTimeoutUnit, queue);

View Full Code Here

Examples of java.util.concurrent.TimeUnit

                throw new IllegalArgumentException
                    ("Duration argument has extra characters after unit: " +
                     property);
            }
            try {
                final TimeUnit unit = TimeUnit.valueOf(unitName);
                millis = TimeUnit.MILLISECONDS.convert(time, unit);
            } catch (IllegalArgumentException e) {
                try {
                    final IEEETimeUnit unit = IEEETimeUnit.valueOf(unitName);
                    millis = unit.toMillis(time);
                } catch (IllegalArgumentException e2) {
                    throw new IllegalArgumentException
                        ("Duration argument has unknown unit name: " +
                         property);
                }
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    public void scheduleCallable() {
        @SuppressWarnings("unchecked")
        ScheduledFuture<Object> expected = mock(ScheduledFuture.class);
        Task task = new Task();
        long delay = 10L;
        TimeUnit unit = TimeUnit.SECONDS;

        when(this.executor.schedule(task, delay, unit)).thenReturn(expected);

        ScheduledFuture<Object> result = this.subject.schedule(task, delay, unit);
View Full Code Here

Examples of java.util.concurrent.TimeUnit

        @SuppressWarnings("rawtypes")
        ScheduledFuture expected = mock(ScheduledFuture.class);
        Runnable task = mock(Runnable.class);
        long delay = 10L;
        long period = 20L;
        TimeUnit unit = TimeUnit.SECONDS;

        when(this.executor.scheduleAtFixedRate(task, delay, period, unit)).thenReturn(expected);

        ScheduledFuture<?> result = this.subject.scheduleAtFixedRate(task, delay, period, unit);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.