Search in sources :

Example 56 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class DisconnectVdcTaskOp method preCheck.

private void preCheck() {
    log.info("The precheck phrase of 'disconnect vdc' start ...");
    checkDisconnectingConcurrency();
    // TODO: use updateVdcStatus()
    updateOpStatus(ConnectionStatus.DISCONNECTING);
    URI unstable = checkAllVdcStable(true, true);
    if (unstable != null) {
        notifyPrecheckFailed();
        log.error("The 'disconnect vdc operation' should not be triggered because vdc {} is unstable", unstable.toString());
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, unstable);
        String vdcName = (vdc != null) ? vdc.getLabel() : "";
        throw GeoException.fatals.unstableVdcFailure(vdcName);
    }
    if (isTargetVdcReachable(NODE_CHECK_TIMEOUT)) {
        notifyPrecheckFailed();
        log.error("The vdc {} to be disconnected is still reachable from other VDCs", operatedVdc.getId());
        throw GeoException.fatals.disconnectVdcStillReachable(operatedVdc.getLabel());
    }
    if (isVdcVersion20()) {
        notifyPrecheckFailed();
        log.error("At least one vdc's version is less than 2.1");
        throw GeoException.fatals.vdcVersionCheckFail(errMsg);
    }
    log.info("The precheck phrase of 'disconnect vdc' successes");
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 57 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class GeoServiceJobQueue method consumeItem.

/**
 * Verify the hosting device has not migrated states while waiting for dispatching and continue task
 *
 * @param job The object provisioning job which is being worked on. This could be either creation or deletion job
 * @param callback This must be executed, after the item is processed successfully to remove the item
 *            from the distributed queue
 *
 * @throws Exception
 */
@Override
public void consumeItem(GeoServiceJob job, DistributedQueueItemProcessedCallback callback) throws Exception {
    // verify job, db may not stable right now after reboot, retry may need
    VirtualDataCenter vdcInfo = null;
    int retry = 0;
    while (retry < MAX_DB_RETRY) {
        try {
            vdcInfo = _dbClient.queryObject(VirtualDataCenter.class, job.getVdcId());
            break;
        } catch (DatabaseException e) {
            _log.info("db not stable yet, retry");
            try {
                TimeUnit.SECONDS.sleep(WAIT_INTERVAL_IN_SEC);
            } catch (InterruptedException ex) {
            // Ignore this exception
            }
        }
        retry = retry + 1;
    }
    if (vdcInfo == null) {
        _log.info("Failed to query vdc {} from DB. Retry later", job.getVdcId());
        return;
    }
    String task = job.getTask();
    if (task == null) {
        _log.error("The vdc connect job for {} does not have an associated task", job.getVdcId());
        return;
    }
    try {
        _controller.setKeystore(viprKeyStore);
        // these methods will obtain lock and do nothing if operation is already in progress
        GeoServiceJob.JobType type = job.getType();
        switch(type) {
            case VDC_CONNECT_JOB:
                _log.info("Continuing initialization operation {} for {}", task, job.getVdcId());
                _controller.connectVdc(vdcInfo, task, job.getParams());
                break;
            case VDC_REMOVE_JOB:
                _log.info("vdc operation {} for {}", task, job.getVdcId());
                _controller.removeVdc(vdcInfo, task, job.getParams());
                break;
            case VDC_UPDATE_JOB:
                _log.info("Updating operation {} for {}", task, job.getVdcId());
                _controller.updateVdc(job.getVdc(), task, job.getParams());
                break;
            case VDC_DISCONNECT_JOB:
                _log.info("Disconnecting operation {} for {}", task, job.getVdcId());
                _controller.disconnectVdc(vdcInfo, task, job.getParams());
                break;
            case VDC_RECONNECT_JOB:
                _log.info("Reconnecting operation {} for {}", task, job.getVdcId());
                _controller.reconnectVdc(vdcInfo, task, job.getParams());
                break;
            default:
                _log.error("Invalid operation type {} on {}/{}", new Object[] { job.getType(), task, job.getVdcId() });
        }
    } catch (Exception e) {
        // TODO: retry the task if it is retryable exception
        _log.error("Execute job failed", e);
    }
    // removes item from queue
    callback.itemProcessed();
    _log.info("The job type={} vdcId={} task={} is removed", new Object[] { job.getType(), job.getVdcId(), job.getTask() });
}
Also used : GeoServiceJob(com.emc.storageos.security.geo.GeoServiceJob) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 58 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class InternalDbClient method waitAllSitesDbStable.

