List of usage examples for java.util.concurrent ExecutionException getCause
public synchronized Throwable getCause()
From source file:de.metas.procurement.webui.MockedTestServerSync.java
private void setReportedWeeklySupply(final SyncWeeklySupply syncWeeklySupply) { try {/*from www.j ava2 s . com*/ final String uuid = syncWeeklySupply.getUuid(); weeklySupplies.get(uuid).set(syncWeeklySupply); } catch (final ExecutionException e) { throw Throwables.propagate(e.getCause()); } }
From source file:org.apache.hadoop.hdfs.qjournal.client.TestIPCLoggerChannel.java
/** * Test that, once the queue eclipses the configure size limit, * calls to journal more data are rejected. */// ww w. ja v a 2s .co m @Test public void testQueueLimiting() throws Exception { // Block the underlying fake proxy from actually completing any calls. DelayAnswer delayer = new DelayAnswer(LOG); Mockito.doAnswer(delayer).when(mockProxy).journal(Mockito.<RequestInfo>any(), Mockito.eq(1L), Mockito.eq(1L), Mockito.eq(1), Mockito.same(FAKE_DATA)); // Queue up the maximum number of calls. int numToQueue = LIMIT_QUEUE_SIZE_BYTES / FAKE_DATA.length; for (int i = 1; i <= numToQueue; i++) { ch.sendEdits(1L, (long) i, 1, FAKE_DATA); } // The accounting should show the correct total number queued. assertEquals(LIMIT_QUEUE_SIZE_BYTES, ch.getQueuedEditsSize()); // Trying to queue any more should fail. try { ch.sendEdits(1L, numToQueue + 1, 1, FAKE_DATA).get(1, TimeUnit.SECONDS); fail("Did not fail to queue more calls after queue was full"); } catch (ExecutionException ee) { if (!(ee.getCause() instanceof LoggerTooFarBehindException)) { throw ee; } } delayer.proceed(); // After we allow it to proceeed, it should chug through the original queue GenericTestUtils.waitFor(new Supplier<Boolean>() { @Override public Boolean get() { return ch.getQueuedEditsSize() == 0; } }, 10, 1000); }
From source file:org.jolokia.client.request.J4pConnectionPoolingIntegrationTest.java
@Test public void testSearchParallelWithConnectionPoolException() throws Exception { configureFor("localhost", wireMockServer.port()); final J4pClient j4pClient = createJ4pClient("http://localhost:" + wireMockServer.port() + "/test", 20, 2); try {/*w w w .j a va 2s .c o m*/ searchParallel(j4pClient); fail(); } catch (ExecutionException executionException) { assertEquals(ConnectionPoolTimeoutException.class, executionException.getCause().getCause().getClass()); } }
From source file:com.rackspacecloud.blueflood.cache.TtlCache.java
public TimeValue getTtl(String acctId, ColumnFamily<Locator, Long> CF) { // if error rate exceeds a threshold return SAFETY_TTL. Otherwise, we spend a non-trivial amount of time stuck // in blocking calls into whatever obtains the account. if (isSafetyMode()) return SAFETY_TTLS.get(CF); try {//from w w w . j a va 2s . co m return cache.get(acctId).get(CF); } catch (ExecutionException ex) { if (ex.getCause() instanceof HttpResponseException) { httpErrorMeter.mark(); log.debug(ex.getCause().getMessage()); } else { // log this every 10s, then use a sane default value for the ttl. generalErrorMeter.mark(); long now = System.currentTimeMillis(); if (now - lastFetchError > 2000) { log.error("Problem fetching accounts from internal API"); if (ex.getCause() instanceof ClusterException) { for (Throwable subCause : ((ClusterException) ex.getCause()).getExceptions()) log.error("Subcause: " + subCause.getMessage()); } else log.error(ex.getCause().getMessage()); lastFetchError = now; // I don't care about races here. } } return SAFETY_TTLS.get(CF); } }
From source file:org.apache.hadoop.hbase.master.TestSchemaModificationLocks.java
@Test(timeout = 60000) public void testAlterAndDisable() throws Exception { prepareMiniCluster();// ww w . j ava 2s .c o m // Send a request to alter a table, then sleep during // the alteration phase. In the mean time, from another // thread, send a request to disable, and then delete a table. // The requests should be serialized final DelayInducingInjectionHandler delayer = new DelayInducingInjectionHandler(); delayer.setEventDelay(InjectionEvent.HMASTER_ALTER_TABLE, 6000); delayer.setEventDelay(InjectionEvent.HMASTER_DISABLE_TABLE, 3000); InjectionHandler.set(delayer); ExecutorService executor = Executors.newFixedThreadPool(2); Future alterTableFuture = executor.submit(new Callable<Object>() { @Override public Object call() throws Exception { HMaster master = getMaster(); master.addColumn(TABLE_NAME, new HColumnDescriptor(NEW_FAMILY)); LOG.info("Added new column family"); HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); assertTrue(admin.isTableEnabled(TABLE_NAME)); HTableDescriptor tableDesc = master.getTableDescriptor(TABLE_NAME); assertTrue(tableDesc.getFamiliesKeys().contains(NEW_FAMILY)); return null; } }); Future disableTableFuture = executor.submit(new Callable<Object>() { @Override public Object call() throws Exception { delayer.awaitEvent(InjectionEvent.HMASTER_ALTER_TABLE); HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); admin.disableTable(TABLE_NAME); assertTrue(admin.isTableDisabled(TABLE_NAME)); admin.deleteTable(TABLE_NAME); assertFalse(admin.tableExists(TABLE_NAME)); return null; } }); try { disableTableFuture.get(); alterTableFuture.get(); } catch (ExecutionException e) { if (e.getCause() instanceof AssertionError) { throw (AssertionError) e.getCause(); } throw e; } }
From source file:org.thingsboard.server.service.script.RuleNodeJsScriptEngine.java
private JsonNode executeScript(TbMsg msg) throws ScriptException { try {//from w w w . j ava 2 s. c om String[] inArgs = prepareArgs(msg); String eval = sandboxService.invokeFunction(this.scriptId, inArgs[0], inArgs[1], inArgs[2]).get() .toString(); return mapper.readTree(eval); } catch (ExecutionException e) { if (e.getCause() instanceof ScriptException) { throw (ScriptException) e.getCause(); } else if (e.getCause() instanceof RuntimeException) { throw new ScriptException(e.getCause().getMessage()); } else { throw new ScriptException(e); } } catch (Exception e) { throw new ScriptException(e); } }
From source file:svnserver.ext.gitlfs.storage.network.LfsHttpStorage.java
@NotNull private Link getToken(@NotNull User user) throws IOException { try {//from w w w. j a v a 2 s . co m return tokens.get(user); } catch (ExecutionException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } if (e.getCause() instanceof Error) { throw (Error) e.getCause(); } if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw new RuntimeException(e); } }
From source file:org.codehaus.httpcache4j.cache.ConcurrentCacheStorageAbstractTest.java
protected void testIterations(int numberOfIterations, int expected) throws InterruptedException { List<Callable<HTTPResponse>> calls = new ArrayList<Callable<HTTPResponse>>(); for (int i = 0; i < numberOfIterations; i++) { final URI uri = URI.create(String.valueOf(i)); final HTTPRequest request = new HTTPRequest(uri); Callable<HTTPResponse> call = new Callable<HTTPResponse>() { public HTTPResponse call() throws Exception { HTTPResponse cached = cacheStorage.insert(request, createCacheResponse()); assertResponse(cached);//from w ww.j ava 2 s . c om CacheItem cacheItem = cacheStorage.get(request); HTTPResponse response = cacheItem.getResponse(); assertResponse(response); cached = cacheStorage.update(request, createCacheResponse()); assertNotSame(cached, cacheItem.getResponse()); assertResponse(cached); return cached; } }; calls.add(call); } List<Future<HTTPResponse>> responses = service.invokeAll(calls); for (Future<HTTPResponse> responseFuture : responses) { try { responseFuture.get(); } catch (ExecutionException e) { e.printStackTrace(); fail(e.getCause().getMessage()); } } assertEquals(expected, cacheStorage.size()); }
From source file:com.github.fge.jsonschema.core.load.SchemaLoader.java
/** * Get a schema tree from the given URI/*from w ww .j a v a2 s .c om*/ * * <p>Note that if the URI is relative, it will be resolved against this * registry's namespace, if any.</p> * * @param uri the URI * @return a schema tree * @throws ProcessingException URI is not an absolute JSON reference, or * failed to dereference this URI * @throws NullPointerException URI is null */ public SchemaTree get(final URI uri) throws ProcessingException { final JsonRef ref = JsonRef.fromURI(translator.translate(uri)); if (!ref.isAbsolute()) throw new ProcessingException(new ProcessingMessage() .setMessage(BUNDLE.getMessage("refProcessing.uriNotAbsolute")).putArgument("uri", ref)); final URI realURI = ref.toURI(); try { JsonNode node = preloadedSchemas.get(realURI); if (node == null) node = cache.get(realURI); return dereferencing.newTree(ref, node); } catch (ExecutionException e) { throw (ProcessingException) e.getCause(); } }
From source file:org.mule.service.oauth.internal.DefaultClientCredentialsOAuthDancer.java
@Override public void start() throws MuleException { super.start(); try {/*from www . java 2 s. c o m*/ refreshToken().get(); } catch (ExecutionException e) { super.stop(); throw new LifecycleException(e.getCause(), this); } catch (InterruptedException e) { super.stop(); currentThread().interrupt(); throw new LifecycleException(e, this); } }