Search in sources :

Example 81 with Configuration

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);
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CuratorTransaction(org.apache.curator.framework.api.transaction.CuratorTransaction) CuratorTransactionFinal(org.apache.curator.framework.api.transaction.CuratorTransactionFinal) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) KeeperException(org.apache.zookeeper.KeeperException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 82 with Configuration

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

Example 83 with Configuration

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

Example 84 with Configuration

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

Example 85 with Configuration

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

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