public class HdfsFileObject extends AbstractFileObject<HdfsFileSystem>
DEFAULT_BUFFER_SIZE
EMPTY_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
HdfsFileObject(AbstractFileName name,
HdfsFileSystem fs,
org.apache.hadoop.fs.FileSystem hdfs,
org.apache.hadoop.fs.Path p)
Constructs a new HDFS FileObject
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRenameTo(FileObject newfile)
Queries the object if a simple rename to the file name of
newfile is possible. |
protected void |
doAttach()
Attaches this file object to its file resource.
|
protected void |
doCreateFolder()
Creates this file as a folder.
|
protected void |
doDelete()
Deletes the file.
|
protected Map<String,Object> |
doGetAttributes()
Returns the attributes of this file.
|
protected long |
doGetContentSize()
Returns the size of the file content (in bytes).
|
protected InputStream |
doGetInputStream(int bufferSize)
Creates an input stream to read the file content from.
|
protected long |
doGetLastModifiedTime()
Returns the last modified time of this file.
|
protected OutputStream |
doGetOutputStream(boolean append)
Creates an output stream to write the file content to.
|
protected RandomAccessContent |
doGetRandomAccessContent(RandomAccessMode mode)
Creates access to the file for random i/o.
|
protected FileType |
doGetType()
Determines the type of this file.
|
protected boolean |
doIsHidden()
Determines if this file is hidden.
|
protected boolean |
doIsReadable()
Determines if this file can be read.
|
protected boolean |
doIsWriteable()
Determines if this file can be written to.
|
protected String[] |
doListChildren()
Lists the children of this file.
|
protected FileObject[] |
doListChildrenResolved()
Lists the children of this file.
|
protected void |
doRemoveAttribute(String attrName)
Removes an attribute of this file.
|
protected void |
doRename(FileObject newfile)
Renames the file.
|
protected void |
doSetAttribute(String attrName,
Object value)
Sets an attribute of this file.
|
protected boolean |
doSetLastModifiedTime(long modtime)
Sets the last modified time of this file.
|
boolean |
exists()
Determines if the file exists.
|
childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doCreateFileContent, doDetach, doGetCertificates, doGetInputStream, doIsExecutable, doIsSameFile, doIsSymbolicLink, doSetExecutable, doSetReadable, doSetWritable, endOutput, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isSymbolicLink, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toString
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPath, getURI
forEach, spliterator
protected HdfsFileObject(AbstractFileName name, HdfsFileSystem fs, org.apache.hadoop.fs.FileSystem hdfs, org.apache.hadoop.fs.Path p)
name
- FileNamefs
- HdfsFileSystem instancehdfs
- Hadoop FileSystem instancep
- Path to the file in HDFSpublic boolean canRenameTo(FileObject newfile)
AbstractFileObject
newfile
is possible.canRenameTo
in interface FileObject
canRenameTo
in class AbstractFileObject<HdfsFileSystem>
newfile
- the new file nameAbstractFileObject.canRenameTo(org.apache.commons.vfs2.FileObject)
protected void doAttach() throws Exception
AbstractFileObject
This method is called before any of the doBlah() or onBlah() methods. Sub-classes can use this method to perform lazy initialization.
This implementation does nothing.
doAttach
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doAttach()
protected void doCreateFolder() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.IMAGINARY
.doCreateFolder
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doCreateFolder()
protected void doDelete() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.AbstractFileObject.doIsWriteable()
returns true.doDelete
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doDelete()
protected Map<String,Object> doGetAttributes() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return
FileType.IMAGINARY
.
This implementation always returns an empty map.
doGetAttributes
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetAttributes()
protected long doGetContentSize() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns
FileType.FILE
.doGetContentSize
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetContentSize()
protected InputStream doGetInputStream(int bufferSize) throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns
FileType.FILE
.
It is guaranteed that there are no open output streams for this file when this method is called.
The returned stream does not have to be buffered.
doGetInputStream
in class AbstractFileObject<HdfsFileSystem>
bufferSize
- Buffer size hint.Exception
- if an error occurs.AbstractFileObject.doGetInputStream(int)
protected long doGetLastModifiedTime() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return
This implementation throws an exception.
doGetLastModifiedTime
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetLastModifiedTime()
protected OutputStream doGetOutputStream(boolean append) throws Exception
AbstractFileObject
AbstractFileObject.doIsWriteable()
returns true.
AbstractFileObject.doGetType()
returns FileType.FILE
, or AbstractFileObject.doGetType()
returns FileType.IMAGINARY
,
and the file's parent exists and is a folder.
The returned stream does not have to be buffered.
This implementation throws an exception.
doGetOutputStream
in class AbstractFileObject<HdfsFileSystem>
append
- true if the file should be appended to, false if it should be overwritten.Exception
- if an error occurs.AbstractFileObject.doGetOutputStream(boolean)
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode) throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.FILE
.
It is guaranteed that there are no open output streams for this file when this method is called.
doGetRandomAccessContent
in class AbstractFileObject<HdfsFileSystem>
mode
- The mode to access the file.Exception
- if an error occurs.(org.apache.commons.vfs2.util.RandomAccessMode)
protected FileType doGetType() throws Exception
AbstractFileObject
doGetType
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetType()
protected boolean doIsHidden() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return
FileType.IMAGINARY
.
This implementation always returns false.
doIsHidden
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsHidden()
protected boolean doIsReadable() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return
FileType.IMAGINARY
.
This implementation always returns true.
doIsReadable
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsReadable()
protected boolean doIsWriteable() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return
FileType.IMAGINARY
.
This implementation always returns true.
doIsWriteable
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsWriteable()
protected String[] doListChildren() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.FOLDER
. The return
value of this method is cached, so the implementation can be expensive.doListChildren
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doListChildren()
protected FileObject[] doListChildrenResolved() throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
returns FileType.FOLDER
.
The return value of this method is cached, so the implementation can be expensive.
Other than doListChildren
you could return FileObject's to e.g. reinitialize the type of the file.
(Introduced for Webdav: "permission denied on resource" during getType())
doListChildrenResolved
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doListChildrenResolved()
protected void doRemoveAttribute(String attrName) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doRemoveAttribute
in class AbstractFileObject<HdfsFileSystem>
attrName
- The name of the attribute to remove.Exception
- if an error occurs.AbstractFileObject.doRemoveAttribute(java.lang.String)
protected void doRename(FileObject newfile) throws Exception
AbstractFileObject
Is only called when:
AbstractFileObject.doIsWriteable()
returns true.This implementation throws an exception.
doRename
in class AbstractFileObject<HdfsFileSystem>
newfile
- A FileObject with the new file name.Exception
- if an error occurs.AbstractFileObject.doRename(FileObject)
protected void doSetAttribute(String attrName, Object value) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doSetAttribute
in class AbstractFileObject<HdfsFileSystem>
attrName
- The attribute name.value
- The value to be associated with the attribute name.Exception
- if an error occurs.AbstractFileObject.doSetAttribute(java.lang.String, java.lang.Object)
protected boolean doSetLastModifiedTime(long modtime) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doSetLastModifiedTime
in class AbstractFileObject<HdfsFileSystem>
modtime
- The last modification time.Exception
- Any Exception thrown is wrapped in FileSystemException.AbstractFileObject.doSetLastModifiedTime(long)
public boolean exists() throws FileSystemException
AbstractFileObject
exists
in interface FileObject
exists
in class AbstractFileObject<HdfsFileSystem>
FileSystemException
- if an error occurs.AbstractFileObject.exists()
Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.