Package com.ceph.fs
Class CephMount
- java.lang.Object
-
- com.ceph.fs.CephMount
-
public class CephMount extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intLOCK_EXstatic intLOCK_NBstatic intLOCK_SHstatic intLOCK_UNstatic intO_APPENDstatic intO_CREATstatic intO_DIRECTORYstatic intO_EXCLstatic intO_RDONLYstatic intO_RDWRstatic intO_TRUNCstatic intO_WRONLYstatic intSEEK_CURstatic intSEEK_ENDstatic intSEEK_SETstatic intSETATTR_ATIMEstatic intSETATTR_GIDstatic intSETATTR_MODEstatic intSETATTR_MTIMEstatic intSETATTR_UIDstatic intXATTR_CREATEstatic intXATTR_NONEstatic intXATTR_REPLACE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchdir(java.lang.String path)Set the current working directory.voidchmod(java.lang.String path, int mode)Change file mode.voidclose(int fd)Close an open file.java.lang.Stringconf_get(java.lang.String option)Get the value of a configuration option.voidconf_read_file(java.lang.String path)Load configuration from a file.voidconf_set(java.lang.String option, java.lang.String value)Set the value of a configuration option.voidfchmod(int fd, int mode)Change file mode of an open file.protected voidfinalize()voidflock(int fd, int operation, long owner)Apply or remove an advisory lock.voidfstat(int fd, CephStat stat)Get file status.voidfsync(int fd, boolean dataonly)Synchronize a file with the file system.voidftruncate(int fd, long size)Truncate a file.java.lang.Stringget_default_data_pool_name()Get the default data pool of cephfs.CephFileExtentget_file_extent(int fd, long offset)Get file extent containing a given offset.java.lang.Stringget_file_pool_name(int fd)Get the name of the pool a file is stored in.intget_file_replication(int fd)Get the replication of a file.intget_file_stripe_unit(int fd)Get the stripe unit of a file.java.net.InetAddressget_osd_address(int osd)Get the network address of an OSD.Bucket[]get_osd_crush_location(int osd)Get the fully qualified CRUSH location of an OSD.intget_pool_id(java.lang.String name)Get the pool id for the named pool.intget_pool_replication(int pool_id)Get the pool replication factor.intget_stripe_unit_granularity()Get file layout stripe unit granularity.java.lang.Stringgetcwd()Get the current working directory.longgetxattr(java.lang.String path, java.lang.String name, byte[] buf)Get an extended attribute value.longlgetxattr(java.lang.String path, java.lang.String name, byte[] buf)Get an extended attribute value of a symbolic link.voidlink(java.lang.String oldpath, java.lang.String newpath)Create a hard link to an existing file.java.lang.String[]listdir(java.lang.String dir)List the contents of a directory.java.lang.String[]listxattr(java.lang.String path)List extended attributes.java.lang.String[]llistxattr(java.lang.String path)List extended attributes of a symbolic link.voidlocalize_reads(boolean state)Favor reading from local replicas when possible.voidlremovexattr(java.lang.String path, java.lang.String name)Remove an extended attribute from a symbolic link.longlseek(int fd, long offset, int whence)Seek to a position in a file.voidlsetxattr(java.lang.String path, java.lang.String name, byte[] buf, long size, int flags)Set the value of an extended attribute on a symbolic link.voidlstat(java.lang.String path, CephStat stat)Get file status, without following symlinks.voidmkdir(java.lang.String path, int mode)Create a directory.voidmkdirs(java.lang.String path, int mode)Create a directory and all parents.voidmount(java.lang.String root)Activate the mount with a given root path.intopen(java.lang.String path, int flags, int mode)Open a file.intopen(java.lang.String path, int flags, int mode, int stripe_unit, int stripe_count, int object_size, java.lang.String data_pool)Open a file with a specific file layout.longread(int fd, byte[] buf, long size, long offset)Read from a file.java.lang.Stringreadlink(java.lang.String path)Read the value of a symbolic link.voidremovexattr(java.lang.String path, java.lang.String name)Remove an extended attribute.voidrename(java.lang.String from, java.lang.String to)Rename a file or directory.voidrmdir(java.lang.String path)Delete a directory.voidsetattr(java.lang.String path, CephStat stat, int mask)Set file attributes.voidsetxattr(java.lang.String path, java.lang.String name, byte[] buf, long size, int flags)Set the value of an extended attribute.voidstat(java.lang.String path, CephStat stat)Get file status.voidstatfs(java.lang.String path, CephStatVFS statvfs)Get file system status.voidsymlink(java.lang.String oldpath, java.lang.String newpath)Create a symbolic link.voidsync_fs()Synchronize the client with the file system.voidtruncate(java.lang.String path, long size)Truncate a file to a specified length.voidunlink(java.lang.String path)Unlink/delete a name from the file system.voidunmount()Deactivate the mount.longwrite(int fd, byte[] buf, long size, long offset)Write to a file at a specific offset.
-
-
-
Field Detail
-
O_RDONLY
public static final int O_RDONLY
- See Also:
- Constant Field Values
-
O_RDWR
public static final int O_RDWR
- See Also:
- Constant Field Values
-
O_APPEND
public static final int O_APPEND
- See Also:
- Constant Field Values
-
O_CREAT
public static final int O_CREAT
- See Also:
- Constant Field Values
-
O_TRUNC
public static final int O_TRUNC
- See Also:
- Constant Field Values
-
O_EXCL
public static final int O_EXCL
- See Also:
- Constant Field Values
-
O_WRONLY
public static final int O_WRONLY
- See Also:
- Constant Field Values
-
O_DIRECTORY
public static final int O_DIRECTORY
- See Also:
- Constant Field Values
-
SEEK_SET
public static final int SEEK_SET
- See Also:
- Constant Field Values
-
SEEK_CUR
public static final int SEEK_CUR
- See Also:
- Constant Field Values
-
SEEK_END
public static final int SEEK_END
- See Also:
- Constant Field Values
-
SETATTR_MODE
public static final int SETATTR_MODE
- See Also:
- Constant Field Values
-
SETATTR_UID
public static final int SETATTR_UID
- See Also:
- Constant Field Values
-
SETATTR_GID
public static final int SETATTR_GID
- See Also:
- Constant Field Values
-
SETATTR_MTIME
public static final int SETATTR_MTIME
- See Also:
- Constant Field Values
-
SETATTR_ATIME
public static final int SETATTR_ATIME
- See Also:
- Constant Field Values
-
XATTR_CREATE
public static final int XATTR_CREATE
- See Also:
- Constant Field Values
-
XATTR_REPLACE
public static final int XATTR_REPLACE
- See Also:
- Constant Field Values
-
XATTR_NONE
public static final int XATTR_NONE
- See Also:
- Constant Field Values
-
LOCK_SH
public static final int LOCK_SH
- See Also:
- Constant Field Values
-
LOCK_EX
public static final int LOCK_EX
- See Also:
- Constant Field Values
-
LOCK_NB
public static final int LOCK_NB
- See Also:
- Constant Field Values
-
LOCK_UN
public static final int LOCK_UN
- See Also:
- Constant Field Values
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
mount
public void mount(java.lang.String root)
Activate the mount with a given root path.- Parameters:
root- The path to use as the root (pass null for "/").
-
unmount
public void unmount()
Deactivate the mount. The mount can be reactivated using mount(). Configuration parameters previously set are not reset.
-
conf_read_file
public void conf_read_file(java.lang.String path) throws java.io.FileNotFoundExceptionLoad configuration from a file.- Parameters:
path- The path to the configuration file.- Throws:
java.io.FileNotFoundException
-
conf_set
public void conf_set(java.lang.String option, java.lang.String value)Set the value of a configuration option.- Parameters:
option- The configuration option to modify.value- The new value of the option.
-
conf_get
public java.lang.String conf_get(java.lang.String option)
Get the value of a configuration option.- Parameters:
option- The name of the configuration option.- Returns:
- The value of the option or null if option not found
-
statfs
public void statfs(java.lang.String path, CephStatVFS statvfs) throws java.io.FileNotFoundExceptionGet file system status.- Parameters:
path- Path to file in file system.statvfs- CephStatVFS structure to hold status.- Throws:
java.io.FileNotFoundException
-
getcwd
public java.lang.String getcwd()
Get the current working directory.- Returns:
- The current working directory in Ceph.
-
chdir
public void chdir(java.lang.String path) throws java.io.FileNotFoundExceptionSet the current working directory.- Parameters:
path- The directory set as the cwd.- Throws:
java.io.FileNotFoundException
-
listdir
public java.lang.String[] listdir(java.lang.String dir) throws java.io.FileNotFoundExceptionList the contents of a directory.- Parameters:
dir- The directory.- Returns:
- List of files and directories excluding "." and "..".
- Throws:
java.io.FileNotFoundException
-
link
public void link(java.lang.String oldpath, java.lang.String newpath) throws java.io.FileNotFoundExceptionCreate a hard link to an existing file.- Parameters:
oldpath- The target path of the link.newpath- The name of the link.- Throws:
java.io.FileNotFoundException
-
unlink
public void unlink(java.lang.String path) throws java.io.FileNotFoundExceptionUnlink/delete a name from the file system.- Parameters:
path- The name to unlink/delete.- Throws:
java.io.FileNotFoundException
-
rename
public void rename(java.lang.String from, java.lang.String to) throws java.io.FileNotFoundExceptionRename a file or directory.- Parameters:
from- The current path.to- The new path.- Throws:
java.io.FileNotFoundException
-
mkdir
public void mkdir(java.lang.String path, int mode)Create a directory.- Parameters:
path- The directory to create.mode- The mode of the new directory.
-
mkdirs
public void mkdirs(java.lang.String path, int mode) throws java.io.IOExceptionCreate a directory and all parents.- Parameters:
path- The directory to create.mode- The mode of the new directory.- Throws:
java.io.IOException
-
rmdir
public void rmdir(java.lang.String path) throws java.io.FileNotFoundExceptionDelete a directory.- Parameters:
path- The directory to delete.- Throws:
java.io.FileNotFoundException
-
readlink
public java.lang.String readlink(java.lang.String path) throws java.io.FileNotFoundExceptionRead the value of a symbolic link.- Throws:
java.io.FileNotFoundException
-
symlink
public void symlink(java.lang.String oldpath, java.lang.String newpath)Create a symbolic link.- Parameters:
oldpath- Target of the symbolic link.newpath- Name of the link.
-
stat
public void stat(java.lang.String path, CephStat stat) throws java.io.FileNotFoundException, CephNotDirectoryExceptionGet file status.- Parameters:
path- Path of file to stat.stat- CephStat structure to hold file status.- Throws:
java.io.FileNotFoundExceptionCephNotDirectoryException
-
lstat
public void lstat(java.lang.String path, CephStat stat) throws java.io.FileNotFoundException, CephNotDirectoryExceptionGet file status, without following symlinks.- Parameters:
path- Path of file to stat.stat- CephStat structure to hold file status.- Throws:
java.io.FileNotFoundExceptionCephNotDirectoryException
-
setattr
public void setattr(java.lang.String path, CephStat stat, int mask) throws java.io.FileNotFoundExceptionSet file attributes.- Parameters:
path- Path to file.stat- CephStat structure holding attributes.mask- Mask specifying which attributes to set.- Throws:
java.io.FileNotFoundException
-
chmod
public void chmod(java.lang.String path, int mode) throws java.io.FileNotFoundExceptionChange file mode.- Parameters:
path- Path to file.mode- New mode bits.- Throws:
java.io.FileNotFoundException
-
fchmod
public void fchmod(int fd, int mode)Change file mode of an open file.- Parameters:
fd- The open file descriptor to change the mode bits on.mode- New mode bits.
-
truncate
public void truncate(java.lang.String path, long size) throws java.io.FileNotFoundExceptionTruncate a file to a specified length.- Parameters:
path- Path of the file.size- New file length.- Throws:
java.io.FileNotFoundException
-
open
public int open(java.lang.String path, int flags, int mode) throws java.io.FileNotFoundExceptionOpen a file.- Parameters:
path- Path of file to open or create.flags- Open flags.mode- Permission mode.- Returns:
- File descriptor.
- Throws:
java.io.FileNotFoundException
-
open
public int open(java.lang.String path, int flags, int mode, int stripe_unit, int stripe_count, int object_size, java.lang.String data_pool) throws java.io.FileNotFoundExceptionOpen a file with a specific file layout.- Parameters:
path- Path of file to open or create.flags- Open flags.mode- Permission mode.stripe_unit- File layout stripe unit size.stripe_count- File layout stripe count.object_size- Size of each object.data_pool- The target data pool.- Returns:
- File descriptor.
- Throws:
java.io.FileNotFoundException
-
close
public void close(int fd)
Close an open file.- Parameters:
fd- The file descriptor.
-
lseek
public long lseek(int fd, long offset, int whence)Seek to a position in a file.- Parameters:
fd- File descriptor.offset- New offset.whence- Whence value.- Returns:
- The new offset.
-
read
public long read(int fd, byte[] buf, long size, long offset)Read from a file.- Parameters:
fd- The file descriptor.buf- Buffer to for data read.size- Amount of data to read into the buffer.offset- Offset to read from (-1 for current position).- Returns:
- The number of bytes read.
-
write
public long write(int fd, byte[] buf, long size, long offset)Write to a file at a specific offset.- Parameters:
fd- The file descriptor.buf- Buffer to write.size- Amount of data to write.offset- Offset to write from (-1 for current position).- Returns:
- The number of bytes written.
-
ftruncate
public void ftruncate(int fd, long size)Truncate a file.- Parameters:
fd- File descriptor of the file to truncate.size- New file size.
-
fsync
public void fsync(int fd, boolean dataonly)Synchronize a file with the file system.- Parameters:
fd- File descriptor to synchronize.dataonly- Synchronize only data.
-
flock
public void flock(int fd, int operation, long owner) throws java.io.IOExceptionApply or remove an advisory lock.- Parameters:
fd- File descriptor to lock or unlock.operation- the advisory lock operation to be performed on the file descriptor among LOCK_SH (shared lock), LOCK_EX (exclusive lock), or LOCK_UN (remove lock). The LOCK_NB value can be ORed to perform a non-blocking operation.owner- the user-supplied owner identifier (an arbitrary integer)- Throws:
java.io.IOException
-
fstat
public void fstat(int fd, CephStat stat)Get file status.- Parameters:
fd- The file descriptor.stat- The object in which to store the status.
-
sync_fs
public void sync_fs()
Synchronize the client with the file system.
-
getxattr
public long getxattr(java.lang.String path, java.lang.String name, byte[] buf) throws java.io.FileNotFoundExceptionGet an extended attribute value. If the buffer is large enough to hold the entire attribute value, or buf is null, the size of the value is returned.- Parameters:
path- File path.name- Name of the attribute.buf- Buffer to store attribute value.- Returns:
- The length of the attribute value. See description for more details.
- Throws:
java.io.FileNotFoundException
-
lgetxattr
public long lgetxattr(java.lang.String path, java.lang.String name, byte[] buf) throws java.io.FileNotFoundExceptionGet an extended attribute value of a symbolic link. If the buffer is large enough to hold the entire attribute value, or buf is null, the size of the value is returned.- Parameters:
path- File path.name- Name of attribute.buf- Buffer to store attribute value.- Returns:
- The length of the attribute value. See description for more details.
- Throws:
java.io.FileNotFoundException
-
listxattr
public java.lang.String[] listxattr(java.lang.String path) throws java.io.FileNotFoundExceptionList extended attributes.- Parameters:
path- File path.- Returns:
- List of attribute names.
- Throws:
java.io.FileNotFoundException
-
llistxattr
public java.lang.String[] llistxattr(java.lang.String path) throws java.io.FileNotFoundExceptionList extended attributes of a symbolic link.- Parameters:
path- File path.- Returns:
- List of attribute names.
- Throws:
java.io.FileNotFoundException
-
removexattr
public void removexattr(java.lang.String path, java.lang.String name) throws java.io.FileNotFoundExceptionRemove an extended attribute.- Parameters:
path- File path.name- Name of attribute.- Throws:
java.io.FileNotFoundException
-
lremovexattr
public void lremovexattr(java.lang.String path, java.lang.String name) throws java.io.FileNotFoundExceptionRemove an extended attribute from a symbolic link.- Parameters:
path- File path.name- Name of attribute.- Throws:
java.io.FileNotFoundException
-
setxattr
public void setxattr(java.lang.String path, java.lang.String name, byte[] buf, long size, int flags) throws java.io.FileNotFoundExceptionSet the value of an extended attribute.- Parameters:
path- The file path.name- The attribute name.buf- The attribute value.size- The size of the attribute value.flags- Flag controlling behavior (XATTR_CREATE/REPLACE/NONE).- Throws:
java.io.FileNotFoundException
-
lsetxattr
public void lsetxattr(java.lang.String path, java.lang.String name, byte[] buf, long size, int flags) throws java.io.FileNotFoundExceptionSet the value of an extended attribute on a symbolic link.- Parameters:
path- The file path.name- The attribute name.buf- The attribute value.size- The size of the attribute value.flags- Flag controlling behavior (XATTR_CREATE/REPLACE/NONE).- Throws:
java.io.FileNotFoundException
-
get_file_stripe_unit
public int get_file_stripe_unit(int fd)
Get the stripe unit of a file.- Parameters:
fd- The file descriptor.- Returns:
- The stripe unit.
-
get_file_pool_name
public java.lang.String get_file_pool_name(int fd)
Get the name of the pool a file is stored in.- Parameters:
fd- An open file descriptor.- Returns:
- The pool name.
-
get_default_data_pool_name
public java.lang.String get_default_data_pool_name()
Get the default data pool of cephfs.- Returns:
- The pool name.
-
get_file_replication
public int get_file_replication(int fd)
Get the replication of a file.- Parameters:
fd- The file descriptor.- Returns:
- The file replication.
-
localize_reads
public void localize_reads(boolean state)
Favor reading from local replicas when possible.- Parameters:
state- Enable or disable localized reads.
-
get_stripe_unit_granularity
public int get_stripe_unit_granularity()
Get file layout stripe unit granularity.- Returns:
- Stripe unit granularity.
-
get_pool_id
public int get_pool_id(java.lang.String name) throws CephPoolExceptionGet the pool id for the named pool.- Parameters:
name- The pool name.- Returns:
- The pool id.
- Throws:
CephPoolException
-
get_pool_replication
public int get_pool_replication(int pool_id) throws CephPoolExceptionGet the pool replication factor.- Parameters:
pool_id- The pool id.- Returns:
- Number of replicas stored in the pool.
- Throws:
CephPoolException
-
get_file_extent
public CephFileExtent get_file_extent(int fd, long offset)
Get file extent containing a given offset.- Parameters:
fd- The file descriptor.offset- Offset in file.- Returns:
- A CephFileExtent object.
-
get_osd_crush_location
public Bucket[] get_osd_crush_location(int osd)
Get the fully qualified CRUSH location of an OSD. Returns (type, name) string pairs for each device in the CRUSH bucket hierarchy starting from the given OSD to the root.- Parameters:
osd- The OSD device id.- Returns:
- List of pairs.
-
get_osd_address
public java.net.InetAddress get_osd_address(int osd)
Get the network address of an OSD.- Parameters:
osd- The OSD device id.- Returns:
- The network address.
-
-