类org.apache.hadoop.fs.swift.exceptions.SwiftInternalStateException源码实例Demo

下面列出了怎么用org.apache.hadoop.fs.swift.exceptions.SwiftInternalStateException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop   文件: SwiftRestClient.java

/**
 * Add the headers to the method, and the auth token (which must be set
 * @param method method to update
 * @param requestHeaders the list of headers
 * @throws SwiftInternalStateException not yet authenticated
 */
private void setHeaders(HttpMethodBase method, Header[] requestHeaders)
    throws SwiftInternalStateException {
    for (Header header : requestHeaders) {
      method.addRequestHeader(header);
    }
  setAuthToken(method, getToken());
}
 
源代码2 项目: hadoop   文件: SwiftRestClient.java

private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 
源代码3 项目: hadoop   文件: SwiftNativeOutputStream.java

@Override
public synchronized void write(byte[] buffer, int offset, int len) throws
                                                                   IOException {
  //validate args
  if (offset < 0 || len < 0 || (offset + len) > buffer.length) {
    throw new IndexOutOfBoundsException("Invalid offset/length for write");
  }
  //validate the output stream
  verifyOpen();
  SwiftUtils.debug(LOG, " write(offset=%d, len=%d)", offset, len);

  // if the size of file is greater than the partition limit
  while (blockOffset + len >= filePartSize) {
    // - then partition the blob and upload as many partitions
    // are needed.
    //how many bytes to write for this partition.
    int subWriteLen = (int) (filePartSize - blockOffset);
    if (subWriteLen < 0 || subWriteLen > len) {
      throw new SwiftInternalStateException("Invalid subwrite len: "
                                            + subWriteLen
                                            + " -buffer len: " + len);
    }
    writeToBackupStream(buffer, offset, subWriteLen);
    //move the offset along and length down
    offset += subWriteLen;
    len -= subWriteLen;
    //now upload the partition that has just been filled up
    // (this also sets blockOffset=0)
    partUpload(false);
  }
  //any remaining data is now written
  writeToBackupStream(buffer, offset, len);
}
 
源代码4 项目: big-c   文件: SwiftRestClient.java

/**
 * Add the headers to the method, and the auth token (which must be set
 * @param method method to update
 * @param requestHeaders the list of headers
 * @throws SwiftInternalStateException not yet authenticated
 */
private void setHeaders(HttpMethodBase method, Header[] requestHeaders)
    throws SwiftInternalStateException {
    for (Header header : requestHeaders) {
      method.addRequestHeader(header);
    }
  setAuthToken(method, getToken());
}
 
源代码5 项目: big-c   文件: SwiftRestClient.java

private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 
源代码6 项目: big-c   文件: SwiftNativeOutputStream.java

@Override
public synchronized void write(byte[] buffer, int offset, int len) throws
                                                                   IOException {
  //validate args
  if (offset < 0 || len < 0 || (offset + len) > buffer.length) {
    throw new IndexOutOfBoundsException("Invalid offset/length for write");
  }
  //validate the output stream
  verifyOpen();
  SwiftUtils.debug(LOG, " write(offset=%d, len=%d)", offset, len);

  // if the size of file is greater than the partition limit
  while (blockOffset + len >= filePartSize) {
    // - then partition the blob and upload as many partitions
    // are needed.
    //how many bytes to write for this partition.
    int subWriteLen = (int) (filePartSize - blockOffset);
    if (subWriteLen < 0 || subWriteLen > len) {
      throw new SwiftInternalStateException("Invalid subwrite len: "
                                            + subWriteLen
                                            + " -buffer len: " + len);
    }
    writeToBackupStream(buffer, offset, subWriteLen);
    //move the offset along and length down
    offset += subWriteLen;
    len -= subWriteLen;
    //now upload the partition that has just been filled up
    // (this also sets blockOffset=0)
    partUpload(false);
  }
  //any remaining data is now written
  writeToBackupStream(buffer, offset, len);
}
 
