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:apiserver.services.pdf.service.AddFooterToPdfCFService.java

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

    try {// w w w . j  a v  a2  s. c  om
        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 AddFooterCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.AddHeaderToPdfCFService.java

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

    try {//from w  w  w.  ja va 2  s . 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 AddFooterCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.MergePdfFilesCFService.java

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

    try {/* w  w  w . jav  a  2 s . c  om*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

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

        Future<CollectionResult> future = exec
                .submit(new MergePdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getCollection());

        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:apiserver.services.pdf.service.TransformPdfCFService.java

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

    try {/*  w  w  w  .j  a  v  a  2s .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 TransformPdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.AddPdfWatermarkCFService.java

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

    try {// w  w  w . j a  v a  2s. 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 AddWatermarkCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.DeletePdfPagesCFService.java

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

    try {//from   ww  w.j ava 2 s  .  co 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 DeletePagesCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.ExtractPdfImagesCFService.java

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

    try {/*  w ww.j  a  v a 2 s .  co m*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

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

        Future<CollectionResult> future = exec
                .submit(new ExtractImageCallable(props.getFile().getFileBytes(), props.getOptions()));

        CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getCollection());

        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:apiserver.services.pdf.service.HtmlToPdfCFService.java

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

    try {/*from  ww w . j a v a2s .  c om*/
        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 HtmlToPdfCallable(props.getHtml(),
                props.getHeaderHtml(), props.getFooterHtml(), props.getOptions()));

        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:com.sios.stc.coseng.test.Base.java

@BeforeSuite(alwaysRun = true, description = "Get Selenium browser driver, start services")
public void onStart() throws MalformedURLException, IOException {
    final Run rp = Common.sharedRunParam;
    testName = rp.getThreadTestName(Thread.currentThread().getId());
    baseUrl = rp.getBaseUrl(testName);//from  ww  w .ja v  a  2  s.  co  m
    spot = rp.getSpot(testName);
    platform = rp.getPlatform(testName);
    browser = rp.getBrowser(testName);
    testReportDirectoryPath = rp.getTestReportDirectoryPath(testName);
    driver = rp.getWebDriver(testName);
    // *may* start a service depending on spot and driver
    // only started *once* per driver type
    // stopped at conclusion of all test runners.
    rp.startService(spot, driver);
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}