com.continuent.tungsten.replicator.backup
Class LvmHelper

java.lang.Object
  extended by com.continuent.tungsten.replicator.backup.LvmHelper

public class LvmHelper
extends java.lang.Object

Implements a helper for running LVM commands across full life-cycle from creating a snapshot to mounting it to unmounting and discarding.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
LvmHelper(ProcessHelper processHelper)
          Creates a new LVM helper.
 
Method Summary
 void configure()
          Configure the commands and locations to manage snapshots.
 void createSnapshot()
          Creates a new snapshot, which is assumed not to exist already.
 java.lang.String getDataDir()
           
 java.lang.String getLogicalVolume()
           
 java.lang.String getLogicalVolumeMount()
           
 java.lang.String getLvcreate()
           
 java.lang.String getLvremove()
           
 java.io.File getSnapshotDataDir()
           
 java.lang.String getSnapshotMount()
           
 java.lang.String getSnapshotName()
           
 java.lang.String getSnapshotSize()
           
 java.lang.String getVolumeGroup()
           
 void mountSnapShot()
          Mounts a snapshot and validates that the storage is readable.
 void removeSnapshot()
          Removes an existing snapshot.
 void removeStorage()
          Clears storage in preparation for restore operation.
 void setDataDir(java.lang.String dataDir)
           
 void setLogicalVolume(java.lang.String logicalVolume)
           
 void setLogicalVolumeMount(java.lang.String logicalVolumeMount)
           
 void setLvcreate(java.lang.String lvcreate)
           
 void setLvremove(java.lang.String lvremove)
           
 void setSnapshotMount(java.lang.String snapshotMount)
           
 void setSnapshotName(java.lang.String snapshotName)
           
 void setSnapshotSize(java.lang.String snapshotSize)
           
 void setVolumeGroup(java.lang.String volumeGroup)
           
 void unmountSnapshot()
          Unmounts a snapshot.
 void validateStorage(java.lang.String name, java.io.File storageDir)
          Ensure that indicated storage is a readable directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LvmHelper

public LvmHelper(ProcessHelper processHelper)
Creates a new LVM helper.

Method Detail

getDataDir

public java.lang.String getDataDir()

setDataDir

public void setDataDir(java.lang.String dataDir)

getVolumeGroup

public java.lang.String getVolumeGroup()

setVolumeGroup

public void setVolumeGroup(java.lang.String volumeGroup)

getLogicalVolume

public java.lang.String getLogicalVolume()

setLogicalVolume

public void setLogicalVolume(java.lang.String logicalVolume)

getLogicalVolumeMount

public java.lang.String getLogicalVolumeMount()

setLogicalVolumeMount

public void setLogicalVolumeMount(java.lang.String logicalVolumeMount)

getSnapshotName

public java.lang.String getSnapshotName()

setSnapshotName

public void setSnapshotName(java.lang.String snapshotName)

getSnapshotSize

public java.lang.String getSnapshotSize()

setSnapshotSize

public void setSnapshotSize(java.lang.String snapshotSize)

getSnapshotMount

public java.lang.String getSnapshotMount()

setSnapshotMount

public void setSnapshotMount(java.lang.String snapshotMount)

getLvcreate

public java.lang.String getLvcreate()

setLvcreate

public void setLvcreate(java.lang.String lvcreate)

getLvremove

public java.lang.String getLvremove()

setLvremove

public void setLvremove(java.lang.String lvremove)

getSnapshotDataDir

public java.io.File getSnapshotDataDir()

configure

public void configure()
               throws BackupException
Configure the commands and locations to manage snapshots. Must be called before executing any other command.

Throws:
BackupException

createSnapshot

public void createSnapshot()
                    throws BackupException
Creates a new snapshot, which is assumed not to exist already.

Throws:
BackupException - If the snapshot creation fails, for example because the snapshot already exists.

removeSnapshot

public void removeSnapshot()
                    throws BackupException
Removes an existing snapshot.

Throws:
BackupException - If the snapshot removal fails, for example because the snapshot does not exist.

mountSnapShot

public void mountSnapShot()
                   throws BackupException
Mounts a snapshot and validates that the storage is readable.

Throws:
BackupException - Thrown if the mount command is unsuccessful for any reason

unmountSnapshot

public void unmountSnapshot()
                     throws BackupException
Unmounts a snapshot.

Throws:
BackupException - Thrown if the unmount command is unsuccessful for any reason

removeStorage

public void removeStorage()
                   throws BackupException
Clears storage in preparation for restore operation.

Throws:
BackupException - Thrown if rm command fails.

validateStorage

public void validateStorage(java.lang.String name,
                            java.io.File storageDir)
                     throws BackupException
Ensure that indicated storage is a readable directory.

Throws:
BackupException