Search in sources :

Example 31 with ConfigurationImpl

use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.

the class LazyLoadTests method setMigrationStatus.

private static void setMigrationStatus(MigrationStatus status) {
    String dbConfigPath = _coordinator.getVersionedDbConfigPath("dbsvc", "1.1");
    Configuration config = _coordinator.queryConfiguration(dbConfigPath, Constants.GLOBAL_ID);
    if (config == null) {
        ConfigurationImpl cfg = new ConfigurationImpl();
        cfg.setKind(dbConfigPath);
        cfg.setId(Constants.GLOBAL_ID);
        config = cfg;
    }
    config.setConfig(Constants.MIGRATION_STATUS, status.name());
    _coordinator.persistServiceConfiguration(config);
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 32 with ConfigurationImpl

use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setTargetInfo.

/**
 * Set target info shared by all nodes.
 *
 * @param info info, String id, String kind
 * @throws CoordinatorClientException
 */
public void setTargetInfo(final CoordinatorSerializable info, String id, String kind) throws CoordinatorClientException {
    if (info == null) {
        return;
    }
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state & version exists in available
            if (!isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl cfg = new ConfigurationImpl();
            cfg.setId(id);
            cfg.setKind(kind);
            cfg.setConfig(TARGET_INFO, info.encodeAsString());
            _coordinator.persistServiceConfiguration(cfg);
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
    }
}
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 33 with ConfigurationImpl

use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setSiteSpecificProperties.

/**
 * Set site specific properties
 *
 * @param props
 * @param siteId
 */
public void setSiteSpecificProperties(Map<String, String> props, String siteId) {
    PropertyInfoExt siteScopeInfo = new PropertyInfoExt(props);
    ConfigurationImpl siteCfg = new ConfigurationImpl();
    siteCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
    siteCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
    siteCfg.setConfig(TARGET_INFO, siteScopeInfo.encodeAsString());
    _coordinator.persistServiceConfiguration(siteId, siteCfg);
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 34 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.
 *
 * @param info info, String id, String kind
 * @throws CoordinatorClientException
 */
public void removeTargetInfo(final CoordinatorSerializable info, String id, String kind) throws CoordinatorClientException {
    if (info == null) {
        return;
    }
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state & version exists in available
            if (!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 : 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 35 with ConfigurationImpl

use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.

the class InterVDCTokenCacheHelper method saveTokenKeysBundle.

/**
 * Stores the token key bundle in cache (zookeeper path based on vdcid)
 * Locks on vdcid for the write.
 *
 * @param vdcID
 * @param bundle
 */
private synchronized void saveTokenKeysBundle(String vdcID, TokenKeysBundle bundle) {
    InterProcessLock tokenBundleLock = null;
    try {
        tokenBundleLock = coordinator.getLock(FOREIGN_TOKEN_BUNDLE_CONFIG_LOCK);
        if (tokenBundleLock == null) {
            log.error("Could not acquire lock for tokenkeys bundle caching");
            throw SecurityException.fatals.couldNotAcquireLockTokenCaching();
        }
        tokenBundleLock.acquire();
        Configuration config = coordinator.queryConfiguration(FOREIGN_TOKEN_KEYS_BUNDLE_CONFIG, FOREIGN_TOKEN_KEYS_BUNDLE_KEYID);
        ConfigurationImpl configImpl = null;
        if (config == null) {
            configImpl = new ConfigurationImpl();
            configImpl.setId(FOREIGN_TOKEN_KEYS_BUNDLE_KEYID);
            configImpl.setKind(FOREIGN_TOKEN_KEYS_BUNDLE_CONFIG);
            log.debug("Creating new foreign tokens config");
        } else {
            configImpl = (ConfigurationImpl) config;
            log.debug("Updating existing foreign token config");
        }
        configImpl.setConfig(vdcID, SerializerUtils.serializeAsBase64EncodedString(bundle));
        coordinator.persistServiceConfiguration(configImpl);
        foreignTokenKeysMap.put(vdcID, bundle);
    } catch (Exception ex) {
        log.error("Could not acquire lock while trying to cache tokenkeys bundle.", ex);
    } finally {
        try {
            if (tokenBundleLock != null) {
                tokenBundleLock.release();
            }
        } catch (Exception ex) {
            log.error("Unable to release token keys bundle caching lock", ex);
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) SecurityException(com.emc.storageos.security.exceptions.SecurityException)

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