Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ public interface BackupProvider {
*/
boolean removeVMFromBackupOffering(VirtualMachine vm);

/**
* Removes the specified backup schedule from a virtual machine.
*
* @param vm the virtual machine from which the schedule will be removed.
* @param backupSchedule the backup schedule to be removed.
* @return {@code true} if the operation was successful; {@code false} otherwise.
*/
default boolean removeVMBackupSchedule(VirtualMachine vm, BackupSchedule backupSchedule) {
return true;
}

/**
* Whether the provider will delete backups on removal of VM from the offering
Expand All @@ -91,7 +81,7 @@ default boolean removeVMBackupSchedule(VirtualMachine vm, BackupSchedule backupS
* @param isolated
* @return the result and {code}Backup{code} {code}Object{code}
*/
Pair<Boolean, Backup> takeBackup(VirtualMachine vm, Boolean quiesceVM, boolean isolated, Long backupScheduleId);
Pair<Boolean, Backup> takeBackup(VirtualMachine vm, Boolean quiesceVM, boolean isolated);

/**
* Delete an existing backup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ default Set<String> getSecondaryStorageUrls(UserVm userVm) {
default void prepareVmForSnapshotRevert(VMSnapshot vmSnapshot, VirtualMachine virtualMachine) {
}

default boolean finishBackupChains(VirtualMachine virtualMachine) {
default boolean finishBackupChain(VirtualMachine virtualMachine) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@
*/
package org.apache.cloudstack.backup;

import java.util.Map;
import java.util.List;

import org.apache.commons.collections4.MapUtils;
import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.commons.collections4.CollectionUtils;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.utils.Pair;

public class CleanupKbossBackupErrorAnswer extends Answer {
private Map<String, Pair<String, Boolean>> volumeIdToPathAndChainEnded;
private List<VolumeObjectTO> volumeObjectTos;
private boolean vmRunning;

public CleanupKbossBackupErrorAnswer(Command cmd, Map<String, Pair<String, Boolean>> volumeIdToPathAndChainEnded, boolean vmRunning) {
super(cmd, MapUtils.isNotEmpty(volumeIdToPathAndChainEnded), null);
this.volumeIdToPathAndChainEnded = volumeIdToPathAndChainEnded;
public CleanupKbossBackupErrorAnswer(Command cmd, List<VolumeObjectTO> volumeObjectTos, boolean vmRunning) {
super(cmd, CollectionUtils.isNotEmpty(volumeObjectTos), null);
this.volumeObjectTos = volumeObjectTos;
this.vmRunning = vmRunning;
}

public Map<String, Pair<String, Boolean>> getVolumeIdToPathAndChainEnded() {
return volumeIdToPathAndChainEnded;
public List<VolumeObjectTO> getVolumeObjectTos() {
return volumeObjectTos;
}

public boolean isVmRunning() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,19 @@ public class CleanupKbossBackupErrorCommand extends Command {

private boolean runningVM;

private boolean errorOnCreate;

private boolean endOfChain;

private boolean isTopDelta;

private String vmName;

private String imageStoreUrl;

private List<KbossTO> kbossTOS;

public CleanupKbossBackupErrorCommand(boolean runningVM, boolean errorOnCreate, boolean endOfChain, boolean isTopDelta, String vmName, String imageStoreUrl, List<KbossTO> kbossTOS) {
this.errorOnCreate = errorOnCreate;
public CleanupKbossBackupErrorCommand(boolean runningVM, String vmName, String imageStoreUrl, List<KbossTO> kbossTOS) {
this.runningVM = runningVM;
this.endOfChain = endOfChain;
this.isTopDelta = isTopDelta;
this.vmName = vmName;
this.imageStoreUrl = imageStoreUrl;
this.kbossTOS = kbossTOS;
}

public boolean isErrorOnCreate() {
return errorOnCreate;
}

public boolean isEndOfChain() {
return endOfChain;
}

public boolean isTopDelta() {
return isTopDelta;
}

public boolean isRunningVM() {
return runningVM;
}
Expand Down
25 changes: 8 additions & 17 deletions core/src/main/java/org/apache/cloudstack/storage/to/KbossTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// specific language governing permissions and limitations
// under the License.

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

Expand All @@ -29,22 +30,20 @@ public class KbossTO {
private String deltaPathOnPrimary;
private String parentDeltaPathOnPrimary;
private String deltaPathOnSecondary;
private String oldVolumePath;

private DeltaMergeTreeTO deltaMergeTreeTO;

private List<String> deltaPaths;
private List<String> vmSnapshotDeltaPaths;

public KbossTO(VolumeObjectTO volumeObjectTO, LinkedList<String> deltaPaths) {
public KbossTO(VolumeObjectTO volumeObjectTO, List<SnapshotDataStoreVO> snapshotDataStoreVOs) {
this.volumeObjectTO = volumeObjectTO;
this.deltaPaths = deltaPaths;
this.vmSnapshotDeltaPaths = snapshotDataStoreVOs.stream().map(SnapshotDataStoreVO::getInstallPath).collect(Collectors.toList());
}

public KbossTO(VolumeObjectTO volumeObjectTO, String deltaPathOnPrimary, String deltaPathOnSecondary, LinkedList<String> deltaPaths) {
public KbossTO(VolumeObjectTO volumeObjectTO, String deltaPathOnPrimary, String deltaPathOnSecondary) {
this.volumeObjectTO = volumeObjectTO;
this.deltaPathOnPrimary = deltaPathOnPrimary;
this.deltaPathOnSecondary = deltaPathOnSecondary;
this.deltaPaths = deltaPaths;
}

public String getPathBackupParentOnSecondary() {
Expand All @@ -59,8 +58,8 @@ public DeltaMergeTreeTO getDeltaMergeTreeTO() {
return deltaMergeTreeTO;
}

public List<String> getDeltaPaths() {
return deltaPaths;
public List<String> getVmSnapshotDeltaPaths() {
return vmSnapshotDeltaPaths;
}

public String getDeltaPathOnPrimary() {
Expand Down Expand Up @@ -95,14 +94,6 @@ public void setDeltaPathOnSecondary(String deltaPathOnSecondary) {
this.deltaPathOnSecondary = deltaPathOnSecondary;
}

public String getOldVolumePath() {
return oldVolumePath;
}

public void setOldVolumePath(String oldVolumePath) {
this.oldVolumePath = oldVolumePath;
}

@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO, Seri
private String encryptFormat;
private List<String> checkpointPaths;
private Set<String> checkpointImageStoreUrls;
private Set<String> deltasToRemove;

public VolumeObjectTO() {

Expand Down Expand Up @@ -426,12 +425,4 @@ public Set<String> getCheckpointImageStoreUrls() {
public void setCheckpointImageStoreUrls(Set<String> checkpointImageStoreUrls) {
this.checkpointImageStoreUrls = checkpointImageStoreUrls;
}

public Set<String> getDeltasToRemove() {
return deltasToRemove;
}

public void setDeltasToRemove(Set<String> deltasToRemove) {
this.deltasToRemove = deltasToRemove;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ public class InternalBackupJoinVO {
@Column(name = "isolated")
private Boolean isolated;

@Column(name = "storage_pool_delta_path")
private String storagePoolDeltaPath;

@Column(name = "storage_pool_parent_path")
private String storagePoolParentPath;

@Column(name = "schedule_id")
private Long scheduleId;

public InternalBackupJoinVO() {
}

Expand Down Expand Up @@ -192,18 +183,6 @@ public Backup.CompressionStatus getCompressionStatus() {
return compressionStatus;
}

public String getStoragePoolDeltaPath() {
return storagePoolDeltaPath;
}

public String getStoragePoolParentPath() {
return storagePoolParentPath;
}

public Long getScheduleId() {
return scheduleId;
}

@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@

public interface InternalBackupJoinDao extends GenericDao<InternalBackupJoinVO, Long> {

List<InternalBackupJoinVO> listByBackedUpAndVmIdAndDateBeforeOrAfterOrderBy(long vmId, Long scheduleId, Date date, boolean before, boolean ascending);
List<InternalBackupJoinVO> listByBackedUpAndVmIdAndDateBeforeOrAfterOrderBy(long vmId, Date date, boolean before, boolean ascending);

List<InternalBackupJoinVO> listIncludingRemovedByVmIdAndBeforeDateOrderByCreatedDesc(long vmId, Long scheduleId, Date beforeDate);
List<InternalBackupJoinVO> listIncludingRemovedByVmIdAndBeforeDateOrderByCreatedDesc(long vmId, Date beforeDate);

InternalBackupJoinVO findCurrent(long vmId, Long scheduleId);

List<InternalBackupJoinVO> listCurrents(long vmId, boolean descending);

List<InternalBackupJoinVO> listCurrentsByVolumeIdDesc(long volumeId);
InternalBackupJoinVO findCurrent(long vmId);

InternalBackupJoinVO findByParentId(long parentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public class InternalBackupJoinDaoImpl extends GenericDaoBase<InternalBackupJoin
private static final String ISOLATED = "isolated";
private static final String PARENT_ID = "parent_id";
private static final String IMAGE_STORE_ID = "image_store_id";
private static final String SCHEDULE_ID = "schedule_id";
private static final String VOLUME_ID = "volume_id";
private SearchBuilder<InternalBackupJoinVO> backupSearch;
private SearchBuilder<InternalBackupJoinVO> allBackupsSearch;

Expand All @@ -54,7 +52,6 @@ protected void init() {
backupSearch.and(CURRENT, backupSearch.entity().getCurrent(), SearchCriteria.Op.EQ);
backupSearch.and(PARENT_ID, backupSearch.entity().getParentId(), SearchCriteria.Op.EQ);
backupSearch.and(ISOLATED, backupSearch.entity().getIsolated(), SearchCriteria.Op.EQ);
backupSearch.and(SCHEDULE_ID, backupSearch.entity().getScheduleId(), SearchCriteria.Op.EQ);
backupSearch.groupBy(backupSearch.entity().getId());
backupSearch.done();

Expand All @@ -63,14 +60,11 @@ protected void init() {
allBackupsSearch.and(STATUS, allBackupsSearch.entity().getStatus(), SearchCriteria.Op.IN);
allBackupsSearch.and(PARENT_ID, allBackupsSearch.entity().getParentId(), SearchCriteria.Op.EQ);
allBackupsSearch.and(IMAGE_STORE_ID, allBackupsSearch.entity().getImageStoreId(), SearchCriteria.Op.EQ);
allBackupsSearch.and(VM_ID, allBackupsSearch.entity().getVmId(), SearchCriteria.Op.EQ);
allBackupsSearch.and(VOLUME_ID, allBackupsSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
allBackupsSearch.and(CURRENT, allBackupsSearch.entity().getCurrent(), SearchCriteria.Op.EQ);
allBackupsSearch.done();
}

@Override
public List<InternalBackupJoinVO> listByBackedUpAndVmIdAndDateBeforeOrAfterOrderBy(long vmId, Long scheduleId, Date date, boolean before, boolean ascending) {
public List<InternalBackupJoinVO> listByBackedUpAndVmIdAndDateBeforeOrAfterOrderBy(long vmId, Date date, boolean before, boolean ascending) {
SearchCriteria<InternalBackupJoinVO> sc = backupSearch.create();
sc.setParameters(VM_ID, vmId);
sc.setParameters(STATUS, Backup.Status.BackedUp);
Expand All @@ -80,29 +74,26 @@ public List<InternalBackupJoinVO> listByBackedUpAndVmIdAndDateBeforeOrAfterOrder
sc.setParameters(CREATED_AFTER, date);
}
sc.setParameters(ISOLATED, Boolean.FALSE.toString());
sc.setParameters(SCHEDULE_ID, scheduleId);
Filter filter = new Filter(InternalBackupJoinVO.class, "date", ascending);
return new ArrayList<>(listBy(sc, filter));
}

@Override
public List<InternalBackupJoinVO> listIncludingRemovedByVmIdAndBeforeDateOrderByCreatedDesc(long vmId, Long scheduleId, Date beforeDate) {
public List<InternalBackupJoinVO> listIncludingRemovedByVmIdAndBeforeDateOrderByCreatedDesc(long vmId, Date beforeDate) {
SearchCriteria<InternalBackupJoinVO> sc = backupSearch.create();
sc.setParameters(VM_ID, vmId);
sc.setParameters(STATUS, Backup.Status.BackedUp, Backup.Status.Removed);
sc.setParameters(CREATED_BEFORE, beforeDate);
sc.setParameters(ISOLATED, Boolean.FALSE.toString());
sc.setParameters(SCHEDULE_ID, scheduleId);
Filter filter = new Filter(InternalBackupJoinVO.class, "date", false);
return new ArrayList<>(listIncludingRemovedBy(sc, filter));
}

@Override
public InternalBackupJoinVO findCurrent(long vmId, Long scheduleId) {
public InternalBackupJoinVO findCurrent(long vmId) {
SearchCriteria<InternalBackupJoinVO> sc = backupSearch.create();
sc.setParameters(VM_ID, vmId);
sc.setParameters(CURRENT, Boolean.TRUE.toString());
sc.setParameters(SCHEDULE_ID, scheduleId);
return findOneBy(sc);
}

Expand Down Expand Up @@ -136,23 +127,4 @@ public List<InternalBackupJoinVO> listByParentId(long parentId) {
sc.setParameters(STATUS, Backup.Status.BackedUp);
return listBy(sc);
}

@Override
public List<InternalBackupJoinVO> listCurrents(long vmId, boolean descending) {
SearchCriteria<InternalBackupJoinVO> sc = allBackupsSearch.create();
sc.setParameters(VM_ID, vmId);
sc.setParameters(CURRENT, Boolean.TRUE.toString());
Filter filter = new Filter(InternalBackupJoinVO.class, "date", !descending);

return listBy(sc, filter);
}

@Override
public List<InternalBackupJoinVO> listCurrentsByVolumeIdDesc(long volumeId) {
SearchCriteria<InternalBackupJoinVO> sc = allBackupsSearch.create();
sc.setParameters(VOLUME_ID, volumeId);
sc.setParameters(CURRENT, Boolean.TRUE.toString());
Filter filter = new Filter(InternalBackupJoinVO.class, "date", false);
return listBy(sc, filter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ public interface InternalBackupStoragePoolDao extends GenericDao<InternalBackupS

List<InternalBackupStoragePoolVO> listByBackupId(long backupId);

List<InternalBackupStoragePoolVO> listByVolumeId(long volumeId);

InternalBackupStoragePoolVO findOneByVolumeIdAndBackupId(long volumeId, long backupId);
InternalBackupStoragePoolVO findOneByVolumeId(long volumeId);

void expungeByBackupId(long backupId);

void expungeByVolumeId(long volumeId);

void expungeByVolumeIdAndBackupId(long volumeId, long backupId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,9 @@ public List<InternalBackupStoragePoolVO> listByBackupId(long backupId) {
}

@Override
public List<InternalBackupStoragePoolVO> listByVolumeId(long volumeId) {
public InternalBackupStoragePoolVO findOneByVolumeId(long volumeId) {
SearchCriteria<InternalBackupStoragePoolVO> sc = backupSearch.create();
sc.setParameters(VOLUME_ID, volumeId);
return listBy(sc);
}

@Override
public InternalBackupStoragePoolVO findOneByVolumeIdAndBackupId(long volumeId, long backupId) {
SearchCriteria<InternalBackupStoragePoolVO> sc = backupSearch.create();
sc.setParameters(VOLUME_ID, volumeId);
sc.setParameters(BACKUP_ID, backupId);
return findOneBy(sc);
}

Expand All @@ -75,12 +67,4 @@ public void expungeByVolumeId(long volumeId) {
sc.setParameters(VOLUME_ID, volumeId);
expunge(sc);
}

@Override
public void expungeByVolumeIdAndBackupId(long volumeId, long backupId) {
SearchCriteria<InternalBackupStoragePoolVO> sc = backupSearch.create();
sc.setParameters(VOLUME_ID, volumeId);
sc.setParameters(BACKUP_ID, backupId);
expunge(sc);
}
}
Loading
Loading