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;
}
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());
}
}
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;
}
}
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;
}
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");
}
}
Aggregations