Example usage for java.util.concurrent ExecutionException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:rapture.server.web.servlet.JmxServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String path = req.getPathInfo();
    if (StringUtils.isNotBlank(path)) {
        path = stripLeadingSlash(path);//from   ww w.  j av a 2s . c o  m
        int index = path.indexOf('/');
        if (index == -1) {
            error(res, "Invalid URL path provided");
            return;
        }
        String appName = path.substring(0, index);
        path = path.substring(index);
        JmxApp app;
        try {
            app = JmxAppCache.getInstance().get().get(appName);
        } catch (ExecutionException e) {
            error(res, e.getMessage());
            return;
        }
        if (app == null) {
            error(res, String.format("App [%s] not found", appName));
            return;
        }
        try (InputStream input = new URL(app.getUrl() + path).openStream();
                OutputStream output = res.getOutputStream();) {
            IOUtils.copy(input, output);
        }
    } else {
        error(res, path + " is unavailable");
    }
}

From source file:org.ygl.plexc.PlexcEngine.java

/**
 * execute a remote query to another user's policy.
 * @param remoteUser/* ww  w.j a  v  a 2 s  .c o m*/
 * @param predicate
 * @return
 * @throws Exception
 */
boolean remoteQuery(String remoteUser, Struct predicate) {
    LOG.debug("remoteQuery: " + remoteUser + " " + predicate);
    Preconditions.checkNotNull(remoteUser);
    Preconditions.checkNotNull(predicate);
    PlexcPolicy policy = null;
    try {
        policy = policyCache.get(remoteUser);
    } catch (ExecutionException e) {
        LOG.warn(e.getMessage());
    }
    try {
        return policy.query(predicate).isSuccess();
    } catch (NoSolutionException e) {
        return false;
    }
}

From source file:monasca.common.middleware.TokenCache.java

