use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method removeServiceConfiguration.
@Override
public void removeServiceConfiguration(String siteId, Configuration... configs) throws CoordinatorException {
for (int i = 0; i < configs.length; i++) {
Configuration config = configs[i];
String prefix = "";
if (siteId != null) {
prefix = getSitePrefix(siteId);
}
String servicePath = String.format("%1$s%2$s/%3$s/%4$s", prefix, ZkPath.CONFIG, config.getKind(), config.getId());
try {
CuratorTransaction handler = zkTransactionHandler.get();
if (handler != null) {
CuratorTransactionFinal tx = handler.delete().forPath(servicePath).and();
zkTransactionHandler.set(tx);
} else {
_zkConnection.curator().delete().forPath(servicePath);
}
} catch (KeeperException.NoNodeException ignore) {
// Ignore exception, don't re-throw
log.debug("Caught exception but ignoring it: " + ignore);
} catch (Exception e) {
throw CoordinatorException.fatals.unableToRemoveConfiguration(config.getId(), e);
}
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class EncryptionProviderImpl method cacheKey.
/**
* Reads existing encryption key from coordinator and caches it
*
* @throws Exception
*/
private synchronized void cacheKey() throws Exception {
Configuration config = _coordinator.queryConfiguration(CONFIG_KIND, _encryptId);
if (config != null) {
readKey(config);
} else {
// key has not been generated
InterProcessLock lock = null;
try {
lock = _coordinator.getLock(CONFIG_KIND);
lock.acquire();
config = _coordinator.queryConfiguration(CONFIG_KIND, _encryptId);
if (config == null) {
_logger.warn("Encryption key not found, initializing it");
generateKey();
} else {
readKey(config);
}
} finally {
if (lock != null) {
lock.release();
}
}
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class HostSupplierImpl method isDbReinitializing.
private boolean isDbReinitializing(Service serviceInfo) {
String configKind = _coordinator.getDbConfigPath(serviceInfo.getName());
Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, serviceInfo.getId());
String value = config.getConfig(Constants.REINIT_DB);
return (value != null && Boolean.parseBoolean(value));
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class GeoTest method checkCleanDbFlag.
@SuppressWarnings("unused")
private void checkCleanDbFlag(String svcName) throws Exception {
String kind = coordinatorClient.getDbConfigPath(svcName);
String id = svcName.equals(Constants.DBSVC_NAME) ? "db-standalone" : "geodb-standalone";
Configuration config = coordinatorClient.queryConfiguration(kind, id);
// Assert.assertEquals(config.getConfig(Constants.RESET_DB),
// String.valueOf(true));
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class GeoDbSvcStartupTest method checkDbConfig.
@Test
public void checkDbConfig() throws Exception {
CoordinatorClient coordinator = runner.getCoordinator();
// Check dbconfig
String kind = coordinator.getDbConfigPath(Constants.GEODBSVC_NAME);
Configuration config = coordinator.queryConfiguration(coordinator.getSiteId(), kind, DbSvcRunner.GEOSVC_ID);
Assert.assertNotNull("No dbconfig found", config);
String value = config.getConfig(DbConfigConstants.JOINED);
Assert.assertTrue("dbconfig joined flag is false", "true".equalsIgnoreCase(value));
// Check dbconfig/global
config = coordinator.queryConfiguration(coordinator.getSiteId(), kind, Constants.GLOBAL_ID);
Assert.assertNotNull("No dbconfig/global found", config);
value = config.getConfig(Constants.SCHEMA_VERSION);
Assert.assertTrue("Unexpected dbconfig/global schemaversion", DbSvcRunner.SVC_VERSION.equalsIgnoreCase(value));
// Check versioned dbconfig
kind = coordinator.getVersionedDbConfigPath(Constants.GEODBSVC_NAME, DbSvcRunner.SVC_VERSION);
config = coordinator.queryConfiguration(coordinator.getSiteId(), kind, DbSvcRunner.GEOSVC_ID);
Assert.assertNotNull("No versioned dbconfig found", config);
value = config.getConfig(DbConfigConstants.INIT_DONE);
Assert.assertTrue("Unexpected versioned dbconfig initdone", "true".equalsIgnoreCase(value));
log.info("Check db config OK");
}
Aggregations