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:com.flipkart.poseidon.serviceclients.FutureTaskResultToDomainObjectPromiseWrapper.java

@Override
public void await() throws InterruptedException {
    try {// w  w w.  j a  v a  2  s .c o m
        for (Future<TaskResult> future : futureList) {
            future.get();
        }
    } catch (ExecutionException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new InterruptedException(exception.getMessage());
    } catch (CancellationException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
    }

}

From source file:com.flipkart.poseidon.serviceclients.FutureTaskResultToDomainObjectPromiseWrapper.java

@Override
public void await(long timeout, TimeUnit timeUnit) throws InterruptedException {
    try {/*ww w .  j av a  2  s . co m*/
        for (Future<TaskResult> future : futureList) {
            future.get(timeout, timeUnit);
        }
    } catch (ExecutionException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new InterruptedException(exception.getMessage());
    } catch (CancellationException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
    } catch (TimeoutException ignored) {
    }
}

From source file:com.quancheng.saluki.registry.consul.ConsulRegistry.java

@Override
public List<GrpcURL> discover(GrpcURL url) {
    String group = url.getGroup();
    try {//from   w ww.  j  a  va  2 s.  c om
        Map<String, List<GrpcURL>> providerUrls = serviceCache.get(group,
                new Callable<Map<String, List<GrpcURL>>>() {

                    @Override
                    public Map<String, List<GrpcURL>> call() throws Exception {
                        return lookupServiceUpdate(group);
                    }
                });
        return providerUrls.get(url.getServiceKey());
    } catch (ExecutionException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.oneops.antenna.ws.AntennaWsController.java

/**
 * Get the cache entry for specific nsPath. If the API returns an entry
 * doesn't mean that entry was existing in the Cache because the cache loader
 * would fetch and load a non existing entry on demand upon expiry.
 *
 * @param nsPath message nspath/*www .j a va2s.c  o m*/
 * @return cache entry map.
 */
@RequestMapping(value = "/cache/entry", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Map<String, Object>> getCacheEntry(
        @RequestParam(value = "nsPath", required = true) String nsPath) {
    Map<String, Object> stat = new LinkedHashMap<String, Object>(2);
    List<BasicSubscriber> entry;
    try {
        entry = cache.instance().get(new SinkKey(nsPath));
    } catch (ExecutionException e) {
        stat.put("status", e.getMessage());
        return new ResponseEntity<Map<String, Object>>(stat, HttpStatus.NOT_FOUND);
    }
    stat.put("status", "ok");
    stat.put("entry", entry.toString());
    return new ResponseEntity<Map<String, Object>>(stat, HttpStatus.OK);
}

From source file:ezbake.security.service.sync.EncryptedRedisCache.java

private SecretKey getEncryptionKey() throws KeyNotFoundException {
    try {//w  w  w.jav  a  2s.co  m
        return locksmithKeySupplier.get(0);
    } catch (ExecutionException e) {
        logger.warn("Failed getting encryption key from locksmith: {}", e.getMessage());
        throw new KeyNotFoundException("Failed getting encryption key from locksmith: " + e.getMessage());
    }
}

From source file:org.rhq.plugins.agent.AgentServerComponent.java

public OperationResult invokeOperation(String name, Configuration params) {
    OperationResult result = null;/*from   ww  w.j  a  va 2  s. c  o m*/

    // I know all operation names have identical MBean operations on the agent management MBean
    // I also know about all operations that have void and non-void parameters
    try {
        if ((params == null) || (params.getProperties().size() == 0)) {
            result = (OperationResult) getAgentBean().getOperation(name).invoke();
        } else {
            if (name.equals("retrievePluginInfo")) {
                String pluginToUpdate = params.getSimple("pluginName").getStringValue();
                result = (OperationResult) getAgentBean().getOperation(name).invoke(pluginToUpdate);
            } else if (name.equals("executeAvailabilityScan")) {
                Boolean changesOnly = params.getSimple("changesOnly").getBooleanValue();
                result = (OperationResult) getAgentBean().getOperation(name).invoke(changesOnly);
            } else if (name.equals("retrieveCurrentDateTime")) {
                String timeZone = params.getSimple("timeZone").getStringValue();
                result = new OperationResult();
                result.getComplexResults().put(
                        new PropertySimple("dateTime", getAgentBean().getOperation(name).invoke(timeZone)));
            } else if (name.equals("setDebugMode")) {
                Boolean enabled = params.getSimple("enabled").getBooleanValue();
                Boolean traceMessaging = params.getSimple("traceMessaging").getBooleanValue();
                result = new OperationResult();
                getAgentBean().getOperation(name).invoke(enabled, traceMessaging);
            } else if (name.equals("executePromptCommand")) {
                String command = params.getSimple("command").getStringValue();
                result = new OperationResult();
                try {
                    Object output = getAgentBean().getOperation(name).invoke(command);
                    result.getComplexResults().put(new PropertySimple("output", output));
                } catch (EmsInvocationException eie) {
                    if (eie.getCause() instanceof MBeanException
                            && eie.getCause().getCause() instanceof ExecutionException) {
                        // the prompt command threw the exception - in this case:
                        // the message is the prompt output and the cause is the actual prompt exception
                        ExecutionException ee = (ExecutionException) eie.getCause().getCause();
                        String output = ee.getMessage();
                        CharArrayWriter caw = new CharArrayWriter();
                        ee.getCause().printStackTrace(new PrintWriter(caw));
                        String error = caw.toString();
                        result.getComplexResults().put(new PropertySimple("output", output));
                        result.getComplexResults().put(new PropertySimple("error", error));
                    } else {
                        throw eie;
                    }
                }
            } else if (name.equals("switchToServer")) {
                String server = params.getSimpleValue("server", null);
                getAgentBean().getOperation(name).invoke(server);
            } else {
                // this should really never happen
                throw new IllegalArgumentException("Operation [" + name + "] does not support params");
            }
        }
    } catch (Exception e) {
        throw new RuntimeException("Failed to invoke operation [" + name + "]", e);
    }
    return result;
}

From source file:com.flipkart.poseidon.serviceclients.FutureTaskResultToDomainObjectPromiseWrapper.java

public Map<String, String> getHeaders() throws PromiseBrokenException, InterruptedException {
    try {/*from w w w .jav  a2s .  c o m*/
        TaskResult taskResult;
        taskResult = futureList.get(0).get();
        if (taskResult == null) {
            throw new PromiseBrokenException("Task result is null");
        }

        ServiceResponse<DomainObject> response = (ServiceResponse<DomainObject>) taskResult.getData();
        return response.getHeaders();
    } catch (ExecutionException exception) {
        checkAndThrowServiceClientException(exception);
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new InterruptedException(exception.getMessage());
    } catch (CancellationException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new PromiseBrokenException(promiseBrokenException);
    }
}

From source file:gridool.mapred.dht.task.DhtMapShuffleTask.java

private void invokeShuffle(final ArrayQueue<byte[]> queue) {
    assert (kernel != null);

    final ArrayQueue<byte[]> records = hasCombiner() ? combine(queue) : queue;

    if (collectOutputKeys()) {
        shuffleAndCollectKeys(records);//from   w  w  w. j  a v a2  s . c om
        return;
    }

    final AddOperation ops = new AddOperation(destTableName);
    ops.setMaxNumReplicas(0);
    final int size = records.size();
    for (int i = 0; i < size; i += 2) {
        byte[] k = records.get(i);
        byte[] v = records.get(i + 1);
        ops.addMapping(k, v);
    }

    shuffleExecPool.execute(new Runnable() {
        public void run() {
            final GridJobFuture<Serializable> future = kernel.execute(DirectoryAddJob.class, ops);
            try {
                future.get(); // wait for execution
            } catch (InterruptedException ie) {
                LOG.error(ie.getMessage(), ie);
            } catch (ExecutionException ee) {
                LOG.error(ee.getMessage(), ee);
            }
        }
    });
}

From source file:com.flipkart.poseidon.serviceclients.FutureTaskResultToDomainObjectPromiseWrapper.java

@Override
public DomainObject get() throws PromiseBrokenException, InterruptedException {
    try {//from   ww  w.jav  a2 s .  co  m
        ServiceResponse<DomainObject> serviceResponse = new ServiceResponse<>();
        for (Future<TaskResult> futureResult : futureList) {
            TaskResult result = futureResult.get();
            if (result == null) {
                throw new PromiseBrokenException("Task result is null");
            }
            ServiceResponse<DomainObject> response = (ServiceResponse<DomainObject>) result.getData();
            if (!response.getIsSuccess())
                throw response.getException();
            serviceResponse.addData(response.getDataList());
        }
        if (responseMerger != null) {
            return responseMerger.mergeResponse(serviceResponse.getDataList());
        } else {
            return serviceResponse.getDataList().get(0);
        }
    } catch (ExecutionException exception) {
        checkAndThrowServiceClientException(exception);
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new InterruptedException(exception.getMessage());
    } catch (CancellationException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new PromiseBrokenException(promiseBrokenException);
    }
}

From source file:com.flipkart.poseidon.serviceclients.FutureTaskResultToDomainObjectPromiseWrapper.java

@Override
public DomainObject get(long timeout, TimeUnit timeUnit)
        throws PromiseBrokenException, TimeoutException, InterruptedException {
    try {//from  w w  w  .j  a v  a 2  s .  c  om
        ServiceResponse<DomainObject> serviceResponse = new ServiceResponse<>();
        for (Future<TaskResult> futureResult : futureList) {
            TaskResult result = futureResult.get(timeout, timeUnit);
            if (result == null) {
                throw new PromiseBrokenException("Task result is null");
            }
            ServiceResponse<DomainObject> response = (ServiceResponse<DomainObject>) result.getData();
            if (!response.getIsSuccess())
                throw response.getException();
            serviceResponse.addData(response.getDataList());
        }
        if (responseMerger != null) {
            return responseMerger.mergeResponse(serviceResponse.getDataList());
        } else {
            return serviceResponse.getDataList().get(0);
        }
    } catch (ExecutionException exception) {
        checkAndThrowServiceClientException(exception);
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new InterruptedException(exception.getMessage());
    } catch (CancellationException exception) {
        promiseBrokenException = new PromiseBrokenException(exception);
        throw new PromiseBrokenException(promiseBrokenException);
    }
}