源代码7 项目: sahara-extra   文件: SwiftRestClient.java

/**
 * Add the headers to the method, and the auth token (which must be set
 * @param method method to update
 * @param requestHeaders the list of headers
 * @throws SwiftInternalStateException not yet authenticated
 */
private void setHeaders(HttpMethodBase method, Header[] requestHeaders)
    throws SwiftInternalStateException {
    for (Header header : requestHeaders) {
      method.addRequestHeader(header);
    }
  setAuthToken(method, getToken());
}
 
源代码8 项目: sahara-extra   文件: SwiftRestClient.java

private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 

@Override
public synchronized void write(byte[] buffer, int offset, int len) throws
                                                                   IOException {
  //validate args
  if (offset < 0 || len < 0 || (offset + len) > buffer.length) {
    throw new IndexOutOfBoundsException("Invalid offset/length for write");
  }
  //validate the output stream
  verifyOpen();
  SwiftUtils.debug(LOG, " write(offset=%d, len=%d)", offset, len);

  // if the size of file is greater than the partition limit
  while (blockOffset + len >= filePartSize) {
    // - then partition the blob and upload as many partitions
    // are needed.
    //how many bytes to write for this partition.
    int subWriteLen = (int) (filePartSize - blockOffset);
    if (subWriteLen < 0 || subWriteLen > len) {
      throw new SwiftInternalStateException("Invalid subwrite len: "
                                            + subWriteLen
                                            + " -buffer len: " + len);
    }
    writeToBackupStream(buffer, offset, subWriteLen);
    //move the offset along and length down
    offset += subWriteLen;
    len -= subWriteLen;
    //now upload the partition that has just been filled up
    // (this also sets blockOffset=0)
    partUpload(false);
  }
  //any remaining data is now written
  writeToBackupStream(buffer, offset, len);
}
 
源代码10 项目: hadoop   文件: SwiftRestClient.java

/**
 * Performs the HTTP request, validates the response code and returns
 * the received data. HTTP Status codes are converted into exceptions.
 *
 * @param uri URI to source
 * @param processor HttpMethodProcessor
 * @param <M> method
 * @param <R> result type
 * @return result of HTTP request
 * @throws IOException IO problems
 * @throws SwiftBadRequestException the status code indicated "Bad request"
 * @throws SwiftInvalidResponseException the status code is out of range
 * for the action (excluding 404 responses)
 * @throws SwiftInternalStateException the internal state of this client
 * is invalid
 * @throws FileNotFoundException a 404 response was returned
 */
private <M extends HttpMethod, R> R perform(URI uri,
                    HttpMethodProcessor<M, R> processor)
  throws IOException,
         SwiftBadRequestException,
         SwiftInternalStateException,
         SwiftInvalidResponseException,
         FileNotFoundException {
  return perform("",uri, processor);
}
 
源代码11 项目: big-c   文件: SwiftRestClient.java

/**
 * Performs the HTTP request, validates the response code and returns
 * the received data. HTTP Status codes are converted into exceptions.
 *
 * @param uri URI to source
 * @param processor HttpMethodProcessor
 * @param <M> method
 * @param <R> result type
 * @return result of HTTP request
 * @throws IOException IO problems
 * @throws SwiftBadRequestException the status code indicated "Bad request"
 * @throws SwiftInvalidResponseException the status code is out of range
 * for the action (excluding 404 responses)
 * @throws SwiftInternalStateException the internal state of this client
 * is invalid
 * @throws FileNotFoundException a 404 response was returned
 */
private <M extends HttpMethod, R> R perform(URI uri,
                    HttpMethodProcessor<M, R> processor)
  throws IOException,
         SwiftBadRequestException,
         SwiftInternalStateException,
         SwiftInvalidResponseException,
         FileNotFoundException {
  return perform("",uri, processor);
}
 
