|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bibalex.daf.reflectioncalls.BackupPhase
public class BackupPhase
Copyright (c) 2006-2007 by Bibliotheca Alexandrina
For a complete list of the operations performed by this phase, see aplyPhaseActions()
method.
Field Summary | |
---|---|
private static int |
BACKUP_PHASE_ID
Holds the ID of the backup phase. |
private static int |
backupServerFTPPoolSize
|
private static java.lang.String |
backupServerIP
|
private static java.lang.String |
backupServerPassword
|
private static java.lang.String |
backupServerPath
|
private static java.lang.String |
backupServerUser
|
private static TransitionInfo |
info
|
private static Job |
job
|
private static java.lang.String |
jobPath
|
private static boolean |
localFolderCreated
Indicates whether the local job or job_version folder has been created in the working directory or not. |
private static int |
QUICK_BACKUP_PHASE_ID
Holds the ID of the quick backup phase. |
private static boolean |
remoteFolderCreated
Indicates whether the local job or job_version folder has been created in the backup server or not. |
private static java.lang.String |
statusData
Holds the status data obtained from the phase before the backup phase. |
private static User |
user
|
private static WorkStation |
workstation
|
Constructor Summary | |
---|---|
BackupPhase()
|
Method Summary | |
---|---|
private static int |
addVersionSuffixToJobFolder()
Adds the version suffix to the job folder, that is; it renames the job folder. This method logs any errors that might happen. This method sets the localPath to the job_version folder at working directory. |
static void |
applyBackupActions(int jobID)
Applies the actions associated with the backup phase. The backup phase responsibility is to do the following: 1) Copy the entire job folder form the production server to the working directory. 2) Create metadata files for the job. 3) Zip each folder and calculate the size of the job. 4) Calculate the version of the job = number of backup entries in the TransactionLog table. 5) Copy the job to the backup server. |
static void |
applyQuickBackupActions(int jobID)
Applies the actions associated with the backup phase. The backup phase responsibility is to do the following: 1) Copy the entire job folder form the production server to the working directory. 2) Create metadata files for the job. 3) Zip each folder and calculate the size of the job. 4) Calculate the version of the job = number of backup entries in the TransactionLog table. 5) Copy the job to the backup server. |
private static long |
calculateJobSize()
Calculates the size of the job. This method logs any errors that might happen. |
private static boolean |
compressJobSubFolder(java.util.ArrayList<java.lang.String> compressedFolders)
Compresses the subfolders within the job folder. |
private static StatusDef |
convertToStatusDef(java.lang.String status)
Converts the gievn string into a StatusDef instance. |
private static boolean |
copyJobFromProductionServerToWorkingDirectory()
Copies the job form the production server to working directory. This method logs any errors that might happen. Note: 1) If an exception occurs, the downloaded folder from the production server is not deleted. 2) If the job folder is copied to the working directory, the localFolderCreated is set to true. |
private static boolean |
copyJobFromWorkingDirectoryToBackupServer()
Copies the job form the working directory to the backup server. This method logs any errors that might happen. Note: 1) If an exception occurs, neither the folder at the working directory or backup server is not deleted. 2) If the job folder is copied to the backup server, the remoteFolderCreated is set to true. |
private static boolean |
createMD5File(java.lang.String filePath)
Calculates the MD5 digest for the given file. The calculated MD5 is stored in a file named the same as the gievn file but with the extension md5. Note: The md5 file is written as 32 hex characters. If an exception is encuntered, a warning is logged. |
private static boolean |
deleteBackupFolder(java.lang.String folderPath)
Attempts to delete the given remote folder. |
private static boolean |
deleteLocalFolder(java.lang.String folderPath)
Attempts to delete the given local folder. If the job couldn't be deleted a warning is logged. |
private static int |
getAssignPhaseID()
Gets the phase ID to which the job will be assigned after it finishes backup. The Phase ID equals the ID of the phase after the last finished phase in sequence. This method logs any errors that might happen. |
private static void |
getBackupServerInformation()
Get the necessary information to connect to the backup phase. The information are read from the rescource file. This method logs any errors that might occur. |
private static boolean |
getLastFinishedPhase()
|
private static boolean |
isEmpty(java.lang.String path)
Determines whether the given folder is empty or not |
private static boolean |
makeDatabaseModification(int version,
java.util.ArrayList<java.lang.String> compressedFolders,
long size)
Makes the necessary database modifications. 1) Add the TransactionLog entries for the job. The method inserts 1 entry indicating the finish of the backup phase . 2) update the job record to point ot the last inserted database record. Note: 1) The method executes in a transaction. 2) If an exception occurs, the database transaction is rolled back. |
private static boolean |
makeDatabaseModification(int version,
java.util.ArrayList<java.lang.String> compressedFolders,
long size,
int assignPhaseID)
Makes the necessary database modifications. 1) Add the TransactionLog entries for the job. The method inserts 1 entry indicating the finish of the backup phase and another entry indicating assigning to the next phase if it is different from the backup phase ID. 2) pdate the job record to point ot the last inserted database record. Note: 1) The method executes in a transaction. 2) If an exception occurs, the database transaction is rolled back. |
private static void |
removesExtraFilesFromWorkingDirectory()
Clean the working directory by deleting extra files in the root folder. |
private static boolean |
writeMetadataFile()
Writes the metadata files of the job. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int QUICK_BACKUP_PHASE_ID
private static int BACKUP_PHASE_ID
private static boolean localFolderCreated
private static boolean remoteFolderCreated
private static java.lang.String statusData
private static Job job
private static java.lang.String jobPath
private static User user
private static WorkStation workstation
private static TransitionInfo info
private static java.lang.String backupServerIP
private static java.lang.String backupServerUser
private static java.lang.String backupServerPassword
private static java.lang.String backupServerPath
private static int backupServerFTPPoolSize
Constructor Detail |
---|
public BackupPhase()
Method Detail |
---|
public static void applyQuickBackupActions(int jobID) throws PhaseActionException
jobID
- The ID of the job to apply backup actions to.
PhaseActionException
- If the backup phase actions couldn't be applied.public static void applyBackupActions(int jobID) throws PhaseActionException
jobID
- The ID of the job to apply backup actions to.
PhaseActionException
- If the backup phase actions couldn't be applied.private static void getBackupServerInformation() throws java.lang.Exception
java.lang.Exception
- If the backup server information couldn't be obtained.private static boolean copyJobFromProductionServerToWorkingDirectory()
localFolderCreated
is set to true.
private static void removesExtraFilesFromWorkingDirectory()
java.lang.Exception
private static boolean compressJobSubFolder(java.util.ArrayList<java.lang.String> compressedFolders)
compressedFolders
- The folders that have been compressed.
private static boolean isEmpty(java.lang.String path)
path
- The path of the folder
private static boolean createMD5File(java.lang.String filePath)
filePath
- The complete path of the file to generated MD5 for.
private static boolean writeMetadataFile()
private static int addVersionSuffixToJobFolder()
localPath
to the job_version folder at working directory.
The method does the following:
private static long calculateJobSize()
private static boolean copyJobFromWorkingDirectoryToBackupServer()
remoteFolderCreated
is set to true.
private static int getAssignPhaseID()
private static boolean getLastFinishedPhase()
private static boolean makeDatabaseModification(int version, java.util.ArrayList<java.lang.String> compressedFolders, long size, int assignPhaseID)
version
- The version of the backup, it is used to write the status data of the backup finish entry.compressedFolders
- An ArrayList holding the names of the folders that has been compressed, it is used to write the status data of the backup finish entry.size
- The size of the entire job folder.assignPhaseID
- The ID of the phase to add an assign entry to. If the phase ID equals backupPhaseID
no assign entry is added.
private static boolean makeDatabaseModification(int version, java.util.ArrayList<java.lang.String> compressedFolders, long size)
version
- The version of the backup, it is used to write the status data of the backup finish entry.compressedFolders
- An ArrayList holding the names of the folders that has been compressed, it is used to write the status data of the backup finish entry.size
- The size of the entire job folder.
private static StatusDef convertToStatusDef(java.lang.String status)
status
- The string to parse.
private static boolean deleteLocalFolder(java.lang.String folderPath)
folderPath
- The complete path of the folder.
private static boolean deleteBackupFolder(java.lang.String folderPath)
folderPath
- The complete path of the folder.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |