@@ -92,7 +92,7 @@ public Answer execute(TakeKbossBackupCommand command, LibvirtComputingResource r
9292 * <br/>
9393 * If an exception is caught while copying the volumes, will try to recover the VM to the previous state so that it is consistent.
9494 * */
95- private void backupVolumes (TakeKbossBackupCommand command , LibvirtComputingResource resource , KVMStoragePoolManager storagePoolManager , List <KbossTO > kbossTOS ,
95+ protected void backupVolumes (TakeKbossBackupCommand command , LibvirtComputingResource resource , KVMStoragePoolManager storagePoolManager , List <KbossTO > kbossTOS ,
9696 List <Pair <VolumeObjectTO , String >> volumeTosAndNewPaths , String vmName , boolean runningVM ,
9797 Map <String , Pair <String , Long >> mapVolumeUuidToDeltaPathOnSecondaryAndDeltaSize ) {
9898 try {
@@ -117,7 +117,7 @@ private void backupVolumes(TakeKbossBackupCommand command, LibvirtComputingResou
117117 }
118118 }
119119
120- private int calculateRemainingTime (int maxWaitInMillis , long startTimeMillis ) throws TimeoutException {
120+ protected int calculateRemainingTime (int maxWaitInMillis , long startTimeMillis ) throws TimeoutException {
121121 maxWaitInMillis -= (int )(System .currentTimeMillis () - startTimeMillis );
122122 if (maxWaitInMillis < 0 ) {
123123 throw new TimeoutException ("Timeout while converting backups to secondary storage." );
@@ -129,7 +129,7 @@ private int calculateRemainingTime(int maxWaitInMillis, long startTimeMillis) th
129129 * For each KbossTO, will merge its DeltaMergeTreeTO (if it exists). Also, if this is the end of the chain, will also end the chain for the volume.
130130 * Will populate the mapVolumeUuidToNewVolumePath argument.
131131 * */
132- private void cleanupVm (TakeKbossBackupCommand command , LibvirtComputingResource resource , List <KbossTO > kbossTOS , String vmName , boolean runningVM ,
132+ protected void cleanupVm (TakeKbossBackupCommand command , LibvirtComputingResource resource , List <KbossTO > kbossTOS , String vmName , boolean runningVM ,
133133 Map <String , String > mapVolumeUuidToNewVolumePath ) {
134134 for (KbossTO kbossTO : kbossTOS ) {
135135 VolumeObjectTO volumeObjectTO = kbossTO .getVolumeObjectTO ();
@@ -160,7 +160,7 @@ private void cleanupVm(TakeKbossBackupCommand command, LibvirtComputingResource
160160 * Copy the backup delta to the secondary storage. Since we created a snapshot on top of the volume, the volume is now the backup delta.
161161 * If there were snapshots created after the last backup, they'll be copied alongside and merged in the secondary storage.
162162 * */
163- private Pair <String , Long > copyBackupDeltaToSecondary (KVMStoragePoolManager storagePoolManager , KbossTO kbossTO , List <String > chainImageStoreUrls , String imageStoreUrl ,
163+ protected Pair <String , Long > copyBackupDeltaToSecondary (KVMStoragePoolManager storagePoolManager , KbossTO kbossTO , List <String > chainImageStoreUrls , String imageStoreUrl ,
164164 int waitInMillis ) {
165165 VolumeObjectTO delta = kbossTO .getVolumeObjectTO ();
166166 String parentDeltaPathOnSecondary = kbossTO .getPathBackupParentOnSecondary ();
@@ -233,7 +233,7 @@ private Pair<String, Long> copyBackupDeltaToSecondary(KVMStoragePoolManager stor
233233 * If there were VM snapshots created after the last backup, we will have copied them alongside the backup delta. If this is the case, we will commit all of them into a single
234234 * base file so that we are left with one file per volume per backup.
235235 * */
236- private void commitTopDeltaOnBaseBackupOnSecondaryIfNeeded (String topDelta , String backupOnSecondary , KVMStoragePool imagePool , String backupOnSecondaryFullPath ,
236+ protected void commitTopDeltaOnBaseBackupOnSecondaryIfNeeded (String topDelta , String backupOnSecondary , KVMStoragePool imagePool , String backupOnSecondaryFullPath ,
237237 int waitInMillis ) throws LibvirtException , QemuImgException {
238238 if (topDelta .equals (backupOnSecondary )) {
239239 return ;
@@ -255,7 +255,7 @@ private void commitTopDeltaOnBaseBackupOnSecondaryIfNeeded(String topDelta, Stri
255255 * - If we fail to backup we have to clean up the secondary storage.<br/>
256256 * - If we had VM snapshots created after the last backup, we copied multiple files to secondary storage, and thus we have to clean them up after merging them.
257257 * */
258- private void removeTemporaryDeltas (List <String > temporaryDeltasToRemove , boolean result ) {
258+ protected void removeTemporaryDeltas (List <String > temporaryDeltasToRemove , boolean result ) {
259259 if (result ) {
260260 temporaryDeltasToRemove .remove (0 );
261261 }
@@ -278,7 +278,7 @@ private void removeTemporaryDeltas(List<String> temporaryDeltasToRemove, boolean
278278 * @param volumeUuid volume uuid, used for logging.
279279 * @param waitInMillis timeout in milliseconds.
280280 * */
281- private void convertDeltaToSecondary (String pathDeltaOnPrimary , String pathDeltaOnSecondary , String pathParentOnSecondary , String volumeUuid , int waitInMillis )
281+ protected void convertDeltaToSecondary (String pathDeltaOnPrimary , String pathDeltaOnSecondary , String pathParentOnSecondary , String volumeUuid , int waitInMillis )
282282 throws QemuImgException , LibvirtException {
283283 QemuImgFile backupDestination = new QemuImgFile (pathDeltaOnSecondary , QemuImg .PhysicalDiskFormat .QCOW2 );
284284 QemuImgFile backupOrigin = new QemuImgFile (pathDeltaOnPrimary , QemuImg .PhysicalDiskFormat .QCOW2 );
@@ -298,7 +298,7 @@ private void convertDeltaToSecondary(String pathDeltaOnPrimary, String pathDelta
298298 }
299299
300300
301- private void endChainForVolume (LibvirtComputingResource resource , VolumeObjectTO volumeObjectTO , String vmName , boolean isVmRunning , String volumeUuid , String baseVolumePath )
301+ protected void endChainForVolume (LibvirtComputingResource resource , VolumeObjectTO volumeObjectTO , String vmName , boolean isVmRunning , String volumeUuid , String baseVolumePath )
302302 throws BackupException {
303303
304304 BackupDeltaTO baseVolume = new BackupDeltaTO (volumeObjectTO .getDataStore (), Hypervisor .HypervisorType .KVM , baseVolumePath );
@@ -315,7 +315,7 @@ private void endChainForVolume(LibvirtComputingResource resource, VolumeObjectTO
315315 * - Merge back any backup deltas created;
316316 * - Remove the data backed up to the secondary storage;
317317 * */
318- private void recoverPreviousVmStateAndDeletePartialBackup (LibvirtComputingResource resource , List <Pair <VolumeObjectTO , String >> volumeTosAndNewPaths , String vmName ,
318+ protected void recoverPreviousVmStateAndDeletePartialBackup (LibvirtComputingResource resource , List <Pair <VolumeObjectTO , String >> volumeTosAndNewPaths , String vmName ,
319319 boolean runningVm , Map <String , Pair <String , Long >> mapVolumeUuidToDeltaPathOnSecondaryAndSize , KVMStoragePoolManager storagePoolManager , String imageStoreUrl ) {
320320 logger .error ("There has been an exception during the backup creation process. We will try to revert the VM [{}] to its previous state." , vmName );
321321
@@ -338,7 +338,7 @@ private void recoverPreviousVmStateAndDeletePartialBackup(LibvirtComputingResour
338338 }
339339 }
340340
341- private void cleanupDeltaOnSecondary (KVMStoragePoolManager storagePoolManager , String imageStoreUrl , String deltaPath ) {
341+ protected void cleanupDeltaOnSecondary (KVMStoragePoolManager storagePoolManager , String imageStoreUrl , String deltaPath ) {
342342 KVMStoragePool imagePool = null ;
343343
344344 try {
@@ -358,7 +358,7 @@ private void cleanupDeltaOnSecondary(KVMStoragePoolManager storagePoolManager, S
358358 }
359359
360360
361- private void mergeBackupDelta (LibvirtComputingResource resource , DeltaMergeTreeTO deltaMergeTreeTO , VolumeObjectTO volumeObjectTO , String vmName , boolean isVmRunning ,
361+ protected void mergeBackupDelta (LibvirtComputingResource resource , DeltaMergeTreeTO deltaMergeTreeTO , VolumeObjectTO volumeObjectTO , String vmName , boolean isVmRunning ,
362362 String volumeUuid , boolean countNewestDeltaAsGrandchild ) throws BackupException {
363363 try {
364364 if (isVmRunning ) {
@@ -375,11 +375,11 @@ private void mergeBackupDelta(LibvirtComputingResource resource, DeltaMergeTreeT
375375 }
376376 }
377377
378- private String getRelativePathOnSecondaryForBackup (long accountId , long volumeId , String backupPath ) {
378+ protected String getRelativePathOnSecondaryForBackup (long accountId , long volumeId , String backupPath ) {
379379 return String .format ("%s%s%s%s%s%s%s" , "backups" , File .separator , accountId , File .separator , volumeId , File .separator , backupPath );
380380 }
381381
382- private void createDirsIfNeeded (String deltaFullPath , String volumeUuid ) {
382+ protected void createDirsIfNeeded (String deltaFullPath , String volumeUuid ) {
383383 String dirs = deltaFullPath .substring (0 , deltaFullPath .lastIndexOf (File .separator ));
384384 try {
385385 Files .createDirectories (Path .of (dirs ));
0 commit comments