Java Code Examples for org.apache.hadoop.fs.swift.exceptions.SwiftInternalStateException

The following examples show how to use org.apache.hadoop.fs.swift.exceptions.SwiftInternalStateException. These examples are extracted from open source projects. 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 Project: hadoop   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 2
Source Project: hadoop   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 
Example 3
Source Project: hadoop   Source File: SwiftNativeOutputStream.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source Project: big-c   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 5
Source Project: big-c   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 
Example 6
Source Project: big-c   Source File: SwiftNativeOutputStream.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 7
Source Project: sahara-extra   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 8
Source Project: sahara-extra   Source File: SwiftRestClient.java    License: Apache License 2.0 5 votes vote down vote up
private static <T> T checkNotNull(T reference, String message) throws
          SwiftInternalStateException {
  if (reference == null) {
    throw new SwiftInternalStateException(message);
  }
  return reference;
}
 
Example 9
Source Project: sahara-extra   Source File: SwiftNativeOutputStream.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source Project: hadoop   Source File: SwiftRestClient.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source Project: big-c   Source File: SwiftRestClient.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source Project: sahara-extra   Source File: SwiftRestClient.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source Project: hadoop   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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());
}
 
Example 14
Source Project: hadoop   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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");
}
 
Example 15
Source Project: big-c   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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());
}
 
Example 16
Source Project: big-c   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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");
}
 
Example 17
Source Project: sahara-extra   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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());
}
 
Example 18
Source Project: sahara-extra   Source File: SwiftRestClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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");
}