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);
}
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");
}
}
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);
}
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");
}
}
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);
}
}
}
Aggregations