/**
 * Waits for the db instances joined in all sites
 */
public void waitAllSitesDbStable() {
    String prefix = "Waiting for DB cluster become stable on all sites ...";
    log.info(prefix);
    DbJmxClient geoInstance = getJmxClient(LOCALHOST);
    // Loop all VDC
    List<URI> vdcIdIter = queryByType(VirtualDataCenter.class, true);
    for (URI vdcId : vdcIdIter) {
        log.info("loop db status check on {}", vdcId.toString());
        VirtualDataCenter vdc = queryObject(VirtualDataCenter.class, vdcId);
        // filter out vdcs that are not connected in geo
        if (!shouldCheckDbStatus(vdc)) {
            log.error("ignore vdc for db status check {}", vdcId);
            continue;
        }
        if (vdc.getConnectionStatus() != ConnectionStatus.DISCONNECTED) {
            Site activeSite = drUtil.getActiveSite(vdc.getShortId());
            // short Id
            waitDbNodesStable(geoInstance, vdc.getShortId(), activeSite.getNodeCount());
        }
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 59 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class ReconnectVdcTaskOp method preCheck.

private void preCheck() {
    URI reconnectVdcId = operatedVdc.getId();
    URI unstable = checkAllVdcStable(true, true);
    if (unstable != null) {
        log.error("The 'reconnect vdc operation' should not be triggered because vdc {} is unstable", unstable);
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, unstable);
        String vdcName = (vdc != null) ? vdc.getLabel() : "";
        throw GeoException.fatals.unstableVdcFailure(vdcName);
    }
    if (!isReconnectVdcInRightStatus()) {
        log.error("The vdc {} to be reconnected has wrong status {}", reconnectVdcId, operatedVdcStatus);
        throw GeoException.fatals.reconnectVdcInvalidStatus(operatedVdc.getLabel());
    }
    // Only reconnect the vdc back once it is connected with other connected vdcs.
    if (!isAllConnectedVdcReachableWith(operatedVdc)) {
        log.error("There is at least one vdc is unreachable with the vdc {} which will need to be reconnected ", operatedVdc);
        throw GeoException.fatals.reconnectVdcUnreachable(errMsg);
    }
    // Only reconnect the vdc back if myVdc is connected with other connected vdcs.
    if (!isAllConnectedVdcReachableWith(myVdc)) {
        log.error("There is at least one vdc is unreachable with the vdc {} which will perform this operation ", myVdcId);
        throw GeoException.fatals.reconnectVdcUnreachable(errMsg);
    }
    if (isVdcVersion20()) {
        log.error("At least one vdc's version is less than 2.1");
        throw GeoException.fatals.vdcVersionCheckFail(errMsg);
    }
    // TODO: check if the vdc need to be reconnected back's IP and SSL changed or not. Or any related change.
    checkReconnectingVdc();
    log.info("ReconnectVdcTaskOp precheck phrase success");
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 60 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class RemoveVdcTaskOp method preCheck.

private void preCheck() {
    log.info("Pre check for {} before removal", operatedVdc.getShortId());
    lockHelper.acquire(operatedVdc.getShortId());
    geoClientCache.clearCache();
    loadVdcInfo();
    log.info("Load vdc info is done");
    checkVdcInUse();
    checkVdcDependency(operatedVdc.getShortId());
    // make sure all other vdc are up and running
    log.info("Check vdc stable");
    URI unstable = checkAllVdcStable(false, !isOperatedVdcDisconnected);
    if (unstable != null) {
        log.error("The vdc {} is not stable.", unstable);
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, unstable);
        String vdcName = (vdc != null) ? vdc.getLabel() : "";
        throw GeoException.fatals.unstableVdcFailure(vdcName);
    }
    log.info("Pre check for {} passed", operatedVdc.getShortId());
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Aggregations

VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)80 URI (java.net.URI)47 ArrayList (java.util.ArrayList)20 VdcConfig (com.emc.storageos.geomodel.VdcConfig)14 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)13 Test (org.junit.Test)10 Site (com.emc.storageos.coordinator.client.model.Site)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)7 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 Produces (javax.ws.rs.Produces)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 DataObject (com.emc.storageos.db.client.model.DataObject)4 TestGeoObject (com.emc.storageos.db.client.model.TestGeoObject)4 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)4 KeyStoreException (java.security.KeyStoreException)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4