Search in sources :

Example 1 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method prepareSiteConfigParam.

/**
 * Prepare all sites related info for synchronizing them from master to be added or resumed standby site
 *
 * @param standbySites All standby sites
 * @param ipsecKey The cluster ipsec key
 * @param targetStandbyUUID The uuid of the target standby
 * @param targetStandbyDataRevision The data revision of the target standby
 * @return SiteConfigParam all the sites configuration
 */
private SiteConfigParam prepareSiteConfigParam(List<Site> standbySites, String ipsecKey, String targetStandbyUUID, long targetStandbyDataRevision, long vdcConfigVersion, SecretKey secretKey) {
    log.info("Preparing to sync sites info among to be added/resumed standby site...");
    Site active = drUtil.getActiveSite();
    SiteConfigParam configParam = new SiteConfigParam();
    SiteParam activeSite = new SiteParam();
    siteMapper.map(active, activeSite);
    activeSite.setIpsecKey(ipsecKey);
    log.info("    active site info:{}", activeSite.toString());
    configParam.setActiveSite(activeSite);
    List<SiteParam> standbySitesParam = new ArrayList<>();
    for (Site standby : standbySites) {
        SiteParam standbyParam = new SiteParam();
        siteMapper.map(standby, standbyParam);
        standbyParam.setSecretKey(new String(Base64.encodeBase64(secretKey.getEncoded()), Charset.forName("UTF-8")));
        if (standby.getUuid().equals(targetStandbyUUID)) {
            log.info("Set data revision for site {} to {}", standby.getUuid(), targetStandbyDataRevision);
            standbyParam.setDataRevision(targetStandbyDataRevision);
        }
        standbySitesParam.add(standbyParam);
        log.info("    standby site info:{}", standbyParam.toString());
    }
    configParam.setStandbySites(standbySitesParam);
    configParam.setVdcConfigVersion(vdcConfigVersion);
    // Need set stanby's NTP same as primary, so standby time is consistent with primary after reboot
    // It's because time inconsistency between primary and standby will cause db rebuild issue: COP-17965
    PropertyInfoExt targetPropInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
    String ntpServers = targetPropInfo.getProperty(NTPSERVERS);
    log.info("    active site ntp servers: {}", ntpServers);
    configParam.setNtpServers(ntpServers);
    return configParam;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ArrayList(java.util.ArrayList) SiteParam(com.emc.storageos.model.dr.SiteParam) SiteConfigParam(com.emc.storageos.model.dr.SiteConfigParam)

Example 2 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method initStandby.

/**
 * Initialize a to-be added/resumed target standby
 * a) re-set all the latest site related info (persisted in ZK) in the target standby
 * b) vdc properties would be changed accordingly
 * c) the target standby reboot
 * d) re-set zk/db data during the target standby reboot
 * e) the target standby would connect with active and sync all the latest ZK&DB data.
 *
 * Scenarios:
 * a) For adding standby site scenario (External API), the current site will be demoted from active to standby during the process
 * b) For resuming standby site scenario (Internal API), the current site's original data will be cleaned by setting new data revision.
 * It is now only used for resuming long paused (> 5 days) standby site
 *
 * @param configParam
 * @return
 */
@PUT
@Path("/internal/initstandby")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response initStandby(SiteConfigParam configParam) {
    try {
        SiteParam activeSiteParam = configParam.getActiveSite();
        ipsecConfig.setPreSharedKey(activeSiteParam.getIpsecKey());
        log.info("Clean up all obsolete site configurations");
        String activeSiteId = activeSiteParam.getUuid();
        Set<String> standbySiteIds = new HashSet<>();
        for (SiteParam standby : configParam.getStandbySites()) {
            standbySiteIds.add(standby.getUuid());
        }
        for (Site siteToRemove : drUtil.listSites()) {
            String siteId = siteToRemove.getUuid();
            if (activeSiteId.equals(siteId) || standbySiteIds.contains(siteId)) {
                continue;
            }
            drUtil.removeSite(siteToRemove);
        }
        coordinator.addSite(activeSiteParam.getUuid());
        Site activeSite = new Site();
        siteMapper.map(activeSiteParam, activeSite);
        activeSite.setVdcShortId(drUtil.getLocalVdcShortId());
        coordinator.persistServiceConfiguration(activeSite.toConfiguration());
        Long dataRevision = null;
        // Add other standby sites
        for (SiteParam standby : configParam.getStandbySites()) {
            Site site = new Site();
            siteMapper.map(standby, site);
            site.setVdcShortId(drUtil.getLocalVdcShortId());
            coordinator.persistServiceConfiguration(site.toConfiguration());
            coordinator.addSite(standby.getUuid());
            if (standby.getUuid().equals(coordinator.getSiteId())) {
                dataRevision = standby.getDataRevision();
                log.info("Set data revision to {}", dataRevision);
            }
            log.info("Persist standby site {} to ZK", standby.getVip());
        }
        if (dataRevision == null) {
            throw new IllegalStateException("Illegal request on standby site. No data revision in request");
        }
        String ntpServers = configParam.getNtpServers();
        PropertyInfoExt targetPropInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
        if (ntpServers != null && !ntpServers.equals(targetPropInfo.getProperty(NTPSERVERS))) {
            targetPropInfo.addProperty(NTPSERVERS, ntpServers);
            coordinator.setTargetInfo(targetPropInfo);
            log.info("Set ntp servers to {}", ntpServers);
        }
        drUtil.updateVdcTargetVersion(coordinator.getSiteId(), SiteInfo.DR_OP_CHANGE_DATA_REVISION, configParam.getVdcConfigVersion(), dataRevision);
        return Response.status(Response.Status.ACCEPTED).build();
    } catch (Exception e) {
        log.error("Internal error for updating coordinator on standby", e);
        throw APIException.internalServerErrors.configStandbyFailed(e.getMessage());
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) SiteParam(com.emc.storageos.model.dr.SiteParam) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) ZkPath(com.emc.storageos.coordinator.common.impl.ZkPath) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 3 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class SystemPropertyUtil method retreiveSystemProperty.

/**
 * retrieve value from system properties of ZooKeeper.
 * if the properties do not exist, or exception when loading, return null.
 */
private static String retreiveSystemProperty(CoordinatorClient coordinator, String propertyName) {
    try {
        PropertyInfoExt params = coordinator.getTargetInfo(PropertyInfoExt.class);
        String propertyValue = params.getProperty(propertyName);
        _log.info("retrieve property: " + propertyName + " = " + propertyValue);
        return propertyValue;
    } catch (Exception e) {
        _log.warn("retrieve property: " + propertyName + " from ZK error");
        return null;
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Example 4 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method getPropertyInfo.

/**
 * Get property
 *
 * This method gets target properties from coordinator service as a string
 * and merges it with the defaults and the ovf properties
 * Syssvc is responsible for publishing the target property information into coordinator
 *
 * @return property object
 * @throws CoordinatorException
 */
@Override
public PropertyInfo getPropertyInfo() throws CoordinatorException {
    PropertyInfo info = new PropertyInfo();
    Map<String, String> defaults = new HashMap<String, String>((Map) defaultProperties);
    final Configuration config = queryConfiguration(TARGET_PROPERTY, TARGET_PROPERTY_ID);
    if (null == config || null == config.getConfig(TARGET_INFO)) {
        log.debug("getPropertyInfo(): no properties saved in coordinator returning defaults");
        info.setProperties(defaults);
    } else {
        final String infoStr = config.getConfig(TARGET_INFO);
        try {
            log.debug("getPropertyInfo(): properties saved in coordinator=" + Strings.repr(infoStr));
            info.setProperties(mergeProps(defaults, decodeFromString(infoStr).getProperties()));
        } catch (final Exception e) {
            throw CoordinatorException.fatals.unableToDecodeDataFromCoordinator(e);
        }
    }
    // add site specific properties
    PropertyInfoExt siteScopePropInfo = getTargetInfo(getSiteId(), PropertyInfoExt.class);
    if (siteScopePropInfo != null) {
        info.getProperties().putAll(siteScopePropInfo.getProperties());
    }
    // add the ovf properties
    info.getProperties().putAll((Map) ovfProperties);
    return info;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) PropertyInfo(com.emc.storageos.model.property.PropertyInfo) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 5 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class ZkCmdHandler method rollbackDataRevision.

public void rollbackDataRevision() throws Exception {
    DrUtil drUtil = new DrUtil(ZKUtil.getCoordinatorClient());
    if (!precheckForRollback(drUtil)) {
        return;
    }
    LocalRepository localRepository = LocalRepository.getInstance();
    PropertyInfoExt localDataRevisionProps = localRepository.getDataRevisionPropertyInfo();
    String prevRevision = localDataRevisionProps.getProperty(Constants.KEY_PREV_DATA_REVISION);
    log.info("Previous data revision at local {}", prevRevision);
    if (StringUtils.isNotEmpty(prevRevision)) {
        long rollbackTargetRevision = Long.parseLong(prevRevision);
        drUtil.updateVdcTargetVersion(drUtil.getLocalSite().getUuid(), SiteInfo.DR_OP_CHANGE_DATA_REVISION, DrUtil.newVdcConfigVersion(), rollbackTargetRevision);
        log.info("Manual rollback to {} has been triggered", rollbackTargetRevision);
        System.out.println(String.format("Rollback to %s has been initiated successfully", prevRevision));
    } else {
        log.warn("No valid previous revision found. Skip rollback");
        System.out.println("Can't find viable previous data revision. Rollback oparation has been aborted");
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) LocalRepository(com.emc.storageos.systemservices.impl.upgrade.LocalRepository)

Aggregations

PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)33 HashMap (java.util.HashMap)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)4 Test (org.junit.Test)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)3 IOException (java.io.IOException)3 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 SiteParam (com.emc.storageos.model.dr.SiteParam)2 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)2 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1