List of usage examples for java.io InterruptedIOException InterruptedIOException
public InterruptedIOException()
InterruptedIOException
with null
as its error detail message. From source file:org.callimachusproject.io.CarInputStream.java
private ZipArchiveEntry next() throws IOException { if (Thread.interrupted()) throw new InterruptedIOException(); entry = zipStream.getNextZipEntry(); if (entry == null) { entryStream = null;// ww w. j a v a 2s. com entryMetaType = null; return null; } final ZipArchiveEntry openEntry = entry; entryStream = new LatencyInputStream(new FilterInputStream(zipStream) { public void close() throws IOException { if (openEntry == entry) { entry = null; entryStream = null; entryMetaType = null; } } }, RDFS_PEEK_SIZE); entryType = readEntryType(entry, entryStream); entryMetaType = MetaTypeExtraField.parseExtraField(entry); if (entryMetaType == null) { if (entry.isDirectory()) { entryMetaType = MetaTypeExtraField.FOLDER; } else if (FILE_NAME.matcher(entry.getName()).find()) { entryMetaType = MetaTypeExtraField.FILE; } else if (scanForClass(entryStream, entryType)) { entryMetaType = MetaTypeExtraField.RDFS; } else { entryMetaType = MetaTypeExtraField.RDF; } } return entry; }
From source file:org.apache.http.impl.execchain.ServiceUnavailableRetryExec.java
public CloseableHttpResponse execute(final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { final Header[] origheaders = request.getAllHeaders(); for (int c = 1;; c++) { final CloseableHttpResponse response = this.requestExecutor.execute(route, request, context, execAware); try {/*from w ww . j a v a2s. c o m*/ if (this.retryStrategy.retryRequest(response, c, context)) { response.close(); final long nextInterval = this.retryStrategy.getRetryInterval(); if (nextInterval > 0) { try { this.log.trace("Wait for " + nextInterval); Thread.sleep(nextInterval); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new InterruptedIOException(); } } request.setHeaders(origheaders); } else { return response; } } catch (final RuntimeException ex) { response.close(); throw ex; } } }
From source file:org.apache.http.HC4.impl.execchain.ServiceUnavailableRetryExec.java
@Override public CloseableHttpResponse execute(final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { final Header[] origheaders = request.getAllHeaders(); for (int c = 1;; c++) { final CloseableHttpResponse response = this.requestExecutor.execute(route, request, context, execAware); try {/*from w ww .j av a 2s.co m*/ if (this.retryStrategy.retryRequest(response, c, context)) { response.close(); final long nextInterval = this.retryStrategy.getRetryInterval(); if (nextInterval > 0) { try { this.log.trace("Wait for " + nextInterval); Thread.sleep(nextInterval); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new InterruptedIOException(); } } request.setHeaders(origheaders); } else { return response; } } catch (final RuntimeException ex) { response.close(); throw ex; } } }
From source file:com.epam.reportportal.apache.http.impl.execchain.ServiceUnavailableRetryExec.java
public CloseableHttpResponse execute(final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { for (int c = 1;; c++) { final CloseableHttpResponse response = this.requestExecutor.execute(route, request, context, execAware); try {/*from www. ja va 2s.c om*/ if (this.retryStrategy.retryRequest(response, c, context)) { response.close(); final long nextInterval = this.retryStrategy.getRetryInterval(); if (nextInterval > 0) { try { this.log.trace("Wait for " + nextInterval); Thread.sleep(nextInterval); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new InterruptedIOException(); } } } else { return response; } } catch (final RuntimeException ex) { response.close(); throw ex; } } }
From source file:com.reactivetechnologies.platform.stream.DistributedPipedOutputStream.java
private void writeByte(byte b) throws IOException { try {/* w w w . j ava2s .c o m*/ writeToChannel(b); } catch (InterruptedException e) { throw new InterruptedIOException(); } }
From source file:org.apache.hadoop.hbase.client.AsyncTableResultScanner.java
@Override public synchronized Result next() throws IOException { while (queue.isEmpty()) { if (closed) { return null; }/*from w ww. java 2 s . c o m*/ if (error != null) { Throwables.propagateIfPossible(error, IOException.class); throw new IOException(error); } try { wait(); } catch (InterruptedException e) { throw new InterruptedIOException(); } } Result result = queue.poll(); cacheSize -= calcEstimatedSize(result); if (resumer != null && cacheSize <= maxCacheSize / 2) { resumePrefetch(); } return result; }
From source file:org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait.java
public static <T> T waitFor(MasterProcedureEnv env, long waitTime, long waitingTimeForEvents, String purpose, Predicate<T> predicate) throws IOException { final long done = EnvironmentEdgeManager.currentTime() + waitTime; do {// w ww.j a va 2s .c o m T result = predicate.evaluate(); if (result != null && !result.equals(Boolean.FALSE)) { return result; } try { Thread.sleep(waitingTimeForEvents); } catch (InterruptedException e) { LOG.warn("Interrupted while sleeping, waiting on " + purpose); throw (InterruptedIOException) new InterruptedIOException().initCause(e); } LOG.debug("Waiting on " + purpose); } while (EnvironmentEdgeManager.currentTime() < done && env.isRunning()); throw new TimeoutIOException("Timed out while waiting on " + purpose); }
From source file:com.asakusafw.runtime.stage.output.LegacyBridgeOutputCommitter.java
private OutputCommitter committer(org.apache.hadoop.mapreduce.TaskAttemptContext taskContext) throws IOException { try {//from ww w . j a va 2 s.c o m return format.getOutputCommitter(taskContext); } catch (InterruptedException e) { throw (IOException) new InterruptedIOException().initCause(e); } }
From source file:org.apache.hadoop.hbase.zookeeper.RegionServerTracker.java
private void add(final List<String> servers) throws IOException { synchronized (this.regionServers) { this.regionServers.clear(); for (String n : servers) { ServerName sn = ServerName.parseServerName(ZKUtil.getNodeName(n)); if (regionServers.get(sn) == null) { RegionServerInfo.Builder rsInfoBuilder = RegionServerInfo.newBuilder(); try { String nodePath = ZKUtil.joinZNode(watcher.rsZNode, n); byte[] data = ZKUtil.getData(watcher, nodePath); if (LOG.isDebugEnabled()) { LOG.debug("RS node: " + nodePath + " data: " + Bytes.toString(data)); }//from w w w .jav a 2 s. c o m if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) { int magicLen = ProtobufUtil.lengthOfPBMagic(); rsInfoBuilder.mergeFrom(data, magicLen, data.length - magicLen); } } catch (KeeperException e) { LOG.warn("Get Rs info port from ephemeral node", e); } catch (IOException e) { LOG.warn("Illegal data from ephemeral node", e); } catch (InterruptedException e) { throw new InterruptedIOException(); } this.regionServers.put(sn, rsInfoBuilder.build()); } } } }
From source file:org.apache.phoenix.hbase.index.LockManager.java
/** * Lock the row or throw otherwise//from ww w .j a va 2 s . co m * @param row the row key * @return RowLock used to eventually release the lock * @throws TimeoutIOException if the lock could not be acquired within the * allowed rowLockWaitDuration and InterruptedException if interrupted while * waiting to acquire lock. */ public RowLock lockRow(byte[] row, int waitDuration) throws IOException { // create an object to use a a key in the row lock map ImmutableBytesPtr rowKey = new ImmutableBytesPtr(row); RowLockContext rowLockContext = null; RowLockImpl result = null; TraceScope traceScope = null; // If we're tracing start a span to show how long this took. if (Trace.isTracing()) { traceScope = Trace.startSpan("LockManager.getRowLock"); traceScope.getSpan().addTimelineAnnotation("Getting a lock"); } boolean success = false; try { // Keep trying until we have a lock or error out. // TODO: do we need to add a time component here? while (result == null) { // Try adding a RowLockContext to the lockedRows. // If we can add it then there's no other transactions currently running. rowLockContext = new RowLockContext(rowKey); RowLockContext existingContext = lockedRows.putIfAbsent(rowKey, rowLockContext); // if there was a running transaction then there's already a context. if (existingContext != null) { rowLockContext = existingContext; } result = rowLockContext.newRowLock(); } if (!result.getLock().tryLock(waitDuration, TimeUnit.MILLISECONDS)) { if (traceScope != null) { traceScope.getSpan().addTimelineAnnotation("Failed to get row lock"); } throw new TimeoutIOException("Timed out waiting for lock for row: " + rowKey); } rowLockContext.setThreadName(Thread.currentThread().getName()); success = true; return result; } catch (InterruptedException ie) { LOG.warn("Thread interrupted waiting for lock on row: " + rowKey); InterruptedIOException iie = new InterruptedIOException(); iie.initCause(ie); if (traceScope != null) { traceScope.getSpan().addTimelineAnnotation("Interrupted exception getting row lock"); } Thread.currentThread().interrupt(); throw iie; } finally { // On failure, clean up the counts just in case this was the thing keeping the context alive. if (!success && rowLockContext != null) rowLockContext.cleanUp(); if (traceScope != null) { traceScope.close(); } } }