Search in sources :

Example 6 with Configuration

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

the class DbServiceImpl method checkConfiguration.

/**
 * Checks and registers db configuration information,
 * this is one time when cluster is coming up for the first time
 */
private Configuration checkConfiguration() {
    String configKind = _coordinator.getDbConfigPath(_serviceInfo.getName());
    Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
    if (config == null) {
        // check if it is upgraded from previous version to yoda - configuration may be stored in
        // zk global area /config. Since SeedProvider still need access that, so we remove the config
        // from global in migration callback after migration is done.
        config = _coordinator.queryConfiguration(configKind, _serviceInfo.getId());
        if (config != null) {
            _log.info("Upgrade from pre-yoda release, move dbconfig to new location");
            _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
            return config;
        }
        // this is a new node
        // 1. register its configuration with coordinator
        // 2. assume autobootstrap configuration
        // this means that when a node is added, it take 1/2 of biggest token rage and
        // copies its data over
        ConfigurationImpl cfg = new ConfigurationImpl();
        cfg.setId(_serviceInfo.getId());
        cfg.setKind(configKind);
        cfg.setConfig(DbConfigConstants.NODE_ID, _coordinator.getInetAddessLookupMap().getNodeId());
        cfg.setConfig(DbConfigConstants.AUTOBOOT, Boolean.TRUE.toString());
        // check other existing db nodes
        List<Configuration> configs = _coordinator.queryAllConfiguration(_coordinator.getSiteId(), configKind);
        if (configs.isEmpty()) {
            // we are the first node - turn off autobootstrap
            cfg.setConfig(DbConfigConstants.AUTOBOOT, Boolean.FALSE.toString());
        }
        // persist configuration
        _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), cfg);
        config = cfg;
    }
    return config;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 7 with Configuration

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

the class DbServiceImpl method removeStaleServiceConfiguration.

private void removeStaleServiceConfiguration() {
    boolean isGeoDBSvc = isGeoDbsvc();
    boolean resetAutoBootFlag = false;
    String configKind = _coordinator.getDbConfigPath(_serviceInfo.getName());
    List<Configuration> configs = _coordinator.queryAllConfiguration(_coordinator.getSiteId(), configKind);
    for (Configuration config : configs) {
        if (isStaleConfiguration(config)) {
            boolean autoboot = Boolean.parseBoolean(config.getConfig(DbConfigConstants.AUTOBOOT));
            String configId = config.getId();
            if (isGeoDBSvc && !autoboot && (configId.equals("geodb-4") || configId.equals("geodb-5"))) {
                // for geodbsvc, if restore with the backup of 5 nodes to 3 nodes and the backup is made
                // on the cluster that the 'autoboot=false' is set on vipr4 or vipr5
                // we should set the autoboot=false on the current node or no node with autoboot=false
                // TODO:This is a temporary/safest solution in Yoda, we'll provide a better soltuion post Yoda
                resetAutoBootFlag = true;
            }
            if (isStaleConfiguration(config)) {
                _coordinator.removeServiceConfiguration(_coordinator.getSiteId(), config);
                _log.info("Remove stale db config, id: {}", config.getId());
            }
        }
    }
    if (resetAutoBootFlag) {
        _log.info("set autoboot flag to false on {}", _serviceInfo.getId());
        Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
        config.setConfig(DbConfigConstants.AUTOBOOT, Boolean.FALSE.toString());
        _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 8 with Configuration

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

the class DbServiceImpl method getConfigValue.

public String getConfigValue(String key) {
    String configKind = _coordinator.getDbConfigPath(_serviceInfo.getName());
    Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
    if (config != null) {
        return config.getConfig(key);
    }
    return null;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 9 with Configuration

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

the class DbServiceImpl method removeStaleVersionedDbConfiguration.

private void removeStaleVersionedDbConfiguration() {
    String configKind = _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
    List<Configuration> configs = _coordinator.queryAllConfiguration(_coordinator.getSiteId(), configKind);
    for (Configuration config : configs) {
        if (isStaleConfiguration(config)) {
            _coordinator.removeServiceConfiguration(_coordinator.getSiteId(), config);
            _log.info("Remove stale version db config, id: {}", config.getId());
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 10 with Configuration

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

the class DbServiceImpl method setDbConfigInitDone.

/**
 * Checks and sets INIT_DONE state
 * this means we are done with the actual cf changes on the cassandra side for the target version
 */
private void setDbConfigInitDone() {
    String configKind = _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
    Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
    if (config != null) {
        if (config.getConfig(DbConfigConstants.INIT_DONE) == null) {
            config.setConfig(DbConfigConstants.INIT_DONE, Boolean.TRUE.toString());
            _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
        }
    } else {
        // we are expecting this to exist, because its initialized from checkVersionedConfiguration
        throw new IllegalStateException("unexpected error, db versioned configuration is null");
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

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