Class Utils


  • public final class Utils
    extends Object
    • Method Detail

      • waitUntilIdle

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

        public static void waitUntilIdleAndSwitchToQuietMode​(int timeout,
                                                             TimeUnit unit)
                                                      throws 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. But if timeout is set to -1, it will never force jenkins to quiet mode.
        Parameters:
        timeout - specifies when a quiet mode is forced. 0 = no timeout; -1 = disable timer, never force jenkins to quiet mode.
        unit - specifies the time unit for the value of timeout.
        Throws:
        IOException - ?
      • getDateFromBackupDirectory

        public static Date getDateFromBackupDirectory​(File directory)
        Parameters:
        directory - directory to get the date from
        Returns:
        the date component of a directory name formatted in the thinBackup standard
      • getDateFromBackupDirectoryName

        public static Date getDateFromBackupDirectoryName​(String directoryName)
        Parameters:
        directoryName - directory name to get the date from
        Returns:
        the date component of a directory name formatted in the thinBackup standard
      • convertToDirectoryNameDateFormat

        public static String convertToDirectoryNameDateFormat​(String displayFormattedDate)
                                                       throws ParseException
        Parameters:
        displayFormattedDate - a String in the display format date
        Returns:
        the string formatted in the directory names' date format
        Throws:
        ParseException - if the beginning of the specified parameter cannot be parsed.
      • getFormattedDirectory

        public static File getFormattedDirectory​(File parent,
                                                 ThinBackupPeriodicWork.BackupType backupType,
                                                 Date date)
        Parameters:
        parent - root directory of all backups
        backupType - type of backup
        date - date of backup
        Returns:
        a reference to a file in the given parent directory with a name formatted like "<BACKUP_TYPE>-yyyy-MM-dd_HH-mm".
      • getBackupTypeDirectories

        public static List<File> getBackupTypeDirectories​(File parentDir,
                                                          ThinBackupPeriodicWork.BackupType backupType)
        Parameters:
        parentDir - root directory of all backups
        backupType - type of backup
        Returns:
        an unordered list of backup directories of the given backup type.
      • getBackupSetZipFiles

        public static List<File> getBackupSetZipFiles​(File parentDir)
        Parameters:
        parentDir - root directory of all backups
        Returns:
        an unordered list of zipped backupsets in the given directory.
      • getReferencedFullBackup

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

        @NonNull
        public static List<File> getReferencingDiffBackups​(File fullBackup)
        Parameters:
        fullBackup - fill backup
        Returns:
        a list of all diff backups which reference the given full backup.
      • getBackupsAsDates

        public static List<String> getBackupsAsDates​(File directory)
        Parameters:
        directory - root directory of all backups
        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 List<BackupSet> getValidBackupSetsFromDirectories​(File directory)
        Parameters:
        directory - root directory of all backups
        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 List<BackupSet> getValidBackupSetsFromZips​(File directory)
        Parameters:
        directory - root directory of all backups
        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 List<BackupSet> getValidBackupSets​(File directory)
        Parameters:
        directory - root directory of all backups
        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​(File backupRoot,
                                                   File currentBackup)
        Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.
        Parameters:
        backupRoot - root directory of all backups
        currentBackup - specified which backup should be omitted from being moved. If null, all backups are moved to ZIP files.
      • waitUntilFileCanBeRead

        public static void waitUntilFileCanBeRead​(File f)