use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method setTargetProperties.
/**
* Update system properties to zookeeper
*
* @param currentProps
* @throws CoordinatorClientException
*/
public void setTargetProperties(Map<String, String> currentProps) throws CoordinatorClientException {
Map<String, PropertyMetadata> propsMetadata = PropertiesMetadata.getGlobalMetadata();
// split properties as global, or site specific
HashMap<String, String> globalProps = new HashMap<String, String>();
HashMap<String, String> siteProps = new HashMap<String, String>();
for (Map.Entry<String, String> prop : currentProps.entrySet()) {
String key = prop.getKey();
PropertyMetadata metadata = propsMetadata.get(key);
if (metadata.getSiteSpecific()) {
siteProps.put(key, prop.getValue());
} else {
globalProps.put(key, prop.getValue());
}
}
// update properties to zk
if (getTargetInfoLock()) {
try {
// check we are in stable state if checkState = true specified
if (!isClusterUpgradable()) {
throw APIException.serviceUnavailable.clusterStateNotStable();
}
ConfigurationImpl globalCfg = new ConfigurationImpl();
globalCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
globalCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
PropertyInfoExt globalPropInfo = new PropertyInfoExt(globalProps);
globalCfg.setConfig(TARGET_INFO, globalPropInfo.encodeAsString());
_coordinator.persistServiceConfiguration(globalCfg);
_log.info("target properties changed successfully. target properties {}", globalPropInfo.toString());
if (siteProps.size() > 0) {
setSiteSpecificProperties(siteProps, _coordinator.getSiteId());
_log.info("site scope target properties changed successfully. target properties {}", siteProps.toString());
}
} catch (Exception e) {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target info. " + e.getMessage());
} finally {
releaseTargetVersionLock();
}
} else {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method setNodeGlobalScopeInfo.
public void setNodeGlobalScopeInfo(final CoordinatorSerializable info, final String siteId, final String kind, final String id) throws CoordinatorClientException {
if (info == null || kind == null) {
return;
}
try {
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(id);
// We can use service id as the "id" and the type of info as "kind", then we can persist certain type of info
cfg.setKind(kind);
// about a particular node in coordinator
cfg.setConfig(NODE_INFO, info.encodeAsString());
_coordinator.persistServiceConfiguration(siteId, cfg);
} catch (Exception e) {
_log.error("Failed to set node global scope info", e);
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set node global scope info. " + e.getMessage());
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method removeTargetInfo.
/**
* Remove target info shared by all nodes.
* checkClusterUpgradable = true is used for rest api's. It forces to check the cluster state stable or not.
* checkClusterUpgradable = false will not check the cluster state. It is used when cluster is not in stable state,
* but we have to set target info at the same time.
*
* @param info
* @param checkClusterUpgradable
* @throws CoordinatorClientException
*/
public void removeTargetInfo(final CoordinatorSerializable info, boolean checkClusterUpgradable) throws CoordinatorClientException {
if (info == null) {
return;
}
final CoordinatorClassInfo coordinatorInfo = info.getCoordinatorClassInfo();
String id = coordinatorInfo.id;
String kind = coordinatorInfo.kind;
if (getTargetInfoLock()) {
try {
// check we are in stable state if checkState = true specified
if (checkClusterUpgradable && !isClusterUpgradable()) {
throw APIException.serviceUnavailable.clusterStateNotStable();
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(id);
cfg.setKind(kind);
cfg.setConfig(TARGET_INFO, info.encodeAsString());
_coordinator.removeServiceConfiguration(cfg);
_log.info("Target info removed: {}", info);
} catch (Exception e) {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. " + e.getMessage());
} finally {
releaseTargetVersionLock();
}
} else {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. Unable to obtain target lock");
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class SchedulerConfig method persistBackupUploadStatus.
/**
* Persist upload status to ZK
*/
public void persistBackupUploadStatus(BackupUploadStatus status) {
Map<String, String> allItems = (status != null) ? status.getAllItems() : null;
if (allItems == null || allItems.size() == 0) {
return;
}
ConfigurationImpl config = new ConfigurationImpl();
config.setKind(BackupConstants.BACKUP_UPLOAD_STATUS);
config.setId(Constants.GLOBAL_ID);
log.info("Setting upload status: {}", status);
for (Map.Entry<String, String> entry : allItems.entrySet()) {
config.setConfig(entry.getKey(), entry.getValue());
}
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
log.info("Persist backup upload status to zk successfully");
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class SchedulerConfig method persist.
public void persist() {
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setKind(Constants.BACKUP_SCHEDULER_CONFIG);
cfg.setId(Constants.GLOBAL_ID);
cfg.setConfig(BackupConstants.BACKUP_TAGS_RETAINED, StringUtils.join(this.retainedBackups, ','));
cfg.setConfig(BackupConstants.BACKUP_TAGS_UPLOADED, StringUtils.join(this.uploadedBackups, ','));
coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), cfg);
}
Aggregations