public String getToken(String key) throws ClientProtocolException {
    String value = null;/* w w w .j  a  v a  2s.  com*/
    try {
        value = cache.get(key);
    } catch (ExecutionException e) {
        logger.info("Failed to get token", e);
        throw new ClientProtocolException(e.getMessage(), e);
    }
    return value;
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.AbstractPhoneNumberRestSuggestBox.java

@Override
public void formatValue(final ValueWithPos<String> pvalue) {
    if (pvalue == null || StringUtils.isEmpty(pvalue.getValue())) {
        this.setValue(StringUtils.EMPTY);
    } else {/*from  www  .j  av a2 s .  co m*/
        final ValueWithPosAndCountry<String> unformatedEntry = new ValueWithPosAndCountry<String>(
                pvalue.getValue(), pvalue.getPos(), Objects.toString(this.countryCodeField.getValue()),
                LocaleInfo.getCurrentLocale().getLocaleName());
        try {
            final FutureResult<ValueWithPos<String>> result = this.cache.get(unformatedEntry);
            if (result.isDone()) {
                this.setTextWithPos(result.get());
            }
        } catch (final ExecutionException e) {
            GWT.log(e.getMessage(), e);
        }
    }
}

From source file:com.ironiacorp.http.impl.httpclient3.HttpJobRunnerHttpClient3.java

public void run() {
    ExecutorService executor = Executors.newFixedThreadPool(maxThreadsCount);
    ExecutorCompletionService<HttpJob> queue = new ExecutorCompletionService<HttpJob>(executor);
    List<Future<?>> workers = new ArrayList<Future<?>>();

    for (HttpJob job : jobs) {
        if (HttpMethod.GET == job.getMethod()) {
            GetRequest request = new GetRequest(httpClient, job);
            Future<HttpJob> jobStatus = queue.submit(request);
            workers.add(jobStatus);//from  ww  w .ja v  a2  s.c  o m
            continue;
        }
        if (HttpMethod.POST == job.getMethod()) {
            PostRequest request = new PostRequest(httpClient, job);
            Future<HttpJob> jobStatus = queue.submit(request);
            workers.add(jobStatus);
            continue;
        }
        // TODO: job cannot be handled, what to do?
    }

    while (!workers.isEmpty()) {
        Iterator<Future<?>> i = workers.iterator();
        while (i.hasNext()) {
            try {
                Future<?> future = i.next();
                // future.get(timeout, TimeUnit.MILLISECONDS);
                future.get();
                i.remove();
                // } catch (TimeoutException e) {
            } catch (InterruptedException ie) {
                System.out.println(ie.getMessage());
            } catch (ExecutionException ee) {
                System.out.println(ee.getMessage());
                i.remove();
            }
        }
    }

    executor.shutdown();
}

From source file:org.cloudgraph.hbase.connect.Connection.java

public Table getTable(TableName tableName) throws IOException {
    Table result = null;/*from  ww w.jav  a 2 s . c  o  m*/
    try {
        result = this.tableCache.get(tableName);
    } catch (ExecutionException e) {
        log.error(e.getMessage(), e);
    }
    return result;
}

From source file:org.cloudgraph.hbase.connect.Connection.java

public Table getTable(TableName tableName, ExecutorService pool) throws IOException {
    Table result = null;/*from   w  w  w .  j  ava  2  s .  co m*/
    try {
        result = this.tableCache.get(tableName);
    } catch (ExecutionException e) {
        log.error(e.getMessage(), e);
    }
    return result;
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.AbstractPhoneNumberRestSuggestBox.java

/**
 * default constructor./*w  ww  . j  a  v a  2s .  co  m*/
 */
public AbstractPhoneNumberRestSuggestBox(final SuggestOracle poracle) {
    super(poracle);
    this.callback = new AsyncCallback<ValueWithPos<String>>() {

        @Override
        public void onFailure(final Throwable pcaught) {
            GWT.log(pcaught.getMessage(), pcaught);
        }

        @Override
        public void onSuccess(final ValueWithPos<String> presponse) {
            if (presponse != null && StringUtils.isNotEmpty(presponse.getValue())) {
                AbstractPhoneNumberRestSuggestBox.this.setTextWithPos(presponse);
            }
        }

    };
    this.cache = CacheBuilder.newBuilder().maximumSize(10000).expireAfterWrite(10, TimeUnit.DAYS)
            .build(new CacheLoader<ValueWithPosAndCountry<String>, FutureResult<ValueWithPos<String>>>() {

                @Override
                public FutureResult<ValueWithPos<String>> load(final ValueWithPosAndCountry<String> pkey) {
                    final FutureResult<ValueWithPos<String>> result = new FutureResult<>();
                    result.addCallback(AbstractPhoneNumberRestSuggestBox.this.callback);
                    try {
                        AbstractPhoneNumberRestSuggestBox.this.formatValue(pkey, result);
                    } catch (final ExecutionException e) {
                        GWT.log(e.getMessage(), e);
                    }
                    return result;
                }
            });
}

From source file:org.cloudgraph.hbase.connect.Connection.java

public boolean tableExists(TableName tableName) throws IOException {
    boolean exists = false;
    Table table = this.tableCache.getIfPresent(tableName);
    if (table != null) {
        exists = true;/*from   ww  w . j  a  v  a2 s .  c o m*/
    } else {
        exists = getAdmin().tableExists(tableName);
        if (exists) {
            try {
                this.tableCache.get(tableName);
            } catch (ExecutionException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return exists;
}

From source file:org.apache.storm.kafka.trident.TridentKafkaState.java

public void updateState(List<TridentTuple> tuples, TridentCollector collector) {
    String topic = null;// www . ja v  a2  s.co m
    try {
        List<Future<RecordMetadata>> futures = new ArrayList<>(tuples.size());
        for (TridentTuple tuple : tuples) {
            topic = topicSelector.getTopic(tuple);

            if (topic != null) {
                Future<RecordMetadata> result = producer.send(new ProducerRecord(topic,
                        mapper.getKeyFromTuple(tuple), mapper.getMessageFromTuple(tuple)));
                futures.add(result);
            } else {
                LOG.warn("skipping key = " + mapper.getKeyFromTuple(tuple) + ", topic selector returned null.");
            }
        }

        List<ExecutionException> exceptions = new ArrayList<>(futures.size());
        for (Future<RecordMetadata> future : futures) {
            try {
                future.get();
            } catch (ExecutionException e) {
                exceptions.add(e);
            }
        }

        if (exceptions.size() > 0) {
            String errorMsg = "Could not retrieve result for messages " + tuples + " from topic = " + topic
                    + " because of the following exceptions: \n";
            for (ExecutionException exception : exceptions) {
                errorMsg = errorMsg + exception.getMessage() + "\n";
            }
            LOG.error(errorMsg);
            throw new FailedException(errorMsg);
        }
    } catch (Exception ex) {
        String errorMsg = "Could not send messages " + tuples + " to topic = " + topic;
        LOG.warn(errorMsg, ex);
        throw new FailedException(errorMsg, ex);
    }
}