Search in sources :

Example 1 with VdcOpLog

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");
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) URI(java.net.URI) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VdcOpLog(com.emc.storageos.db.client.model.VdcOpLog)

Example 2 with VdcOpLog

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;
}
Also used : VdcConfig(com.emc.storageos.geomodel.VdcConfig) ArrayList(java.util.ArrayList) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) URI(java.net.URI) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) VdcOpLog(com.emc.storageos.db.client.model.VdcOpLog)

Aggregations

VdcOpLog (com.emc.storageos.db.client.model.VdcOpLog)2 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 VdcConfig (com.emc.storageos.geomodel.VdcConfig)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 IntrospectionException (java.beans.IntrospectionException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 NodeList (org.w3c.dom.NodeList)1