org.jvnet.hudson.plugins.thinbackup.utils
Class Utils

java.lang.Object
  extended by org.jvnet.hudson.plugins.thinbackup.utils.Utils

public class Utils
extends java.lang.Object


Field Summary
static java.text.SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT
           
static java.text.SimpleDateFormat DISPLAY_DATE_FORMAT
           
static int FORCE_QUIETMODE_TIMEOUT_MINUTES
           
static java.lang.String THINBACKUP_TMP_DIR
           
 
Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String convertToDirectoryNameDateFormat(java.lang.String displayFormattedDate)
           
static java.lang.String expandEnvironmentVariables(java.lang.String path)
           
static java.util.List<java.lang.String> getBackupsAsDates(java.io.File directory)
           
static java.util.List<java.io.File> getBackupSetZipFiles(java.io.File parentDir)
           
static java.util.List<java.io.File> getBackupTypeDirectories(java.io.File parentDir, ThinBackupPeriodicWork.BackupType backupType)
           
static java.util.Date getDateFromBackupDirectory(java.io.File directory)
           
static java.util.Date getDateFromBackupDirectoryName(java.lang.String directoryName)
           
static java.io.File getFormattedDirectory(java.io.File parent, ThinBackupPeriodicWork.BackupType backupType, java.util.Date date)
           
static java.io.File getReferencedFullBackup(java.io.File diffBackup)
           
static java.util.List<java.io.File> getReferencingDiffBackups(java.io.File fullBackup)
           
static java.util.List<BackupSet> getValidBackupSets(java.io.File directory)
           
static java.util.List<BackupSet> getValidBackupSetsFromDirectories(java.io.File directory)
           
static java.util.List<BackupSet> getValidBackupSetsFromZips(java.io.File directory)
           
protected static java.lang.String internalExpandEnvironmentVariables(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> environmentVariables)
          For unit testing purposes only.
static void moveOldBackupsToZipFile(java.io.File backupRoot, java.io.File currentBackup)
          Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.
static void waitUntilFileCanBeRead(java.io.File f)
           
static void waitUntilIdle()
          Waits until all Hudson slaves are idle.
static void waitUntilIdleAndSwitchToQuietMode(int timeout, java.util.concurrent.TimeUnit unit)
          Waits until all executors are idle and switch jenkins to quiet mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_DATE_FORMAT

public static final java.text.SimpleDateFormat DISPLAY_DATE_FORMAT

DIRECTORY_NAME_DATE_FORMAT

public static final java.text.SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT

THINBACKUP_TMP_DIR

public static final java.lang.String THINBACKUP_TMP_DIR

FORCE_QUIETMODE_TIMEOUT_MINUTES

public static final int FORCE_QUIETMODE_TIMEOUT_MINUTES
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

waitUntilIdle

public static void waitUntilIdle()
Waits until all Hudson slaves are idle.


waitUntilIdleAndSwitchToQuietMode

public static void waitUntilIdleAndSwitchToQuietMode(int timeout,
                                                     java.util.concurrent.TimeUnit unit)
                                              throws java.io.IOException
Waits until all executors are idle and switch jenkins to quiet mode. If it takes to long that all executors are idle because in the mean time other jobs are executed the timeout ensure that the quiet mode is forced.

Parameters:
timeout - specifies when a quiet mode is forced. 0 = no timeout.
unit - specifies the time unit for the value of timeout.
Throws:
java.io.IOException

getDateFromBackupDirectory

public static java.util.Date getDateFromBackupDirectory(java.io.File directory)
Parameters:
directory -
Returns:
the date component of a directory name formatted in the thinBackup standard

getDateFromBackupDirectoryName

public static java.util.Date getDateFromBackupDirectoryName(java.lang.String directoryName)
Parameters:
directoryName -
Returns:
the date component of a directory name formatted in the thinBackup standard

convertToDirectoryNameDateFormat

public static java.lang.String convertToDirectoryNameDateFormat(java.lang.String displayFormattedDate)
                                                         throws java.text.ParseException
Parameters:
displayFormattedDate - a String in the display format date
Returns:
the string formatted in the directory names' date format
Throws:
java.text.ParseException

getFormattedDirectory

public static java.io.File getFormattedDirectory(java.io.File parent,
                                                 ThinBackupPeriodicWork.BackupType backupType,
                                                 java.util.Date date)
Parameters:
parent -
backupType -
date -
Returns:
a reference to a file in the given parent directory with a name formatted like "-yyyy-MM-dd_HH-mm".

getBackupTypeDirectories

public static java.util.List<java.io.File> getBackupTypeDirectories(java.io.File parentDir,
                                                                    ThinBackupPeriodicWork.BackupType backupType)
Parameters:
parentDir -
backupType -
Returns:
an unordered list of backup directories of the given backup type.

getBackupSetZipFiles

public static java.util.List<java.io.File> getBackupSetZipFiles(java.io.File parentDir)
Parameters:
parentDir -
Returns:
an unordered list of zipped backupsets in the given directory.

getReferencedFullBackup

public static java.io.File getReferencedFullBackup(java.io.File diffBackup)
Parameters:
diffBackup -
Returns:
the full backup referenced by the given diff backup, or null if none can be found.

getReferencingDiffBackups

public static java.util.List<java.io.File> getReferencingDiffBackups(java.io.File fullBackup)
Parameters:
fullBackup -
Returns:
a list of all diff backups which reference the given full backup.

getBackupsAsDates

public static java.util.List<java.lang.String> getBackupsAsDates(java.io.File directory)
Parameters:
directory -
Returns:
a list of backups in the given directory (both FULL and DIFF), displayed as the respective backup date, from both directories and ZIP files, ordered descending by the date encoded in the backups' name.

getValidBackupSetsFromDirectories

public static java.util.List<BackupSet> getValidBackupSetsFromDirectories(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets that exists as directories (not as ZIP files) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

getValidBackupSetsFromZips

public static java.util.List<BackupSet> getValidBackupSetsFromZips(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets that exists as ZIP files (not as directories) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

getValidBackupSets

public static java.util.List<BackupSet> getValidBackupSets(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

moveOldBackupsToZipFile

public static void moveOldBackupsToZipFile(java.io.File backupRoot,
                                           java.io.File currentBackup)
                                    throws java.io.IOException
Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.

Parameters:
backupRoot -
currentBackup - specified which backup should be omitted from being moved. If null, all backups are moved to ZIP files.
Throws:
java.io.IOException

expandEnvironmentVariables

public static java.lang.String expandEnvironmentVariables(java.lang.String path)
                                                   throws EnvironmentVariableNotDefinedException
Throws:
EnvironmentVariableNotDefinedException

internalExpandEnvironmentVariables

protected static java.lang.String internalExpandEnvironmentVariables(java.lang.String path,
                                                                     java.util.Map<java.lang.String,java.lang.String> environmentVariables)
                                                              throws EnvironmentVariableNotDefinedException
For unit testing purposes only. Use @link {expandEnvironmentVariables}.

Throws:
EnvironmentVariableNotDefinedException

waitUntilFileCanBeRead

public static void waitUntilFileCanBeRead(java.io.File f)


Copyright © 2004-2013. All Rights Reserved.