Search in sources :

Example 16 with ConfigurationImpl

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");
    }
}
Also used : HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 17 with ConfigurationImpl

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());
    }
}
Also used : ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 18 with ConfigurationImpl

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");
    }
}
Also used : CoordinatorClassInfo(com.emc.storageos.coordinator.client.model.CoordinatorClassInfo) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 19 with ConfigurationImpl

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");
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) TypeMap(com.emc.storageos.db.client.impl.TypeMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with ConfigurationImpl

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

Aggregations

ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)51 Configuration (com.emc.storageos.coordinator.common.Configuration)16 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)8 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 IOException (java.io.IOException)6 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)6 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)5 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)5 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)5 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)4 Site (com.emc.storageos.coordinator.client.model.Site)4 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)4 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)4 HashMap (java.util.HashMap)4 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 Map (java.util.Map)3 CoordinatorClassInfo (com.emc.storageos.coordinator.client.model.CoordinatorClassInfo)2 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)2 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)2