use of com.emc.storageos.db.client.model.VdcOpLog in project coprhd-controller by CoprHD.
the class GeoServiceHelper method backupOperationVdc.
public static void backupOperationVdc(DbClient dbClient, GeoServiceJob.JobType jobType, URI operatedVdc, String operationParam) {
VdcOpLog op = new VdcOpLog();
op.setId(URIUtil.createId(VdcOpLog.class));
op.setOperationType(jobType.toString());
op.setOperatedVdc(operatedVdc);
try {
byte[] paramBytes = SerializerUtils.serializeAsByteArray(operationParam);
op.setOperationParam(paramBytes);
} catch (Exception e) {
throw InternalServerErrorException.internalServerErrors.genericApisvcError("Internal error when backup vdc config info", e);
}
List<VirtualDataCenter> vdcList = new ArrayList();
List<URI> ids = dbClient.queryByType(VirtualDataCenter.class, true);
for (URI id : ids) {
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, id);
if (vdc != null) {
if (vdc.getLocal() || (!vdc.getLocal() && vdc.getRepStatus() != VirtualDataCenter.GeoReplicationStatus.REP_NONE)) {
log.info("Add vdc {} {} to backup list", vdc.getId().toString(), vdc.getShortId());
vdcList.add(vdc);
}
}
}
try {
byte[] vdcBytes = SerializerUtils.serializeAsByteArray(vdcList);
op.setVdcConfigInfo(vdcBytes);
} catch (Exception e) {
throw InternalServerErrorException.internalServerErrors.genericApisvcError("Internal error when backup vdc config info", e);
}
dbClient.createObject(op);
log.info("Backup vdc config info succeed");
}
use of com.emc.storageos.db.client.model.VdcOpLog in project coprhd-controller by CoprHD.
the class DBClient method readRecoverBackupInfo.
private List<VdcConfig> readRecoverBackupInfo() {
List<VdcConfig> newVdcConfigList = new ArrayList<VdcConfig>();
List<URI> ids = _dbClient.queryByType(VdcOpLog.class, true);
VdcOpLog latestOp = null;
for (URI id : ids) {
if (latestOp == null) {
latestOp = _dbClient.queryObject(VdcOpLog.class, id);
} else {
VdcOpLog thisOp = _dbClient.queryObject(VdcOpLog.class, id);
if (thisOp.getCreationTime().getTimeInMillis() > latestOp.getCreationTime().getTimeInMillis()) {
latestOp = thisOp;
}
}
}
if (latestOp != null) {
byte[] vdcConfigInfo = latestOp.getVdcConfigInfo();
try {
List<VirtualDataCenter> vdcList = (List<VirtualDataCenter>) SerializerUtils.deserialize(vdcConfigInfo);
if (vdcList != null) {
for (VirtualDataCenter vdc : vdcList) {
newVdcConfigList.add(vdcConfHelper.toConfigParam(vdc));
}
}
} catch (Exception e) {
log.error("error in recovervdcinfo: " + e);
}
}
return newVdcConfigList;
}
Aggregations