Search in sources :

Example 51 with Configuration

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

the class SeedProviderImpl method getSeeds.

/**
 *  We select seeds based on the following rules -
 *  For DR standby sites, use all nodes in active site as seeds
 *  For DR active site, use local nodes as seeds. The rule to select local seed is
 *    - first boot node(AUTOBOOT = false) uses itself as seed nodes so that it could boot and initialize schema
 *    - subsquent node(AUTOBOOT = true) uses other successfully booted(JOINED = true) nodes as seeds
 */
@Override
public List<InetAddress> getSeeds() {
    try {
        CoordinatorClientInetAddressMap nodeMap = _client.getInetAddessLookupMap();
        List<Configuration> configs = _client.queryAllConfiguration(_client.getSiteId(), Constants.DB_CONFIG);
        List<InetAddress> seeds = new ArrayList<>();
        // If we are upgrading from pre-2.5 releases, dbconfig exists in zk global area
        List<Configuration> leftoverConfig = _client.queryAllConfiguration(Constants.DB_CONFIG);
        configs.addAll(leftoverConfig);
        // Add extra seeds - seeds from remote sites
        for (String seed : extraSeeds) {
            if (StringUtils.isNotEmpty(seed)) {
                seeds.add(InetAddress.getByName(seed));
            }
        }
        for (int i = 0; i < configs.size(); i++) {
            Configuration config = configs.get(i);
            // Bypasses item of "global" and folders of "version", just check db configurations.
            if (config.getId() == null || config.getId().equals(Constants.GLOBAL_ID)) {
                continue;
            }
            String nodeId = config.getConfig(DbConfigConstants.NODE_ID);
            if (!Boolean.parseBoolean(config.getConfig(DbConfigConstants.AUTOBOOT)) || (!config.getId().equals(_id) && Boolean.parseBoolean(config.getConfig(DbConfigConstants.JOINED)))) {
                // all non autobootstrap nodes + other nodes are used as seeds
                InetAddress ip = null;
                if (nodeMap != null) {
                    String ipAddress = nodeMap.getConnectableInternalAddress(nodeId);
                    _logger.debug("ip[" + i + "]: " + ipAddress);
                    ip = InetAddress.getByName(ipAddress);
                } else {
                    ip = InetAddress.getByName(nodeId);
                }
                seeds.add(ip);
                _logger.info("Seed {}", ip);
            }
        }
        _logger.info("Seeds list {}", StringUtils.join(seeds.toArray(), ","));
        return seeds;
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress)

Example 52 with Configuration

use of com.emc.storageos.coordinator.common.Configuration 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 53 with Configuration

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

the class DbServiceStatusChecker method isClusterStateDone.

/**
 * Checks to see if the cassandra cluster finished entering a certain state
 */
private boolean isClusterStateDone(String state, boolean isVersioned, String svcName) throws Exception {
    if (clusterNodeCount == 0) {
        throw new IllegalStateException("node count not set");
    }
    List<Configuration> configs = coordinator.queryAllConfiguration(coordinator.getSiteId(), coordinator.getVersionedDbConfigPath(svcName, getDbsvcVersion(isVersioned)));
    List<Configuration> leftoverConfig = coordinator.queryAllConfiguration(coordinator.getVersionedDbConfigPath(svcName, getDbsvcVersion(isVersioned)));
    configs.addAll(leftoverConfig);
    Set<String> qualifiedConfigs = new HashSet<String>();
    for (int i = 0; i < configs.size(); i++) {
        Configuration config = configs.get(i);
        String value = config.getConfig(state);
        if (value != null && Boolean.parseBoolean(value)) {
            qualifiedConfigs.add(config.getId());
        }
    }
    return (qualifiedConfigs.size() == clusterNodeCount);
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) HashSet(java.util.HashSet)

Example 54 with Configuration

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

the class DbServiceStatusChecker method isAnyNodeInState.

/**
 * Checks to see if any node in the cluster has entered a certain state
 */
private boolean isAnyNodeInState(String state, boolean isVersioned) throws Exception {
    List<Configuration> configs = coordinator.queryAllConfiguration(coordinator.getSiteId(), coordinator.getVersionedDbConfigPath(serviceName, getDbsvcVersion(isVersioned)));
    for (int i = 0; i < configs.size(); i++) {
        Configuration config = configs.get(i);
        String value = config.getConfig(state);
        if (value != null && Boolean.parseBoolean(value)) {
            return true;
        }
    }
    return false;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 55 with Configuration

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

the class StorageDriverManager method getUpgradeDriverMetaDataMap.

private Map<String, StorageDriverMetaData> getUpgradeDriverMetaDataMap() {
    List<Configuration> configs = coordinatorClient.queryAllConfiguration(StorageDriverMetaData.KIND);
    Map<String, StorageDriverMetaData> result = new HashMap<String, StorageDriverMetaData>();
    if (configs == null || configs.isEmpty()) {
        return result;
    }
    for (Configuration config : configs) {
        StorageDriverMetaData newMetaData = new StorageDriverMetaData(config);
        result.put(newMetaData.getDriverName(), newMetaData);
    }
    return result;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) HashMap(java.util.HashMap) StorageDriverMetaData(com.emc.storageos.coordinator.client.model.StorageDriverMetaData)

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