Search in sources :

Example 61 with Configuration

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);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Example 62 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 63 with Configuration

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);
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 64 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) BackupUploadStatus(com.emc.vipr.model.sys.backup.BackupUploadStatus) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 65 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) Date(java.util.Date)

Aggregations

Configuration (com.emc.storageos.coordinator.common.Configuration)87 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)16 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)11 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)9 IOException (java.io.IOException)9 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)8 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)8 Site (com.emc.storageos.coordinator.client.model.Site)7 UnknownHostException (java.net.UnknownHostException)7 KeeperException (org.apache.zookeeper.KeeperException)7 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)3 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)2 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)2 SiteConfigRestRep (com.emc.storageos.model.dr.SiteConfigRestRep)2