use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class RecoveryManager method persistNodeRecoveryStatus.
/**
* Persist recovery status to ZK
*/
private void persistNodeRecoveryStatus(RecoveryStatus status) {
log.info("Set node recovery status: {}", status);
if (status == null) {
return;
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setKind(Constants.NODE_RECOVERY_STATUS);
cfg.setId(Constants.GLOBAL_ID);
cfg.setConfig(RecoveryConstants.RECOVERY_STATUS, status.getStatus().toString());
if (status.getStartTime() != null) {
cfg.setConfig(RecoveryConstants.RECOVERY_STARTTIME, String.valueOf(status.getStartTime().getTime()));
}
if (status.getEndTime() != null) {
cfg.setConfig(RecoveryConstants.RECOVERY_ENDTIME, String.valueOf(status.getEndTime().getTime()));
}
if (status.getErrorCode() != null) {
cfg.setConfig(RecoveryConstants.RECOVERY_ERRCODE, status.getErrorCode().toString());
}
coordinator.getCoordinatorClient().persistServiceConfiguration(cfg);
log.debug("Persist node recovery status({}) to zk successfully", status);
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class CoordinatorConfigStoringHelper method createOrUpdateConfig.
/**
* Creates or updates a new entry of the specified type in coordinator. If siteId
* is not null, the config is in zk site specific area. Otherwise in global area
*
* @param objToPersist
* the object to store in coordinator
* @param lockName
* the name of the lock to use while storing this object
* If passed as Null, lock is assumed to be already owned
* @param configKInd
* @param configId
* @param ConfigKey
* @throws Exception
*/
public void createOrUpdateConfig(Object objToPersist, String lockName, String siteId, String configKInd, String configId, String ConfigKey) throws Exception {
InterProcessLock lock = acquireLock(lockName);
try {
if (lock != null) {
Configuration config = coordinator.queryConfiguration(siteId, configKInd, configId);
ConfigurationImpl configImpl = null;
if (config == null) {
configImpl = new ConfigurationImpl();
configImpl.setId(configId);
configImpl.setKind(configKInd);
log.debug("Creating new config");
} else {
configImpl = (ConfigurationImpl) config;
if (config.getKind() == null) {
((ConfigurationImpl) config).setKind(configKInd);
}
if (config.getId() == null) {
((ConfigurationImpl) config).setId(configId);
}
log.debug("Updating existing config");
}
configImpl.setConfig(ConfigKey, SerializerUtils.serializeAsBase64EncodedString(objToPersist));
coordinator.persistServiceConfiguration(siteId, configImpl);
log.debug("Updated config successfully");
}
} finally {
releaseLock(lock);
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class GeoDbSvcStartupTest method setLocalDbCurrentVersion.
private static void setLocalDbCurrentVersion(CoordinatorClient coordinator) throws Exception {
Configuration config = coordinator.queryConfiguration(coordinator.getSiteId(), Constants.DB_CONFIG, Constants.GLOBAL_ID);
if (config == null) {
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(Constants.GLOBAL_ID);
cfg.setKind(Constants.DB_CONFIG);
config = cfg;
}
config.setConfig(Constants.SCHEMA_VERSION, DbSvcRunner.SVC_VERSION);
coordinator.persistServiceConfiguration(coordinator.getSiteId(), config);
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class VdcConfigHelper method createVdcConfigInZk.
public void createVdcConfigInZk(VdcConfig vdc, String ipsecKey) {
log.info("Update Vdc info to zk {}", vdc.getShortId());
// Insert vdc info
ConfigurationImpl vdcConfig = new ConfigurationImpl();
vdcConfig.setKind(Site.CONFIG_KIND);
vdcConfig.setId(vdc.getShortId());
coordinator.persistServiceConfiguration(vdcConfig);
// insert DR active site info to ZK
Site site = new Site();
site.setUuid(vdc.getActiveSiteId());
site.setName("Default Active Site");
site.setVdcShortId(vdc.getShortId());
site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
site.setHostIPv4AddressMap(vdc.getHostIPv4AddressesMap());
site.setHostIPv6AddressMap(vdc.getHostIPv6AddressesMap());
site.setState(SiteState.ACTIVE);
site.setCreationTime(System.currentTimeMillis());
String vdcEndpoint = vdc.getApiEndpoint();
if (vdcEndpoint.contains(":")) {
site.setVip6(vdcEndpoint);
site.setVip(PropertyConstants.IPV4_ADDR_DEFAULT);
} else {
site.setVip(vdcEndpoint);
site.setVip6(PropertyConstants.IPV6_ADDR_DEFAULT);
}
site.setNodeCount(vdc.getHostCount());
coordinator.persistServiceConfiguration(site.toConfiguration());
ipsecConfig.setPreSharedKey(ipsecKey);
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class BackupOps method setGeoFlag.
public synchronized void setGeoFlag(String backupName, boolean isLocal) {
BackupRestoreStatus state = queryBackupRestoreStatus(backupName, isLocal);
state.setGeo(true);
log.info("Persist backup restore status {} stack=", state, new Throwable());
Map<String, String> allItems = state.toMap();
ConfigurationImpl config = new ConfigurationImpl();
config.setKind(getBackupConfigKind(isLocal));
config.setId(backupName);
for (Map.Entry<String, String> entry : allItems.entrySet()) {
config.setConfig(entry.getKey(), entry.getValue());
}
coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
log.info("Persist backup restore status to zk successfully");
}
Aggregations