当前位置: 首页>>代码示例>>Java>>正文


Java InterruptedIOException.initCause方法代码示例

本文整理汇总了Java中java.io.InterruptedIOException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java InterruptedIOException.initCause方法的具体用法?Java InterruptedIOException.initCause怎么用?Java InterruptedIOException.initCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.InterruptedIOException的用法示例。


在下文中一共展示了InterruptedIOException.initCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWriteEntry

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Will block until a write entry has been assigned by they WAL subsystem.
 * @return A WriteEntry gotten from local WAL subsystem. Must be completed by calling
 * mvcc#complete or mvcc#completeAndWait.
 * @throws InterruptedIOException
 * @see
 * #setWriteEntry(org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl.WriteEntry)
 */
@InterfaceAudience.Private // For internal use only.
public MultiVersionConcurrencyControl.WriteEntry getWriteEntry() throws InterruptedIOException {
  try {
    this.seqNumAssignedLatch.await();
  } catch (InterruptedException ie) {
    // If interrupted... clear out our entry else we can block up mvcc.
    MultiVersionConcurrencyControl mvcc = getMvcc();
    LOG.debug("mvcc=" + mvcc + ", writeEntry=" + this.writeEntry);
    if (mvcc != null) {
      if (this.writeEntry != null) {
        mvcc.complete(this.writeEntry);
      }
    }
    InterruptedIOException iie = new InterruptedIOException();
    iie.initCause(ie);
    throw iie;
  }
  return this.writeEntry;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:WALKey.java

示例2: take

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Retrieves a task from the queue with the given timeout.
 *
 * @param useTimeout whether to use a timeout.
 * @param timeoutNano Time to wait, in nanoseconds.
 * @return A non-{@code null} Runnable from the queue.
 * @throws InterruptedIOException
 */
private Runnable take(boolean useTimeout, long timeoutNano) throws InterruptedIOException {
    Runnable task = null;
    try {
        if (!useTimeout) {
            task = mQueue.take(); // Blocks if the queue is empty.
        } else {
            // poll returns null upon timeout.
            task = mQueue.poll(timeoutNano, TimeUnit.NANOSECONDS);
        }
    } catch (InterruptedException e) {
        InterruptedIOException exception = new InterruptedIOException();
        exception.initCause(e);
        throw exception;
    }
    if (task == null) {
        // This will terminate the loop.
        throw new SocketTimeoutException();
    }
    return task;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:29,代码来源:MessageLoop.java

示例3: read

import java.io.InterruptedIOException; //导入方法依赖的package包/类
@Override
public int read() throws IOException {
    synchronized(synchronizer) {
        while(read_pos == write_pos) {
            if(exception != null) {
                throw exception;
            }
            if(isEOF) {
                return -1;
            }
            try {
                synchronizer.wait();
            }
            catch(InterruptedException e) {
                final InterruptedIOException f = new InterruptedIOException(e.getMessage());
                f.initCause(e);
                throw f;
            }
        }
        return buffer[read_pos++] & 0xff;
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:StreamGobbler.java

示例4: timeout

import java.io.InterruptedIOException; //导入方法依赖的package包/类
private static AsyncTimeout timeout(final Socket socket) {
    return new AsyncTimeout() {
        protected IOException newTimeoutException(IOException cause) {
            InterruptedIOException ioe = new SocketTimeoutException(a.f);
            if (cause != null) {
                ioe.initCause(cause);
            }
            return ioe;
        }

        protected void timedOut() {
            try {
                socket.close();
            } catch (Exception e) {
                Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, e);
            } catch (AssertionError e2) {
                if (e2.getCause() == null || e2.getMessage() == null || !e2.getMessage().contains("getsockname failed")) {
                    throw e2;
                }
                Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, e2);
            }
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:Okio.java

示例5: createPacket

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/** Use {@link ByteArrayManager} to create buffer for non-heartbeat packets.*/
private DFSPacket createPacket(int packetSize, int chunksPerPkt, long offsetInBlock,
    long seqno, boolean lastPacketInBlock) throws InterruptedIOException {
  final byte[] buf;
  final int bufferSize = PacketHeader.PKT_MAX_HEADER_LEN + packetSize;

  try {
    buf = byteArrayManager.newByteArray(bufferSize);
  } catch (InterruptedException ie) {
    final InterruptedIOException iioe = new InterruptedIOException(
        "seqno=" + seqno);
    iioe.initCause(ie);
    throw iioe;
  }

  return new DFSPacket(buf, chunksPerPkt, offsetInBlock, seqno,
                       getChecksumSize(), lastPacketInBlock);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DFSOutputStream.java

示例6: getSequenceId

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Wait for sequence number to be assigned & return the assigned value.
 * @param maxWaitForSeqId maximum time to wait in milliseconds for sequenceid
 * @return long the new assigned sequence number
 * @throws IOException
 */
public long getSequenceId(final long maxWaitForSeqId) throws IOException {
  // TODO: This implementation waiting on a latch is problematic because if a higher level
  // determines we should stop or abort, there is no global list of all these blocked WALKeys
  // waiting on a sequence id; they can't be cancelled... interrupted. See getNextSequenceId.
  //
  // UPDATE: I think we can remove the timeout now we are stamping all walkeys with sequenceid,
  // even those that have failed (previously we were not... so they would just hang out...).
  // St.Ack 20150910
  try {
    if (maxWaitForSeqId < 0) {
      this.seqNumAssignedLatch.await();
    } else if (!this.seqNumAssignedLatch.await(maxWaitForSeqId, TimeUnit.MILLISECONDS)) {
      throw new TimeoutIOException("Failed to get sequenceid after " + maxWaitForSeqId +
        "ms; WAL system stuck or has gone away?");
    }
  } catch (InterruptedException ie) {
    LOG.warn("Thread interrupted waiting for next log sequence number");
    InterruptedIOException iie = new InterruptedIOException();
    iie.initCause(ie);
    throw iie;
  }
  return this.logSeqNum;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:WALKey.java

示例7: preCreateCoprocScanner

import java.io.InterruptedIOException; //导入方法依赖的package包/类
protected InternalScanner preCreateCoprocScanner(final CompactionRequest request,
    final ScanType scanType, final long earliestPutTs, final List<StoreFileScanner> scanners,
    User user) throws IOException {
  if (store.getCoprocessorHost() == null) return null;
  if (user == null) {
    return store.getCoprocessorHost()
        .preCompactScannerOpen(store, scanners, scanType, earliestPutTs, request);
  } else {
    try {
      return user.getUGI().doAs(new PrivilegedExceptionAction<InternalScanner>() {
        @Override public InternalScanner run() throws Exception {
          return store.getCoprocessorHost()
              .preCompactScannerOpen(store, scanners, scanType, earliestPutTs, request);
        }
      });
    } catch (InterruptedException ie) {
      InterruptedIOException iioe = new InterruptedIOException();
      iioe.initCause(ie);
      throw iioe;
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:Compactor.java

示例8: postCreateCoprocScanner

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Calls coprocessor, if any, to create scanners - after normal scanner creation.
 *
 * @param request  Compaction request.
 * @param scanType Scan type.
 * @param scanner  The default scanner created for compaction.
 * @return Scanner scanner to use (usually the default); null if compaction should not proceed.
 */
protected InternalScanner postCreateCoprocScanner(final CompactionRequest request,
    final ScanType scanType, final InternalScanner scanner, User user) throws IOException {
  if (store.getCoprocessorHost() == null) return scanner;
  if (user == null) {
    return store.getCoprocessorHost().preCompact(store, scanner, scanType, request);
  } else {
    try {
      return user.getUGI().doAs(new PrivilegedExceptionAction<InternalScanner>() {
        @Override public InternalScanner run() throws Exception {
          return store.getCoprocessorHost().preCompact(store, scanner, scanType, request);
        }
      });
    } catch (InterruptedException ie) {
      InterruptedIOException iioe = new InterruptedIOException();
      iioe.initCause(ie);
      throw iioe;
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:Compactor.java

示例9: asInterrupt

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * @return an InterruptedIOException if t was an interruption, null otherwise
 */
public static InterruptedIOException asInterrupt(Throwable t) {
  if (t instanceof SocketTimeoutException) return null;

  if (t instanceof InterruptedIOException) return (InterruptedIOException) t;

  if (t instanceof InterruptedException || t instanceof ClosedByInterruptException) {
    InterruptedIOException iie =
        new InterruptedIOException("Origin: " + t.getClass().getSimpleName());
    iie.initCause(t);
    return iie;
  }

  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ExceptionUtil.java

示例10: newTimeoutException

import java.io.InterruptedIOException; //导入方法依赖的package包/类
protected IOException newTimeoutException(IOException cause) {
    InterruptedIOException e = new InterruptedIOException(a.f);
    if (cause != null) {
        e.initCause(cause);
    }
    return e;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:AsyncTimeout.java

示例11: getResponseHeaders

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Returns the stream's response headers, blocking if necessary if they
 * have not been received yet.
 */
public synchronized List<String> getResponseHeaders() throws IOException {
  long remaining = 0;
  long start = 0;
  if (readTimeoutMillis != 0) {
    start = (System.nanoTime() / 1000000);
    remaining = readTimeoutMillis;
  }
  try {
    while (responseHeaders == null && errorCode == null) {
      if (readTimeoutMillis == 0) { // No timeout configured.
        wait();
      } else if (remaining > 0) {
        wait(remaining);
        remaining = start + readTimeoutMillis - (System.nanoTime() / 1000000);
      } else {
        throw new SocketTimeoutException("Read response header timeout. readTimeoutMillis: "
                          + readTimeoutMillis);
      }
    }
    if (responseHeaders != null) {
      return responseHeaders;
    }
    throw new IOException("stream was reset: " + errorCode);
  } catch (InterruptedException e) {
    InterruptedIOException rethrow = new InterruptedIOException();
    rethrow.initCause(e);
    throw rethrow;
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:34,代码来源:SpdyStream.java

示例12: get

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Returns the parameter passed to {@link #run(Object)} or {@code null} if a null value was
 * passed.  When used asynchronously, this method will block until the {@link #run(Object)}
 * method has been called.
 * @return the response object or {@code null} if no response was passed
 */
public synchronized R get() throws IOException {
  while (!resultSet) {
    try {
      this.wait();
    } catch (InterruptedException ie) {
      InterruptedIOException exception = new InterruptedIOException(ie.getMessage());
      exception.initCause(ie);
      throw exception;
    }
  }
  return result;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:BlockingRpcCallback.java

示例13: execute

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Run the transaction.
 * @param server Hosting server instance.  Can be null when testing
 * @param services Used to online/offline regions.
 * @throws IOException If thrown, transaction failed.
 *          Call {@link #rollback(Server, RegionServerServices)}
 * @return Regions created
 * @throws IOException
 * @see #rollback(Server, RegionServerServices)
 */
@Override
public PairOfSameType<Region> execute(final Server server,
    final RegionServerServices services, User user) throws IOException {
  this.server = server;
  this.rsServices = services;
  useZKForAssignment = server == null ? true :
    ConfigUtil.useZKForAssignment(server.getConfiguration());
  if (useCoordinatedStateManager(server)) {
    std =
        ((BaseCoordinatedStateManager) server.getCoordinatedStateManager())
            .getSplitTransactionCoordination().getDefaultDetails();
  }
  PairOfSameType<Region> regions = createDaughters(server, services, user);
  if (this.parent.getCoprocessorHost() != null) {
    if (user == null) {
      parent.getCoprocessorHost().preSplitAfterPONR();
    } else {
      try {
        user.getUGI().doAs(new PrivilegedExceptionAction<Void>() {
          @Override
          public Void run() throws Exception {
            parent.getCoprocessorHost().preSplitAfterPONR();
            return null;
          }
        });
      } catch (InterruptedException ie) {
        InterruptedIOException iioe = new InterruptedIOException();
        iioe.initCause(ie);
        throw iioe;
      }
    }
  }
  regions = stepsAfterPONR(server, services, regions, user);

  transition(SplitTransactionPhase.COMPLETED);

  return regions;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:SplitTransactionImpl.java

示例14: stepsAfterPONR

import java.io.InterruptedIOException; //导入方法依赖的package包/类
public PairOfSameType<Region> stepsAfterPONR(final Server server,
    final RegionServerServices services, final PairOfSameType<Region> regions, User user)
    throws IOException {
  openDaughters(server, services, regions.getFirst(), regions.getSecond());
  if (useCoordinatedStateManager(server)) {
    ((BaseCoordinatedStateManager) server.getCoordinatedStateManager())
        .getSplitTransactionCoordination().completeSplitTransaction(services, regions.getFirst(),
          regions.getSecond(), std, parent);
  }

  transition(SplitTransactionPhase.BEFORE_POST_SPLIT_HOOK);

  // Coprocessor callback
  if (parent.getCoprocessorHost() != null) {
    if (user == null) {
      this.parent.getCoprocessorHost().postSplit(regions.getFirst(), regions.getSecond());
    } else {
      try {
        user.getUGI().doAs(new PrivilegedExceptionAction<Void>() {
          @Override
          public Void run() throws Exception {
            parent.getCoprocessorHost().postSplit(regions.getFirst(), regions.getSecond());
            return null;
          }
        });
      } catch (InterruptedException ie) {
        InterruptedIOException iioe = new InterruptedIOException();
        iioe.initCause(ie);
        throw iioe;
      }
    }
  }

  transition(SplitTransactionPhase.AFTER_POST_SPLIT_HOOK);

  return regions;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:SplitTransactionImpl.java

示例15: getRowLock

import java.io.InterruptedIOException; //导入方法依赖的package包/类
/**
 * Get a row lock for the specified row. All locks are reentrant. Before calling this function
 * make sure that a region operation has already been started (the calling thread has already
 * acquired the region-close-guard lock).
 *
 * @param row      The row actions will be performed against
 * @param readLock is the lock reader or writer. True indicates that a non-exlcusive lock is
 *                 requested
 */
public RowLock getRowLock(byte[] row, boolean readLock) throws IOException {
  // Make sure the row is inside of this region before getting the lock for
  // it.
  checkRow(row, "row lock");
  // create an object to use a a key in the row lock map
  HashedBytes rowKey = new HashedBytes(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("HRegion.getRowLock");
    traceScope.getSpan()
        .addTimelineAnnotation("Getting a " + (readLock ? "readLock" : "writeLock"));
  }

  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;
      }

      // Now try an get the lock.
      //
      // This can fail as
      if (readLock) {
        result = rowLockContext.newReadLock();
      } else {
        result = rowLockContext.newWriteLock();
      }
    }
    if (!result.getLock().tryLock(this.rowLockWaitDuration, TimeUnit.MILLISECONDS)) {
      if (traceScope != null) {
        traceScope.getSpan().addTimelineAnnotation("Failed to get row lock");
      }
      result = null;
      // Clean up the counts just in case this was the thing keeping the
      // context alive.
      rowLockContext.cleanUp();
      throw new IOException("Timed out waiting for lock for row: " + rowKey);
    }
    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 {
    if (traceScope != null) {
      traceScope.close();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:79,代码来源:HRegion.java


注:本文中的java.io.InterruptedIOException.initCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。