Example usage for java.util.concurrent TimeoutException getMessage

List of usage examples for java.util.concurrent TimeoutException getMessage

Introduction

In this page you can find the example usage for java.util.concurrent TimeoutException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:cc.gospy.core.util.StringHelper.java

public static String getMyExternalIp() {
    if (myExternalIp == null) {
        try {/*from w w w  .j  ava2 s. c  o  m*/
            logger.info("Querying external ip...");
            FutureTask futureTask = new FutureTask<>(() -> {
                URL ipEcho = new URL("http://ipecho.net/plain");
                BufferedReader in = new BufferedReader(new InputStreamReader(ipEcho.openStream()));
                String resultIp = in.readLine();
                in.close();
                return resultIp;
            });
            futureTask.run();
            myExternalIp = (String) futureTask.get(3, TimeUnit.SECONDS);
            logger.info("My external ip: {}", myExternalIp);
        } catch (TimeoutException e) {
            myExternalIp = "unknown ip";
            logger.error("Get external ip failure, cause: Timeout (3 seconds)");
        } catch (Exception e) {
            myExternalIp = "unknown ip";
            logger.error("Get external ip failure, cause: {}", e.getMessage());
        }
    }
    return myExternalIp;
}

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;//  w  w  w  .j  a va 2 s  .  c  o  m

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        throw new SVGConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:Highcharts.SVGConverter.java

public String requestServer(String params)
            throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
        Server server = null;/*from  ww w.  j  a v a2  s . com*/

        try {
            server = (Server) serverPool.borrowObject();
            String response = server.request(params);

            return response;
        } catch (SocketTimeoutException ste) {
            throw new TimeoutException(ste.getMessage());
        } catch (TimeoutException te) {
            throw new TimeoutException(te.getMessage());
        } catch (PoolException nse) {
            logger.error("POOL EXHAUSTED!!");
            throw new PoolException(nse.getMessage());
        } catch (Exception e) {
            logger.debug(e.getMessage());
            throw new SVGConverterException("Error converting SVG" + e.getMessage());
        } finally {
            try {
                serverPool.returnObject(server, true);
            } catch (Exception e) {
                logger.error("Exception while returning server to pool: " + e.getMessage());
            }
        }
    }

From source file:iddb.runtime.cache.impl.CacheImpl.java

@Override
public Object get(String key) {
    synchronized (key) {
        Object obj = null;//from  w w w.j  ava 2  s  . c  o m
        Future<Object> asGet = client.asyncGet(getNamespace() + "-" + key);
        try {
            obj = asGet.get(10, TimeUnit.SECONDS);
        } catch (TimeoutException e) {
            asGet.cancel(false);
            log.error(e.getMessage());
        } catch (InterruptedException e) {
            log.error(e.getMessage());
        } catch (ExecutionException e) {
            log.error(e.getMessage());
        }
        return obj;
    }
}

From source file:com.sophia.charts.export.converter.ChartConverter.java

public String requestServer(String params)
        throws ChartConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;// w w  w  .  j  a v a  2s .  c o m

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        throw new ChartConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;/* www  .  j  a va 2s. c o m*/

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        logger.error(ste);
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        logger.error(te);
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.error(e);
        throw new SVGConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;//from   w  w w  .j a  v  a2  s . c o  m

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        logger.error(ste);
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        logger.error(te);
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.error(e);
        throw new SVGConverterException("Error converting SVG: " + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:com.verigreen.common.command.TEQCommandExecuter.java

private <TCommandParameters extends TEQCommandParameters> void getResults(
        List<CommandPack<TCommandParameters>> commandPacks, List<Future<Void>> futures)
        throws InterruptedException {

    for (int i = 0; i < futures.size(); ++i) {
        // futures and commandpacks have the same order - invokeAll guarantees that
        try {//from   w  w  w.  j  a v  a  2 s.  c o m
            futures.get(i).get(0, TimeUnit.MILLISECONDS);
        } catch (TimeoutException e) {
            commandPacks.get(i).setError(CommandResult.TIMEOUT);
        } catch (ExecutionException e) {
            commandPacks.get(i).setError(e.getMessage());
        }
    }
}

From source file:com.clustercontrol.util.CommandExecutor.java

public CommandResult getResult() {
    CommandExecuteTask task = new CommandExecuteTask(process, _charset, _timeout, _bufferSize);
    Future<CommandResult> future = _commandExecutor.submit(task);
    log.debug("executing command. (command = " + _commandLine + ", timeout = " + _timeout + " [msec])");

    // receive result
    CommandResult ret = null;//from  w ww  .  j  a va  2s .  c om
    try {
        if (_timeout == _disableTimeout) {
            ret = future.get();
        } else {
            ret = future.get(_timeout, TimeUnit.MILLISECONDS);
        }

        log.debug("exit code : " + (ret != null ? ret.exitCode : null));
        log.debug("stdout : " + (ret != null ? ret.stdout : null));
        log.debug("stderr : " + (ret != null ? ret.stderr : null));
        log.debug("buffer discarded : " + (ret != null ? ret.bufferDiscarded : null));
    } catch (TimeoutException e) {
        log.info("command execution failure. (command = " + _commandLine + ") " + e.getMessage());
    } catch (Exception e) {
        log.warn("command execution failure. (command = " + _commandLine + ") " + e.getMessage(), e);
    } finally {
        // release thread pool
        log.debug("releasing command threads.");
        _commandExecutor.shutdownNow();
    }

    return ret;
}