源代码12 项目: sahara-extra   文件: SwiftRestClient.java

/**
 * Performs the HTTP request, validates the response code and returns
 * the received data. HTTP Status codes are converted into exceptions.
 *
 * @param uri URI to source
 * @param processor HttpMethodProcessor
 * @param <M> method
 * @param <R> result type
 * @return result of HTTP request
 * @throws IOException IO problems
 * @throws SwiftBadRequestException the status code indicated "Bad request"
 * @throws SwiftInvalidResponseException the status code is out of range
 * for the action (excluding 404 responses)
 * @throws SwiftInternalStateException the internal state of this client
 * is invalid
 * @throws FileNotFoundException a 404 response was returned
 */
private <M extends HttpMethod, R> R perform(URI uri,
                    HttpMethodProcessor<M, R> processor)
  throws IOException,
         SwiftBadRequestException,
         SwiftInternalStateException,
         SwiftInvalidResponseException,
         FileNotFoundException {
  return perform("",uri, processor);
}
 
源代码13 项目: hadoop   文件: SwiftRestClient.java

/**
 * Set the auth key header of the method to the token ID supplied
 *
 * @param method method
 * @param accessToken access token
 * @throws SwiftInternalStateException if the client is not yet authenticated
 */
private void setAuthToken(HttpMethodBase method, AccessToken accessToken)
    throws SwiftInternalStateException {
  checkNotNull(accessToken,"Not authenticated");
  method.addRequestHeader(HEADER_AUTH_KEY, accessToken.getId());
}
 
源代码14 项目: hadoop   文件: SwiftRestClient.java

/**
 * Ensures that an object reference passed as a parameter to the calling
 * method is not null.
 *
 * @param reference an object reference
 * @return the non-null reference that was validated
 * @throws NullPointerException if {@code reference} is null
 */
private static <T> T checkNotNull(T reference) throws
          SwiftInternalStateException {
  return checkNotNull(reference, "Null Reference");
}
 
源代码15 项目: big-c   文件: SwiftRestClient.java

/**
 * Set the auth key header of the method to the token ID supplied
 *
 * @param method method
 * @param accessToken access token
 * @throws SwiftInternalStateException if the client is not yet authenticated
 */
private void setAuthToken(HttpMethodBase method, AccessToken accessToken)
    throws SwiftInternalStateException {
  checkNotNull(accessToken,"Not authenticated");
  method.addRequestHeader(HEADER_AUTH_KEY, accessToken.getId());
}
 
源代码16 项目: big-c   文件: SwiftRestClient.java

/**
 * Ensures that an object reference passed as a parameter to the calling
 * method is not null.
 *
 * @param reference an object reference
 * @return the non-null reference that was validated
 * @throws NullPointerException if {@code reference} is null
 */
private static <T> T checkNotNull(T reference) throws
          SwiftInternalStateException {
  return checkNotNull(reference, "Null Reference");
}
 
源代码17 项目: sahara-extra   文件: SwiftRestClient.java

/**
 * Set the auth key header of the method to the token ID supplied
 *
 * @param method method
 * @param accessToken access token
 * @throws SwiftInternalStateException if the client is not yet authenticated
 */
private void setAuthToken(HttpMethod method, AccessToken accessToken)
    throws SwiftInternalStateException {
  checkNotNull(accessToken,"Not authenticated");
  method.setRequestHeader(HEADER_AUTH_KEY, accessToken.getId());
}
 
源代码18 项目: sahara-extra   文件: SwiftRestClient.java

/**
 * Ensures that an object reference passed as a parameter to the calling
 * method is not null.
 *
 * @param reference an object reference
 * @return the non-null reference that was validated
 * @throws NullPointerException if {@code reference} is null
 */
private static <T> T checkNotNull(T reference) throws
          SwiftInternalStateException {
  return checkNotNull(reference, "Null Reference");
}
 
 类所在包
 同包方法