List of usage examples for java.util.concurrent ExecutionException getMessage
public String getMessage()
From source file:de.adorsys.jmspojo.JMSJavaFutureAdapterTest.java
@Test public void testSendAndWaitForError() throws InterruptedException, TimeoutException { JMSJavaFutureAdapter<PingMessage> jmsServiceMethodInvoker = new JMSJavaFutureAdapter<PingMessage>( objectMapper, cf, PingMessage.class, 5000); HashMap<String, Object> messageProperties = new HashMap<String, Object>(); messageProperties.put("error", true); JMSFuture<PingMessage> future = jmsServiceMethodInvoker.send(testQueue, messageProperties, new PingMessage()); try {//from ww w.j ava 2 s . c om future.get(1000, TimeUnit.MILLISECONDS); fail("error expected"); } catch (ExecutionException e) { assertEquals("test error", e.getMessage()); } }
From source file:com.oneops.opamp.ws.OpampWsController.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 key message key/*from w w w.java 2 s .com*/ * @return cache entry map. */ @RequestMapping(value = "/cache/entry", method = RequestMethod.GET) @ResponseBody public ResponseEntity<Map<String, Object>> getCacheEntry( @RequestParam(value = "key", required = true) String key) { Map<String, Object> stat = new LinkedHashMap<>(2); String entry; try { entry = cache.instance().get(key); } catch (ExecutionException e) { stat.put("status", e.getMessage()); return new ResponseEntity<>(stat, HttpStatus.NOT_FOUND); } stat.put("status", "ok"); stat.put("entry", entry); return new ResponseEntity<>(stat, HttpStatus.OK); }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.dns.ZoneManager.java
private static Zone fillDynamicZone(final LoadingCache<ZoneKey, Zone> dzc, final Zone staticZone, final Name name, final List<InetRecord> addresses, final boolean dnssecRequest) { if (addresses == null) { return null; }/*from www. ja v a2s.co m*/ try { final List<Record> records = createZoneRecords(staticZone); int recordsAdded = 0; for (final InetRecord address : addresses) { final Record record = createRecord(name, address); if (record != null) { records.add(record); recordsAdded++; } } if (recordsAdded > 0) { try { final ZoneKey zoneKey = signatureManager.generateDynamicZoneKey(staticZone.getOrigin(), records, dnssecRequest); final Zone zone = dzc.get(zoneKey); return zone; } catch (ExecutionException e) { LOGGER.error(e, e); } return new Zone(staticZone.getOrigin(), records.toArray(new Record[records.size()])); } } catch (final IOException e) { LOGGER.error(e.getMessage(), e); } return null; }
From source file:nz.org.proverbio.android.loader.DataLoader.java
@Override public ServerApiCall loadInBackground() { RequestFuture<String> future = RequestFuture.newFuture(); JsonObjectRequest request = new JsonObjectRequest( //Method serverApiCall.getHttpMethod(), //Url APPLICATION_CONTEXT.getString(R.string.server_url) + serverApiCall.getRequestPath(), //Data - This only supports POST and GET serverApiCall.getHttpMethod() == Request.Method.POST ? JSON_MANAGER.toJSON(serverApiCall.getRequest().getMessage()) : null,/* w w w. j a v a 2 s . co m*/ future, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { serverApiCall.getResponse().setError(volleyError); } }); NETWORK_MANAGER.getRequestQueue().add(request); try { String jsonResponse = future.get(20, TimeUnit.SECONDS); serverApiCall.getResponse() .setResult((Message) JSON_MANAGER.fromJSON(jsonResponse, serverApiCall.getResponseType())); return serverApiCall; } catch (InterruptedException ie) { Log.e(TAG, "The request has been interrupted", ie); } catch (ExecutionException ee) { Log.e(TAG, ee.getMessage()); } catch (TimeoutException te) { Log.e(TAG, "Timeout has occurred", te); } return serverApiCall; }
From source file:xbird.xquery.ext.grid.DispatchQueryExecTask.java
@Override public Sequence<? extends Item> execute() throws GridException { final Future<Sequence<? extends Item>> future = grid.execute(QueryExecJob.class, this); try {/* www . j av a 2 s . c o m*/ return future.get(); } catch (InterruptedException ie) { LOG.error(ie.getMessage()); throw new GridException(ie.getMessage(), ie); } catch (ExecutionException ee) { LOG.error(ee.getMessage()); throw new GridException(ee.getMessage(), ee); } }
From source file:org.apache.metron.enrichment.stellar.ObjectGet.java
@Override public Object apply(List<Object> args, Context context) throws ParseException { if (!isInitialized()) { return null; }/*w ww .ja v a 2 s . c o m*/ if (args.size() < 1) { return null; } Object o = args.get(0); if (o == null) { return null; } if (o instanceof String) { try { return cache.get((String) o); } catch (ExecutionException e) { throw new IllegalStateException("Unable to retrieve " + o + " because " + e.getMessage(), e); } } else { throw new IllegalStateException("Unable to retrieve " + o + " as it is not a path"); } }
From source file:com.leclercb.taskunifier.gui.main.Main.java
private static boolean loadApiPlugins() { API_PLUGINS = new PluginLoader<SynchronizerGuiPlugin>(SynchronizerGuiPlugin.class); API_PLUGINS.addPlugin(null, DummyGuiPlugin.getInstance()); File pluginsFolder = new File(getPluginsFolder()); boolean outdatedPlugins = false; File[] pluginFiles = pluginsFolder.listFiles(); for (File file : pluginFiles) { try {/*w w w.ja v a 2 s . c o m*/ ProcessLoadPlugin process = new ProcessLoadPlugin(file); Worker<SynchronizerGuiPlugin> worker = new Worker<SynchronizerGuiPlugin>(process); worker.setSilent(true); worker.execute(); try { worker.get(); } catch (ExecutionException e) { if (e.getCause() instanceof PluginException) throw e.getCause(); } } catch (PluginException e) { switch (e.getType()) { case MORE_THAN_ONE_PLUGIN: case NO_VALID_PLUGIN: case OUTDATED_PLUGIN: outdatedPlugins = true; break; default: outdatedPlugins = false; break; } GuiLogger.getLogger().warning(e.getMessage()); } catch (Throwable t) { GuiLogger.getLogger().log(Level.WARNING, "Error while loading plugin", t); } } API_PLUGINS.addListChangeListener(new ListChangeListener() { @Override public void listChange(ListChangeEvent evt) { SynchronizerGuiPlugin plugin = (SynchronizerGuiPlugin) evt.getValue(); if (evt.getChangeType() == ListChangeEvent.VALUE_REMOVED) { if (EqualsUtils.equals(Main.getUserSettings().getStringProperty("plugin.synchronizer.id"), plugin.getId())) SynchronizerUtils.setSynchronizerPlugin(DummyGuiPlugin.getInstance()); } } }); SynchronizerUtils.setSynchronizerPlugin(SynchronizerUtils.getSynchronizerPlugin()); return outdatedPlugins; }
From source file:io.scigraph.owlapi.loader.BatchOwlLoader.java
public void loadOntology() throws InterruptedException, ExecutionException { CompletionService<Long> completionService = new ExecutorCompletionService<Long>(exec); Set<Future<?>> futures = new HashSet<>(); if (!ontologies.isEmpty()) { for (int i = 0; i < numConsumers; i++) { futures.add(completionService.submit(consumerProvider.get())); }/*from w w w .j a va 2s. c o m*/ for (int i = 0; i < numProducers; i++) { futures.add(completionService.submit(producerProvider.get())); } for (OntologySetup ontology : ontologies) { urlQueue.offer(ontology); } for (int i = 0; i < numProducers; i++) { urlQueue.offer(POISON_STR); } } while (futures.size() > 0) { Future<?> completedFuture = completionService.take(); futures.remove(completedFuture); try { completedFuture.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Stopping batchLoading due to: " + e.getMessage(), e); e.printStackTrace(); exec.shutdownNow(); throw new InterruptedException(e.getCause().getMessage()); } } exec.shutdown(); exec.awaitTermination(10, TimeUnit.DAYS); graph.shutdown(); logger.info("Postprocessing..."); postprocessorProvider.get().postprocess(); if (cliqueConfiguration.isPresent()) { postprocessorProvider.runCliquePostprocessor(cliqueConfiguration.get()); } postprocessorProvider.shutdown(); }
From source file:org.centralperf.controller.ApiController.java
/** * export summary chart csv./*from ww w . j av a 2 s . co m*/ * @param runId ID of the run (from URI) * @param model Model prepared for the new project form view * @return CSV with Response Time and concurrent requests datas * @throws IOException */ @RequestMapping(value = "/api/getSumChartCSV/{runId}", method = RequestMethod.GET, produces = "text/csv") @ResponseBody public String getSumChartCSV(@PathVariable("runId") Long runId, Model model, HttpServletResponse response) throws IOException { String csv = ""; try { csv = runStatService.getSummaryGraph(runId); } catch (ExecutionException ee) { log.error("CSV data could not be retrieve from cache:" + ee.getMessage()); } return csv; }
From source file:org.centralperf.controller.ApiController.java
/** * export csv with average response time of each sample. * @param runId ID of the run (from URI) * @param model Model prepared for the new project form view * @return CSV with average Response Time * @throws IOException // ww w.j a v a 2 s .c o m */ @RequestMapping(value = "/api/getRTChartCSV/{runId}", method = RequestMethod.GET, produces = "text/csv") @ResponseBody public String getRTChartCSV(@PathVariable("runId") Long runId, Model model, HttpServletResponse response) throws IOException { String csv = ""; try { csv = runStatService.getResponseTimeGraph(runId); } catch (ExecutionException ee) { log.error("CSV data could not be retrieve from cache:" + ee.getMessage()); } return csv; }