use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class CoordinatorConfigStoringHelper method removeConfig.
/**
* Removes the specified config from coordinator. If siteId is not null, config
* is in global area. Otherwise it is in site specific area
*
* @param lockName
* the name of the lock to use while removing this object
* @param configKInd
* @param configId
* @throws Exception
*/
public void removeConfig(String lockName, String siteId, String configKInd, String configId) throws Exception {
InterProcessLock lock = acquireLock(lockName);
try {
Configuration config = coordinator.queryConfiguration(siteId, configKInd, configId);
if (config != null) {
coordinator.removeServiceConfiguration(siteId, config);
log.debug("removed config successfully");
} else {
log.debug("config " + configId + " of kind " + configKInd + " was not removed since it could not be found");
}
} finally {
releaseLock(lock);
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class CoordinatorConfigStoringHelper method readConfig.
/**
* Reads object of the specified kind from coordinator and deserializes it. If siteId
* is not null, the config is in zk site specific area. Otherwise in global area
*
* @param siteId
* @param configKind
* @param configId
* @param ConfigKey
* @return the retrieved object or null if not found
* @throws ClassNotFoundException
* @throws IOException
*/
public <T> T readConfig(String siteId, String configKind, String configId, String ConfigKey) throws IOException, ClassNotFoundException {
Configuration config = coordinator.queryConfiguration(siteId, configKind, configId);
if (config == null || config.getConfig(ConfigKey) == null) {
log.debug("Config of kind " + configKind + " and id " + configId + "not found");
return null;
}
String serializedConfig = config.getConfig(ConfigKey);
@SuppressWarnings("unchecked") T retObj = (T) SerializerUtils.deserialize(serializedConfig);
return retObj;
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class SchedulerConfig method initRetainedAndUploadedBackups.
private void initRetainedAndUploadedBackups() {
this.retainedBackups.clear();
this.uploadedBackups.clear();
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), Constants.BACKUP_SCHEDULER_CONFIG, Constants.GLOBAL_ID);
if (cfg != null) {
String succBackupStr = cfg.getConfig(BackupConstants.BACKUP_TAGS_RETAINED);
if (succBackupStr != null && succBackupStr.length() > 0) {
splitAndRemoveEmpty(succBackupStr, ",", this.retainedBackups);
}
String completedTagsStr = cfg.getConfig(BackupConstants.BACKUP_TAGS_UPLOADED);
if (completedTagsStr != null && completedTagsStr.length() > 0) {
splitAndRemoveEmpty(completedTagsStr, ",", this.uploadedBackups);
}
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class SchedulerConfig method queryBackupUploadStatus.
/**
* Query upload status from ZK
*/
public BackupUploadStatus queryBackupUploadStatus() {
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), BackupConstants.BACKUP_UPLOAD_STATUS, Constants.GLOBAL_ID);
Map<String, String> allItems = (cfg == null) ? new HashMap<String, String>() : cfg.getAllConfigs(false);
BackupUploadStatus uploadStatus = new BackupUploadStatus(allItems);
log.info("Upload status is: {}", uploadStatus);
return uploadStatus;
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class RecoveryManager method queryNodeRecoveryStatus.
/**
* Query recovery status from ZK
*/
public RecoveryStatus queryNodeRecoveryStatus() {
RecoveryStatus status = new RecoveryStatus();
Configuration cfg = coordinator.getCoordinatorClient().queryConfiguration(Constants.NODE_RECOVERY_STATUS, Constants.GLOBAL_ID);
if (cfg != null) {
String statusStr = cfg.getConfig(RecoveryConstants.RECOVERY_STATUS);
status.setStatus(RecoveryStatus.Status.valueOf(statusStr));
String startTimeStr = cfg.getConfig(RecoveryConstants.RECOVERY_STARTTIME);
if (startTimeStr != null && startTimeStr.length() > 0) {
status.setStartTime(new Date(Long.parseLong(startTimeStr)));
}
String endTimeStr = cfg.getConfig(RecoveryConstants.RECOVERY_ENDTIME);
if (endTimeStr != null && endTimeStr.length() > 0) {
status.setEndTime(new Date(Long.parseLong(endTimeStr)));
}
String errorCodeStr = cfg.getConfig(RecoveryConstants.RECOVERY_ERRCODE);
if (errorCodeStr != null && errorCodeStr.length() > 0) {
status.setErrorCode(RecoveryStatus.ErrorCode.valueOf(errorCodeStr));
}
}
log.info("Recovery status is: {}", status);
return status;
}
Aggregations