com.cloudera.hoop.fs
Class FSUtils

java.lang.Object
  extended by com.cloudera.hoop.fs.FSUtils

public class FSUtils
extends Object

File system utilities used by Hoop classes.


Field Summary
static String DEFAULT_PERMISSION
          Constant for the default permission string ('default').
 
Constructor Summary
FSUtils()
           
 
Method Summary
static org.apache.hadoop.fs.Path convertPathToHoop(org.apache.hadoop.fs.Path path, String hoopBaseUrl)
          Replaces the SCHEME://HOST:PORT of a Hadoop Path with the specified base URL.
static org.json.simple.JSONArray fileStatusToJSON(org.apache.hadoop.fs.FileStatus[] status, String hoopBaseUrl)
          Converts a Hadoop FileStatus array into a JSON array object.
static Map fileStatusToJSON(org.apache.hadoop.fs.FileStatus status, String hoopBaseUrl)
          Converts a Hadoop FileStatus object into a JSON array object.
static org.apache.hadoop.fs.permission.FsPermission getPermission(String str)
          Converts a Unix permission symbolic representation (i.e.
static org.json.simple.JSONObject toJSON(String name, Object value)
          Converts an object into a Json Map with with one key-value entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PERMISSION

public static final String DEFAULT_PERMISSION
Constant for the default permission string ('default').

See Also:
Constant Field Values
Constructor Detail

FSUtils

public FSUtils()
Method Detail

getPermission

public static org.apache.hadoop.fs.permission.FsPermission getPermission(String str)
Converts a Unix permission symbolic representation (i.e. -rwxr--r--) into a Hadoop permission.

Parameters:
str - Unix permission symbolic representation.
Returns:
the Hadoop permission. If the given string was 'default', it returns FsPermission.getDefault().

convertPathToHoop

public static org.apache.hadoop.fs.Path convertPathToHoop(org.apache.hadoop.fs.Path path,
                                                          String hoopBaseUrl)
Replaces the SCHEME://HOST:PORT of a Hadoop Path with the specified base URL.

Parameters:
path - Hadoop path to replace the SCHEME://HOST:PORT.
hoopBaseUrl - base URL to replace it with.
Returns:
the path using the given base URL.

fileStatusToJSON

public static Map fileStatusToJSON(org.apache.hadoop.fs.FileStatus status,
                                   String hoopBaseUrl)
Converts a Hadoop FileStatus object into a JSON array object. It replaces the SCHEME://HOST:PORT of the path with the specified URL.

Parameters:
status - Hadoop file status.
hoopBaseUrl - base URL to replace the SCHEME://HOST:PORT in the file status.
Returns:
The JSON representation of the file status.

fileStatusToJSON

public static org.json.simple.JSONArray fileStatusToJSON(org.apache.hadoop.fs.FileStatus[] status,
                                                         String hoopBaseUrl)
Converts a Hadoop FileStatus array into a JSON array object. It replaces the SCHEME://HOST:PORT of the path with the specified URL.

Parameters:
status - Hadoop file status array.
hoopBaseUrl - base URL to replace the SCHEME://HOST:PORT in the file status.
Returns:
The JSON representation of the file status array.

toJSON

public static org.json.simple.JSONObject toJSON(String name,
                                                Object value)
Converts an object into a Json Map with with one key-value entry.

It assumes the given value is either a JSON primitive type or a JsonAware instance.

Parameters:
name - name for the key of the entry.
value - for the value of the entry.
Returns:
the JSON representation of the key-value pair.


Copyright © 2012 Cloudera. All Rights Reserved.