List of usage examples for java.lang InterruptedException getCause
public synchronized Throwable getCause()
From source file:org.apache.druid.indexing.overlord.RemoteTaskRunner.java
@Override public Optional<ByteSource> streamTaskLog(final String taskId, final long offset) { final ZkWorker zkWorker = findWorkerRunningTask(taskId); if (zkWorker == null) { // Worker is not running this task, it might be available in deep storage return Optional.absent(); } else {// w w w. ja va2 s. c o m // Worker is still running this task final URL url = TaskRunnerUtils.makeWorkerURL(zkWorker.getWorker(), "/druid/worker/v1/task/%s/log?offset=%d", taskId, offset); return Optional.of(new ByteSource() { @Override public InputStream openStream() throws IOException { try { return httpClient.go(new Request(HttpMethod.GET, url), new InputStreamResponseHandler()) .get(); } catch (InterruptedException e) { throw Throwables.propagate(e); } catch (ExecutionException e) { // Unwrap if possible Throwables.propagateIfPossible(e.getCause(), IOException.class); throw Throwables.propagate(e); } } }); } }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CQLKeyValueService.java
private Map<Cell, Long> getLatestTimestampsInternal(final String tableName, Map<Cell, Long> timestampByCell) throws Exception { final CassandraKeyValueServiceConfig config = configManager.getConfig(); int fetchBatchCount = config.fetchBatchCount(); Iterable<List<Cell>> partitions = Iterables.partition(timestampByCell.keySet(), fetchBatchCount); int numPartitions = (timestampByCell.size() / fetchBatchCount) + (timestampByCell.size() % fetchBatchCount > 0 ? 1 : 0); List<Future<Map<Cell, Long>>> futures = Lists.newArrayListWithCapacity(numPartitions); final String loadOnlyTsQuery = "SELECT " + CassandraConstants.ROW_NAME + ", " + CassandraConstants.COL_NAME_COL + ", " + CassandraConstants.TS_COL + " FROM " + getFullTableName(tableName) + " " + "WHERE " + CassandraConstants.ROW_NAME + " = ? AND " + CassandraConstants.COL_NAME_COL + " = ? LIMIT 1"; if (timestampByCell.size() > fetchBatchCount) { log.warn("Re-batching in getLatestTimestamps a call to " + tableName + " that attempted to multiget " + timestampByCell.size() + " cells; this may indicate overly-large batching on a higher level.\n" + CassandraKeyValueServices.getFilteredStackTrace("com.palantir")); }//from w ww . j a v a2 s . c o m for (final List<Cell> partition : partitions) { futures.add(executor.submit(new Callable<Map<Cell, Long>>() { @Override public Map<Cell, Long> call() throws Exception { PreparedStatement preparedStatement = getPreparedStatement(tableName, loadOnlyTsQuery, session); preparedStatement.setConsistencyLevel(readConsistency); List<ResultSetFuture> resultSetFutures = Lists.newArrayListWithExpectedSize(partition.size()); for (Cell c : partition) { BoundStatement boundStatement = preparedStatement.bind(); boundStatement.setBytes(CassandraConstants.ROW_NAME, ByteBuffer.wrap(c.getRowName())); boundStatement.setBytes(CassandraConstants.COL_NAME_COL, ByteBuffer.wrap(c.getColumnName())); resultSetFutures.add(session.executeAsync(boundStatement)); } Map<Cell, Long> res = Maps.newHashMapWithExpectedSize(partition.size()); for (ResultSetFuture resultSetFuture : resultSetFutures) { ResultSet resultSet = resultSetFuture.getUninterruptibly(); for (Row row : resultSet.all()) { res.put(Cell.create(CQLKeyValueServices.getRowName(row), CQLKeyValueServices.getColName(row)), CQLKeyValueServices.getTs(row)); } CQLKeyValueServices.logTracedQuery(loadOnlyTsQuery, resultSet, session, cqlStatementCache.NORMAL_QUERY); } return res; } })); } Map<Cell, Long> res = Maps.newHashMapWithExpectedSize(timestampByCell.size()); for (Future<Map<Cell, Long>> f : futures) { try { res.putAll(f.get()); } catch (InterruptedException e) { throw Throwables.throwUncheckedException(e); } catch (ExecutionException e) { Throwables.throwIfInstance(e, Error.class); throw Throwables.throwUncheckedException(e.getCause()); } } return res; }
From source file:gov.bnl.channelfinder.api.ChannelFinderClientImpl.java
private <T> T wrappedSubmit(Callable<T> callable) { try {/* w w w . ja v a 2 s . c o m*/ return this.executor.submit(callable).get(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { if (e.getCause() != null && e.getCause() instanceof UniformInterfaceException) { throw new ChannelFinderException((UniformInterfaceException) e.getCause()); } throw new RuntimeException(e); } }
From source file:gov.bnl.channelfinder.api.ChannelFinderClientImpl.java
private void wrappedSubmit(Runnable runnable) { try {/*from ww w .j a v a 2s .com*/ this.executor.submit(runnable).get(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { if (e.getCause() != null && e.getCause() instanceof UniformInterfaceException) { throw new ChannelFinderException((UniformInterfaceException) e.getCause()); } throw new RuntimeException(e); } }
From source file:org.apache.jackrabbit.core.cluster.ClusterNode.java
/** * Synchronize contents from journal.// ww w. jav a 2 s. c o m * * @throws ClusterException if an error occurs */ public void sync() throws ClusterException { int count = syncCount; try { syncLock.acquire(); } catch (InterruptedException e) { String msg = "Interrupted while waiting for mutex."; throw new ClusterException(msg); } try { // JCR-1753: Only synchronize if no other thread already did so // while we were waiting to acquire the syncLock. if (count == syncCount) { journal.sync(); syncCount++; } } catch (JournalException e) { throw new ClusterException(e.getMessage(), e.getCause()); } finally { syncLock.release(); } }
From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector.java
/** * Release the session, if it's time.// ww w.jav a2 s .co m */ protected void releaseCheck() throws ManifoldCFException { if (lastSessionFetch == -1L) return; long currentTime = System.currentTimeMillis(); if (currentTime >= lastSessionFetch + timeToRelease) { DestroySessionThread t = new DestroySessionThread(); try { t.start(); t.join(); Throwable thr = t.getException(); if (thr != null) { if (thr instanceof RemoteException) throw (RemoteException) thr; else throw (Error) thr; } session = null; lastSessionFetch = -1L; } catch (InterruptedException e) { t.interrupt(); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (RemoteException e) { Throwable e2 = e.getCause(); if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException) throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED); session = null; lastSessionFetch = -1L; // Treat this as a transient problem Logging.connectors.warn("CMIS: Transient remote exception closing session: " + e.getMessage(), e); } } }
From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector.java
/** * This method is periodically called for all connectors that are connected but not * in active use./*w ww .ja va 2s .co m*/ */ @Override public void poll() throws ManifoldCFException { if (lastSessionFetch == -1L) return; long currentTime = System.currentTimeMillis(); if (currentTime >= lastSessionFetch + timeToRelease) { DestroySessionThread t = new DestroySessionThread(); try { t.start(); t.join(); Throwable thr = t.getException(); if (thr != null) { if (thr instanceof RemoteException) throw (RemoteException) thr; else throw (Error) thr; } session = null; lastSessionFetch = -1L; } catch (InterruptedException e) { t.interrupt(); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (RemoteException e) { Throwable e2 = e.getCause(); if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException) throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED); session = null; lastSessionFetch = -1L; // Treat this as a transient problem Logging.connectors.warn("CMIS: Transient remote exception closing session: " + e.getMessage(), e); } } }
From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector.java
protected void checkConnection() throws ManifoldCFException, ServiceInterruption { while (true) { boolean noSession = (session == null); getSession();/* w w w.j a v a 2 s . c om*/ long currentTime; CheckConnectionThread t = new CheckConnectionThread(); try { t.start(); t.join(); Throwable thr = t.getException(); if (thr != null) { if (thr instanceof RemoteException) throw (RemoteException) thr; else if (thr instanceof CmisConnectionException) throw new ManifoldCFException("CMIS: Error during checking connection: " + thr.getMessage(), thr); else throw (Error) thr; } return; } catch (InterruptedException e) { t.interrupt(); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (RemoteException e) { Throwable e2 = e.getCause(); if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException) throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED); if (noSession) { currentTime = System.currentTimeMillis(); throw new ServiceInterruption( "Transient error connecting to filenet service: " + e.getMessage(), currentTime + 60000L); } session = null; lastSessionFetch = -1L; continue; } } }
From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector.java
/** * Close the connection. Call this before discarding the connection. *//*from w w w. jav a2 s.com*/ @Override public void disconnect() throws ManifoldCFException { if (session != null) { DestroySessionThread t = new DestroySessionThread(); try { t.start(); t.join(); Throwable thr = t.getException(); if (thr != null) { if (thr instanceof RemoteException) throw (RemoteException) thr; else throw (Error) thr; } session = null; lastSessionFetch = -1L; } catch (InterruptedException e) { t.interrupt(); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (RemoteException e) { Throwable e2 = e.getCause(); if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException) throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED); session = null; lastSessionFetch = -1L; // Treat this as a transient problem Logging.connectors.warn("CMIS: Transient remote exception closing session: " + e.getMessage(), e); } } username = null; password = null; protocol = null; server = null; port = null; path = null; binding = null; repositoryId = null; }
From source file:org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.java
static void importTestRunSession(final String url) { try {// w w w . j a v a 2s .c o m PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { JUnitModel.importTestRunSession(url, monitor); } }); } catch (InterruptedException e) { // cancelled } catch (InvocationTargetException e) { CoreException ce = (CoreException) e.getCause(); StatusManager.getManager().handle(ce.getStatus(), StatusManager.SHOW | StatusManager.LOG); } }