Search in sources :

Example 76 with Configuration

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

the class SiteTest method test.

@Test
public void test() {
    site.setNodeCount(3);
    site.setUuid("uuid-1");
    site.setVip("10.247.101.158");
    site.getHostIPv4AddressMap().put("node1", "10.247.101.157");
    site.getHostIPv4AddressMap().put("node2", "10.247.101.156");
    site.getHostIPv4AddressMap().put("node3", "10.247.101.155");
    site.getHostIPv4AddressMap().put("node4", "10.247.101.154");
    site.getHostIPv4AddressMap().put("node5", "10.247.101.153");
    Configuration configuration = site.toConfiguration();
    Site target = new Site(configuration);
    for (int i = 1; i <= site.getNodeCount(); i++) {
        assertEquals(site.getHostIPv4AddressMap().get("node" + i), target.getHostIPv4AddressMap().get("node" + i));
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) Test(org.junit.Test)

Example 77 with Configuration

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

the class DrPostFailoverHandler method updateStatus.

/**
 * Update execution status for current handler
 *
 * @param status
 */
protected void updateStatus(Status status) {
    Configuration config = coordinator.queryConfiguration(CONFIG_KIND, CONFIG_ID);
    if (config == null) {
        ConfigurationImpl configImpl = new ConfigurationImpl();
        configImpl.setKind(CONFIG_KIND);
        configImpl.setId(CONFIG_ID);
        config = configImpl;
    }
    config.setConfig(name, status.toString());
    coordinator.persistServiceConfiguration(config);
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 78 with Configuration

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

the class DrUtil method listSites.

/**
 * List all sites in given vdc
 *
 * @return list of all sites
 */
public List<Site> listSites(String vdcShortId) {
    List<Site> result = new ArrayList<>();
    String siteKind = String.format("%s/%s", Site.CONFIG_KIND, vdcShortId);
    for (Configuration siteConfig : coordinator.queryAllConfiguration(siteKind)) {
        result.add(new Site(siteConfig));
    }
    return result;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) Configuration(com.emc.storageos.coordinator.common.Configuration) ArrayList(java.util.ArrayList)

Example 79 with Configuration

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

the class CoordinatorClientImpl method getMigrationStatus.

public MigrationStatus getMigrationStatus() {
    log.debug("getMigrationStatus: target version: \"{}\"", getTargetDbSchemaVersion());
    // TODO support geodbsvc
    Configuration config = queryConfiguration(_zkConnection.getSiteId(), getVersionedDbConfigPath(Constants.DBSVC_NAME, getTargetDbSchemaVersion()), GLOBAL_ID);
    if (config == null || config.getConfig(MIGRATION_STATUS) == null) {
        log.debug("config is null");
        return null;
    }
    MigrationStatus status = MigrationStatus.valueOf(config.getConfig(MIGRATION_STATUS));
    log.debug("status: {}", status);
    return status;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) MigrationStatus(com.emc.storageos.coordinator.client.model.MigrationStatus)

Example 80 with Configuration

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

the class CoordinatorClientImpl method loadInetAddressFromCoordinator.

/**
 * Try to look up the node in zk configuration - this is called ONLY if map does not have it.
 *
 * @param nodeId
 *            the node in the lookup, any node
 * @return DualInetAddress of the node
 */
public DualInetAddress loadInetAddressFromCoordinator(String nodeId) {
    DualInetAddress dualAddress = null;
    // grab the lock
    InterProcessLock lock = null;
    try {
        lock = getLock(NODE_DUALINETADDR_CONFIG + nodeId);
        lock.acquire();
        Configuration config = queryConfiguration(Constants.NODE_DUALINETADDR_CONFIG, nodeId);
        if (config != null) {
            dualAddress = parseInetAddressConfig(config);
        }
    } catch (Exception e) {
        log.warn("Unexpected exception during loadInetAddressFromCoordinator()", e);
    } finally {
        if (lock != null) {
            try {
                lock.release();
            } catch (Exception e) {
                log.warn("Unexpected exception unlocking loadInetAddressFromCoordinator()", e);
            }
        }
    }
    // Add it to the map
    if (dualAddress != null) {
        inetAddressLookupMap.put(nodeId, dualAddress);
    }
    return dualAddress;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) 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)

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