Example usage for java.util.concurrent TimeUnit SECONDS

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

Introduction

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

Prototype

TimeUnit SECONDS

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

Click Source Link

Document

Time unit representing one second.

Usage

From source file:com.boundary.sdk.event.snmp.SNMPSpringTest.java

@Ignore("Need Mock SSH Server")
@Test/*  w  ww  .ja  v  a2  s. c  o m*/
public void testSnmpGet() throws InterruptedException {
    out.setMinimumExpectedMessageCount(1);
    out.await(10, TimeUnit.SECONDS);
    out.assertIsSatisfied();

    CamelContext context = context();

    List<Exchange> exchanges = out.getExchanges();
    for (Exchange exchange : exchanges) {
        Message message = exchange.getOut();
        SnmpMessage snmpMessage = message.getBody(SnmpMessage.class);
        LOG.info("body: ", snmpMessage);
        assertNotNull("Body is null", snmpMessage);
        PDU pdu = snmpMessage.getSnmpMessage();
        for (Object o : pdu.getVariableBindings()) {
            VariableBinding b = (VariableBinding) o;
            LOG.info("oid: {}, value: {}", b.getOid().toString(), b.getVariable().toString());
        }
    }
}

From source file:com.synapticpath.naica.selenium.SeleniumUtils.java

/**
 * Call this method to find a WebElement. Several parameters are supported.
 * //from w ww  .  j  ava2s .c  om
 * @param elementSelector
 *            Will be used as primary criteria to find an element.
 * @param visible
 *            When not null, will be evaluated for visibility on page. That is, the desired element must
 *            also be visible when true, or invisible when false.
 * @param withText
 *            if specified, the element.getText must match also.
 * @param timeout
 *            positive number of seconds to wait
 * @return the {@link WebElement} when found, null if not found in timeout reached first.
 */
public static WebElement findElementWithTimeout(final SeleniumSelector elementSelector, final Boolean visible,
        final String withText, int timeout) {

    final WebDriver driver = SeleniumTestContext.getInstance().getDriver();

    FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver)
            .withTimeout(timeout > -1 ? timeout : MAX_WAIT, TimeUnit.SECONDS)
            .pollingEvery(POLL_INTERVAL_MILLIS, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class)
            .ignoring(TimeoutException.class);

    try {
        return wait.until((WebDriver d) -> {
            WebElement e = d.findElement(elementSelector.toBySelector());
            if (e != null && (withText == null || e.getText().contains(withText))
                    && (visible == null || visible && e.isDisplayed() || !visible && !e.isDisplayed())) {
                return e;
            }
            return null;
        });
    } catch (TimeoutException te) {
        logger.severe(format("Element selected by %s, visible:%s, withText:%s was not found in time.",
                elementSelector, visible, withText));
    }

    return null;

}

From source file:dk.dma.navnet.server.AbstractServerConnectionTest.java

@After
public void after() throws Exception {
    server.shutdown();//from w w w.  j a  v  a 2  s . com
    assertTrue(server.awaitTerminated(5, TimeUnit.SECONDS));
    for (TesstEndpoint te : allClient) {
        te.close();
    }
}

From source file:org.fcrepo.auth.roles.common.AbstractRolesIT.java

public AbstractRolesIT() {
    connectionManager.setMaxTotal(Integer.MAX_VALUE);
    connectionManager.setDefaultMaxPerRoute(5);
    connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
    client = new DefaultHttpClient(connectionManager);
}

From source file:apiserver.services.pdf.service.ProcessPdfDDXCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    DDXPdfResult props = (DDXPdfResult) message.getPayload();

    try {/*from ww w  .j  a v  a2s  .  c o m*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new ProcessDDXCallable(props.getFile().getFileBytes(), props.getDdx()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:org.ng200.openolympus.services.TaskContainerCache.java

@Autowired
public TaskContainerCache(final StorageService storageService) {
    this.taskContainers = new ConcurrentHashMap<>();
    this.storageService = storageService;
    this.executorService.scheduleAtFixedRate(() -> {
        this.taskContainers.forEach((id, taskContainer) -> taskContainer.collectGarbage(this.solutionService));
    }, 10, 10, TimeUnit.SECONDS);
}

From source file:org.esigate.extension.monitoring.Metric.java

@Override
public void init(Driver d, Properties properties) {
    this.driver = d;
    LOG.debug("Initialize Metric");
    driver.getEventManager().register(EventManager.EVENT_PROXY_POST, this);
    driver.getEventManager().register(EventManager.EVENT_FETCH_POST, this);

    reporter = Slf4jReporter.forRegistry(this.metric).outputTo(LOG).convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).build();

    reporter.start(PARAM_METRIC_PERIOD.getValue(properties), TimeUnit.SECONDS);
}

From source file:io.watchcat.node.monitoring.threshold.ThresholdPoller.java

@PostConstruct
public void postConstruct() {
    thresholdInitializer.initializeThresholds();
    scheduledExecutorService.scheduleAtFixedRate(this, 5, 10, TimeUnit.SECONDS);
}

From source file:aos.camel.MyComponent.java

@Override
protected void doStart() throws Exception {
    super.doStart();
    // create a scheduled thread pool with 1 thread as we only need one task as background task
    executor = getCamelContext().getExecutorServiceStrategy().newScheduledThreadPool(this, "MyBackgroundTask",
            1);/* ww  w  . j  a  v  a  2s  .c  om*/
    // schedule the task to run once every second
    executor.scheduleWithFixedDelay(this, 1, 1, TimeUnit.SECONDS);
}

From source file:org.addhen.birudo.data.net.BaseHttpClient.java

public BaseHttpClient(String url) {

    this.url = url;
    this.params = new ArrayList<>();
    this.header = new HashMap<>();

    httpClient = new OkHttpClient();
    httpClient.setConnectTimeout(TIME_OUT_CONNECTION, TimeUnit.SECONDS);
    httpClient.setWriteTimeout(TIME_OUT_CONNECTION, TimeUnit.SECONDS);
    httpClient.setReadTimeout(TIME_OUT_CONNECTION, TimeUnit.SECONDS);
}