org.apache.hadoop.fs.FSExceptionMessages Java Examples

The following examples show how to use org.apache.hadoop.fs.FSExceptionMessages. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: COSInputStream.java    From stocator with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void seek(long targetPos) throws IOException {
  checkNotClosed();

  // Do not allow negative seek
  if (targetPos < 0) {
    throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK
        + " " + targetPos);
  }

  if (contentLength <= 0) {
    return;
  }

  // Lazy seek
  nextReadPos = targetPos;
}
 
Example #2
Source File: KeyOutputStream.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Verify that the output stream is open. Non blocking; this gives
 * the last state of the volatile {@link #closed} field.
 * @throws IOException if the connection is closed.
 */
private void checkNotClosed() throws IOException {
  if (closed) {
    throw new IOException(
        ": " + FSExceptionMessages.STREAM_IS_CLOSED + " Key: "
            + blockOutputStreamEntryPool.getKeyName());
  }
}
 
Example #3
Source File: KeyInputStream.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Verify that the input stream is open. Non blocking; this gives
 * the last state of the volatile {@link #closed} field.
 * @throws IOException if the connection is closed.
 */
private void checkOpen() throws IOException {
  if (closed) {
    throw new IOException(
        ": " + FSExceptionMessages.STREAM_IS_CLOSED + " Key: " + key);
  }
}
 
Example #4
Source File: StrictBufferedFSInputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void seek(long pos) throws IOException {
  if (pos < 0) {
    throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK);
  }
  if (in == null) {
    throw new SwiftConnectionClosedException(FSExceptionMessages.STREAM_IS_CLOSED);
  }
  super.seek(pos);
}
 
Example #5
Source File: NativeS3FileSystem.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void seek(long newpos) throws IOException {
  if (newpos < 0) {
    throw new EOFException(
        FSExceptionMessages.NEGATIVE_SEEK);
  }
  if (pos != newpos) {
    // the seek is attempting to move the current position
    reopen(newpos);
  }
}
 
Example #6
Source File: S3AInputStream.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private synchronized void reopen(long pos) throws IOException {

    if (wrappedStream != null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Aborting old stream to open at pos " + pos);
      }
      wrappedStream.abort();
    }

    if (pos < 0) {
      throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK
          +" " + pos);
    }

    if (contentLength > 0 && pos > contentLength-1) {
      throw new EOFException(
          FSExceptionMessages.CANNOT_SEEK_PAST_EOF
          + " " + pos);
    }

    LOG.debug("Actually opening file " + key + " at pos " + pos);

    GetObjectRequest request = new GetObjectRequest(bucket, key);
    request.setRange(pos, contentLength-1);

    wrappedStream = client.getObject(request).getObjectContent();

    if (wrappedStream == null) {
      throw new IOException("Null IO stream");
    }

    this.pos = pos;
  }
 
Example #7
Source File: StrictBufferedFSInputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void seek(long pos) throws IOException {
  if (pos < 0) {
    throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK);
  }
  if (in == null) {
    throw new SwiftConnectionClosedException(FSExceptionMessages.STREAM_IS_CLOSED);
  }
  super.seek(pos);
}
 
Example #8
Source File: NativeS3FileSystem.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void seek(long newpos) throws IOException {
  if (newpos < 0) {
    throw new EOFException(
        FSExceptionMessages.NEGATIVE_SEEK);
  }
  if (pos != newpos) {
    // the seek is attempting to move the current position
    reopen(newpos);
  }
}
 
Example #9
Source File: S3AInputStream.java    From big-c with Apache License 2.0 5 votes vote down vote up
private synchronized void reopen(long pos) throws IOException {

    if (wrappedStream != null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Aborting old stream to open at pos " + pos);
      }
      wrappedStream.abort();
    }

    if (pos < 0) {
      throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK
          +" " + pos);
    }

    if (contentLength > 0 && pos > contentLength-1) {
      throw new EOFException(
          FSExceptionMessages.CANNOT_SEEK_PAST_EOF
          + " " + pos);
    }

    LOG.debug("Actually opening file " + key + " at pos " + pos);

    GetObjectRequest request = new GetObjectRequest(bucket, key);
    request.setRange(pos, contentLength-1);

    wrappedStream = client.getObject(request).getObjectContent();

    if (wrappedStream == null) {
      throw new IOException("Null IO stream");
    }

    this.pos = pos;
  }
 
