public class HdfsResource extends AbstractResource implements Serializable
Resource implementation that connects to Apache Hadoop's HDFS
distributed file system.| Constructor and Description |
|---|
HdfsResource(String url)
Creates a
HdfsResource |
HdfsResource(String hostname,
int port,
String filepath)
Creates a
HdfsResource |
| Modifier and Type | Method and Description |
|---|---|
OutputStream |
append()
Opens up an
OutputStream to append to the resource. |
boolean |
equals(Object obj) |
String |
getFilepath() |
org.apache.hadoop.conf.Configuration |
getHadoopConfiguration() |
org.apache.hadoop.fs.FileSystem |
getHadoopFileSystem() |
org.apache.hadoop.fs.Path |
getHadoopPath() |
String |
getHostname() |
long |
getLastModified()
Gets the last modified timestamp value (measured in milliseconds since
the epoch (00:00:00 GMT, January 1, 1970)) of the resource, if available.
|
String |
getName()
Gets the name of the resource, typically a filename or other identifying
string
|
int |
getPort() |
String |
getQualifiedPath()
Gets the qualified path of the resource, which typically includes slash
or backslash separated nodes in a hierarical tree structure.
|
long |
getSize()
Gets the size (in number of bytes) of this resource's data.
|
int |
hashCode() |
boolean |
isExists()
Determines if the resource referenced by this object exists or not.
|
boolean |
isReadOnly()
Determines if the file is read only, or if writes are also possible.
|
InputStream |
read()
Opens up an
InputStream to read from the resource. |
OutputStream |
write()
Opens up an
OutputStream to write to the resource. |
public HdfsResource(String url)
HdfsResourceurl - a URL of the form: hdfs://hostname:port/path/to/filepublic HdfsResource(String hostname, int port, String filepath)
HdfsResourcehostname - the HDFS (namenode) hostnameport - the HDFS (namenode) port numberfilepath - the path on HDFS to the file, starting with slash ('/')public String getFilepath()
public String getHostname()
public int getPort()
public String getName()
Resourcepublic String getQualifiedPath()
ResourcegetQualifiedPath in interface Resourcepublic boolean isReadOnly()
ResourceisReadOnly in interface Resourcepublic boolean isExists()
Resourcepublic long getSize()
Resourcepublic long getLastModified()
ResourcegetLastModified in interface Resourcepublic OutputStream write() throws ResourceException
ResourceOutputStream to write to the resource. Consumers of
this method are expected to invoke the OutputStream.close()
method manually.
If possible, the other write(...) method is preferred over this one,
since it guarantees proper closing of the resource's handles.write in interface ResourceResourceExceptionpublic OutputStream append() throws ResourceException
ResourceOutputStream to append to the resource. Consumers of
this method are expected to invoke the OutputStream.close()
method manually.
If possible, the other append(...) method is preferred over this one,
since it guarantees proper closing of the resource's handles.append in interface ResourceResourceExceptionpublic InputStream read() throws ResourceException
ResourceInputStream to read from the resource. Consumers of
this method are expected to invoke the InputStream.close() method
manually.
If possible, the other read(...) methods are preferred over this one,
since they guarantee proper closing of the resource's handles.read in interface ResourceResourceExceptionpublic org.apache.hadoop.conf.Configuration getHadoopConfiguration()
public org.apache.hadoop.fs.FileSystem getHadoopFileSystem()
public org.apache.hadoop.fs.Path getHadoopPath()
Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.