org.jvnet.solaris.libzfs
Class ZFSObject

java.lang.Object
  extended by org.jvnet.solaris.libzfs.ZFSObject
All Implemented Interfaces:
Comparable<ZFSObject>, ZFSContainer
Direct Known Subclasses:
ZFSFileSystem, ZFSSnapshot, ZFSVolume

public abstract class ZFSObject
extends Object
implements Comparable<ZFSObject>, ZFSContainer

Represents ZFS snapshot, file system, volume, or pool.

Author:
Kohsuke Kawaguchi

Method Summary
 void allow(ACLBuilder acl)
          Grants the specified set of permissions to this dataset.
 List<ZFSObject> children()
          List the children of this ZFS object (but not recursively.)
<T extends ZFSObject>
List<T>
children(Class<T> type)
          List the specific kind of children of this ZFS object (but not recursively.)
 ZFSFileSystem clone(String fullDestinationName)
          Creates a clone from this snapshot.
 int compareTo(ZFSObject that)
           
 ZFSFileSystem createFileSystem(String name, Map<String,String> props)
          Creates a nested file system.
 ZFSSnapshot createSnapshot(String snapshotName)
          Take a snapshot of this ZFS dataset.
 ZFSSnapshot createSnapshot(String snapshotName, boolean recursive)
          Take a snapshot of this ZFS dataset and recursively for all child datasets.
 List<ZFSObject> descendants()
          List the children of this ZFS object recursively, excluding the 'this' object itself.
<T extends ZFSObject>
List<T>
descendants(Class<T> type)
           
 void destory()
          Wipes out the dataset and all its data.
 void destory(boolean recursive)
          Wipes out this dataset and all its data, optionally recursively.
 void dispose()
           
 boolean equals(Object o)
           
 List<ZFSObject> filesystems()
           
protected  void finalize()
           
 List<ZFSObject> getChildren()
           
 LibZFS getLibrary()
           
 String getName()
          Gets the name of the dataset like "rpool/foo/bar".
 ZFSPool getPool()
          Gets the ZFSPool that contains this ZFS object.
 ZFSType getType()
          Gets the type of this ZFSObject.
 Hashtable<String,String> getUserProperty(Collection<String> keys)
           
 String getUserProperty(String key)
           
 Map<zfs_prop_t,String> getZfsProperty(Collection<zfs_prop_t> props)
           
 String getZfsProperty(zfs_prop_t prop)
           
 int hashCode()
           
 void inheritProperty(String key)
          Clears the given property on this dataset, causing it to be inherited from its parent.
 boolean isShared()
          Is this dataset shared.
 ZFSFileSystem openFileSystem(String name)
          Opens a nested file system.
 ZFSObject rename(String fullName, boolean recursive)
          Renames this data set to another name.
 ZFSObject rollback(boolean recursive)
           
 void setProperty(String key, String value)
          Sets a user-defined property.
 Set<ZFSSnapshot> snapshots()
          Obtain all snapshots for this dataset.
 String toString()
          Returns the name.
 void unallow(ACLBuilder acl)
          Revokes the specified set of permissions to this dataset.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getLibrary

public LibZFS getLibrary()

getPool

public ZFSPool getPool()
Gets the ZFSPool that contains this ZFS object.

Returns:
This method should never return null.

compareTo

public int compareTo(ZFSObject that)
Specified by:
compareTo in interface Comparable<ZFSObject>

children

public List<ZFSObject> children()
Description copied from interface: ZFSContainer
List the children of this ZFS object (but not recursively.)

Specified by:
children in interface ZFSContainer
Returns:
Never null. Sorted by the in-order of the traversal.

children

public <T extends ZFSObject> List<T> children(Class<T> type)
Description copied from interface: ZFSContainer
List the specific kind of children of this ZFS object (but not recursively.)

Specified by:
children in interface ZFSContainer
Returns:
Never null. Sorted by the in-order of the traversal.

descendants

public List<ZFSObject> descendants()
Description copied from interface: ZFSContainer
List the children of this ZFS object recursively, excluding the 'this' object itself.

Specified by:
descendants in interface ZFSContainer
Returns:
Never null. Sorted by the in-order of the traversal.

descendants

public <T extends ZFSObject> List<T> descendants(Class<T> type)
Specified by:
descendants in interface ZFSContainer

clone

public ZFSFileSystem clone(String fullDestinationName)
Creates a clone from this snapshot. This method fails if this ZFSObject is not a snapshot.


createFileSystem

public ZFSFileSystem createFileSystem(String name,
                                      Map<String,String> props)
Creates a nested file system.

Parameters:
props - ZFS properties to be attached to the new file system. Can be null.

openFileSystem

public ZFSFileSystem openFileSystem(String name)
Opens a nested file system.


createSnapshot

public ZFSSnapshot createSnapshot(String snapshotName)
Take a snapshot of this ZFS dataset.

Parameters:
snapshotName - the name of the Snapshot to create, i.e. 'monday', 'before-test'.
Returns:
the created snapshot.

createSnapshot

public ZFSSnapshot createSnapshot(String snapshotName,
                                  boolean recursive)
Take a snapshot of this ZFS dataset and recursively for all child datasets.

Parameters:
snapshotName - the name of the Snapshot to create, i.e. 'monday', 'before-test'.
recursive - should snapshot recursively create snapshot for all descendant datasets. Snapshots are taken atomically, so that all recursive snapshots correspond to the same moment in time.
Returns:
the created snapshot of this dataset.

destory

public void destory()
Wipes out the dataset and all its data. Very dangerous.

If this dataset contains nested datasets, this method fails with ErrorCode.EZFS_EXISTS.


destory

public void destory(boolean recursive)
Wipes out this dataset and all its data, optionally recursively.


dispose

public void dispose()

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

filesystems

public List<ZFSObject> filesystems()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getChildren

public List<ZFSObject> getChildren()

getName

public String getName()
Gets the name of the dataset like "rpool/foo/bar".

Returns:
the name of the dataset.

getType

public ZFSType getType()
Gets the type of this ZFSObject.


getZfsProperty

public Map<zfs_prop_t,String> getZfsProperty(Collection<zfs_prop_t> props)

getZfsProperty

public String getZfsProperty(zfs_prop_t prop)

getUserProperty

public Hashtable<String,String> getUserProperty(Collection<String> keys)

getUserProperty

public String getUserProperty(String key)

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

inheritProperty

public void inheritProperty(String key)
Clears the given property on this dataset, causing it to be inherited from its parent.


isShared

public boolean isShared()
Is this dataset shared.

Returns:
is dataset shared.

rename

public ZFSObject rename(String fullName,
                        boolean recursive)
Renames this data set to another name.

Returns:
ZFSObject representing the new renamed dataset.

rollback

public ZFSObject rollback(boolean recursive)

setProperty

public void setProperty(String key,
                        String value)
Sets a user-defined property.


snapshots

public Set<ZFSSnapshot> snapshots()
Obtain all snapshots for this dataset.

Returns:
all snapshot datasets.

allow

public void allow(ACLBuilder acl)
Grants the specified set of permissions to this dataset.


unallow

public void unallow(ACLBuilder acl)
Revokes the specified set of permissions to this dataset.


toString

public String toString()
Returns the name.

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.