Example #10
Source File: SwiftNativeInputStream.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Seek to an offset. If the data is already in the buffer, move to it
 * @param targetPos target position
 * @throws IOException on any problem
 */
@Override
public synchronized void seek(long targetPos) throws IOException {
  if (targetPos < 0) {
    throw new EOFException(
        FSExceptionMessages.NEGATIVE_SEEK);
  }
  //there's some special handling of near-local data
  //as the seek can be omitted if it is in/adjacent
  long offset = targetPos - pos;
  if (LOG.isDebugEnabled()) {
    LOG.debug("Seek to " + targetPos + "; current pos =" + pos
              + "; offset="+offset);
  }
  if (offset == 0) {
    LOG.debug("seek is no-op");
    return;
  }

  if (offset < 0) {
    LOG.debug("seek is backwards");
  } else if ((rangeOffset + offset < bufferSize)) {
    //if the seek is in  range of that requested, scan forwards
    //instead of closing and re-opening a new HTTP connection
    SwiftUtils.debug(LOG,
                     "seek is within current stream"
                     + "; pos= %d ; targetPos=%d; "
                     + "offset= %d ; bufferOffset=%d",
                     pos, targetPos, offset, rangeOffset);
    try {
      LOG.debug("chomping ");
      chompBytes(offset);
    } catch (IOException e) {
      //this is assumed to be recoverable with a seek -or more likely to fail
      LOG.debug("while chomping ",e);
    }
    if (targetPos - pos == 0) {
      LOG.trace("chomping successful");
      return;
    }
    LOG.trace("chomping failed");
  } else {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Seek is beyond buffer size of " + bufferSize);
    }
  }

  innerClose("seeking to " + targetPos);
  fillBuffer(targetPos);
}
 
Example #11
Source File: S3AInputStream.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void checkNotClosed() throws IOException {
  if (closed) {
    throw new IOException(FSExceptionMessages.STREAM_IS_CLOSED);
  }
}
 
Example #12
Source File: SwiftNativeInputStream.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Seek to an offset. If the data is already in the buffer, move to it
 * @param targetPos target position
 * @throws IOException on any problem
 */
@Override
public synchronized void seek(long targetPos) throws IOException {
  if (targetPos < 0) {
    throw new EOFException(
        FSExceptionMessages.NEGATIVE_SEEK);
  }
  //there's some special handling of near-local data
  //as the seek can be omitted if it is in/adjacent
  long offset = targetPos - pos;
  if (LOG.isDebugEnabled()) {
    LOG.debug("Seek to " + targetPos + "; current pos =" + pos
              + "; offset="+offset);
  }
  if (offset == 0) {
    LOG.debug("seek is no-op");
    return;
  }

  if (offset < 0) {
    LOG.debug("seek is backwards");
  } else if ((rangeOffset + offset < bufferSize)) {
    //if the seek is in  range of that requested, scan forwards
    //instead of closing and re-opening a new HTTP connection
    SwiftUtils.debug(LOG,
                     "seek is within current stream"
                     + "; pos= %d ; targetPos=%d; "
                     + "offset= %d ; bufferOffset=%d",
                     pos, targetPos, offset, rangeOffset);
    try {
      LOG.debug("chomping ");
      chompBytes(offset);
    } catch (IOException e) {
      //this is assumed to be recoverable with a seek -or more likely to fail
      LOG.debug("while chomping ",e);
    }
    if (targetPos - pos == 0) {
      LOG.trace("chomping successful");
      return;
    }
    LOG.trace("chomping failed");
  } else {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Seek is beyond buffer size of " + bufferSize);
    }
  }

  innerClose("seeking to " + targetPos);
  fillBuffer(targetPos);
}
 
Example #13
Source File: S3AInputStream.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void checkNotClosed() throws IOException {
  if (closed) {
    throw new IOException(FSExceptionMessages.STREAM_IS_CLOSED);
  }
}
 
Example #14
Source File: COSInputStream.java    From stocator with Apache License 2.0 4 votes vote down vote up
/**
 * Verify that the input stream is open. Non blocking; this gives
 * the last state of the volatile {@link #closed} field.
 * @throws IOException if the connection is closed
 */
private void checkNotClosed() throws IOException {
  if (closed) {
    throw new IOException(uri + ": " + FSExceptionMessages.STREAM_IS_CLOSED);
  }
}