Search in sources :

Example 6 with SwiftException

use of org.apache.hadoop.fs.swift.exceptions.SwiftException in project hadoop by apache.

the class SwiftRestClient method pathToURI.

/**
   * Converts Swift path to URI to make request.
   * This is public for unit testing
   *
   * @param path path to object
   * @param endpointURI domain url e.g. http://domain.com
   * @return valid URI for object
   * @throws SwiftException
   */
public static URI pathToURI(SwiftObjectPath path, URI endpointURI) throws SwiftException {
    checkNotNull(endpointURI, "Null Endpoint -client is not authenticated");
    String dataLocationURI = endpointURI.toString();
    try {
        dataLocationURI = SwiftUtils.joinPaths(dataLocationURI, encodeUrl(path.toUriPath()));
        return new URI(dataLocationURI);
    } catch (URISyntaxException e) {
        throw new SwiftException("Failed to create URI from " + dataLocationURI, e);
    }
}
Also used : SwiftException(org.apache.hadoop.fs.swift.exceptions.SwiftException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 7 with SwiftException

use of org.apache.hadoop.fs.swift.exceptions.SwiftException in project hadoop by apache.

the class SwiftNativeOutputStream method newBackupFile.

private File newBackupFile() throws IOException {
    File dir = new File(conf.get("hadoop.tmp.dir"));
    if (!dir.mkdirs() && !dir.exists()) {
        throw new SwiftException("Cannot create Swift buffer directory: " + dir);
    }
    File result = File.createTempFile("output-", ".tmp", dir);
    result.deleteOnExit();
    return result;
}
Also used : SwiftException(org.apache.hadoop.fs.swift.exceptions.SwiftException) File(java.io.File)

Aggregations

SwiftException (org.apache.hadoop.fs.swift.exceptions.SwiftException)7 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)2 GetMethod (org.apache.commons.httpclient.methods.GetMethod)2 SwiftInternalStateException (org.apache.hadoop.fs.swift.exceptions.SwiftInternalStateException)2 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Header (org.apache.commons.httpclient.Header)1 Path (org.apache.hadoop.fs.Path)1 SwiftObjectPath (org.apache.hadoop.fs.swift.util.SwiftObjectPath)1