Search in sources :

Example 26 with Configuration

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

the class CoordinatorClientImpl method getLicenseInfo.

/**
 * get License Info from coordinator for the specified license type
 *
 * @param licenseType
 * @return LicenseInfo
 */
private LicenseInfo getLicenseInfo(LicenseType licenseType) {
    final Configuration config = queryConfiguration(LicenseInfo.LICENSE_INFO_TARGET_PROPERTY, TARGET_PROPERTY_ID);
    if (config == null || config.getConfig(TARGET_INFO) == null) {
        return null;
    }
    final String infoStr = config.getConfig(TARGET_INFO);
    try {
        List<LicenseInfo> licenseInfoList = LicenseInfo.decodeLicenses(infoStr);
        for (LicenseInfo licenseInfo : licenseInfoList) {
            if (licenseType.equals(licenseInfo.getLicenseType())) {
                log.debug("getLicenseInfo: " + licenseInfo);
                return licenseInfo;
            }
        }
    } catch (final Exception e) {
        throw CoordinatorException.fatals.unableToDecodeLicense(e);
    }
    log.warn("getLicenseInfo: null");
    return null;
}
Also used : LicenseInfo(com.emc.storageos.coordinator.client.service.LicenseInfo) Configuration(com.emc.storageos.coordinator.common.Configuration) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) 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 27 with Configuration

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

the class RecoveryManager method removeOfflineInfo.

private void removeOfflineInfo() {
    Configuration config = coordinator.getCoordinatorClient().queryConfiguration(coordinator.getCoordinatorClient().getSiteId(), Constants.DB_DOWNTIME_TRACKER_CONFIG, Constants.DBSVC_NAME);
    DbOfflineEventInfo dbOfflineEventInfo = new DbOfflineEventInfo(config);
    for (int i = 1; i <= nodeCount; i++) {
        String nodeId = "vipr" + i;
        if (corruptedNodes.contains(nodeId)) {
            if (dbOfflineEventInfo.getOfflineTimeInMS(nodeId) != null) {
                dbOfflineEventInfo.setOfflineTimeInMS(nodeId, null);
                log.info("Removed offline Time info of {}", nodeId);
            }
        }
    }
    config = dbOfflineEventInfo.toConfiguration(Constants.DBSVC_NAME);
    coordinator.getCoordinatorClient().persistServiceConfiguration(coordinator.getCoordinatorClient().getSiteId(), config);
    log.info("Clean offlineTime and Persist db tracker info to zk successfully");
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 28 with Configuration

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

the class SchedulerConfig method isClusterNodeRecovering.

private boolean isClusterNodeRecovering() {
    RecoveryStatus.Status status = null;
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    Configuration cfg = coordinatorClient.queryConfiguration(Constants.NODE_RECOVERY_STATUS, Constants.GLOBAL_ID);
    if (cfg != null) {
        String statusStr = cfg.getConfig(RecoveryConstants.RECOVERY_STATUS);
        if (statusStr != null && statusStr.length() > 0) {
            status = RecoveryStatus.Status.valueOf(statusStr);
        }
    }
    log.info("Recovery status is: {}", status);
    if (status == RecoveryStatus.Status.INIT || status == RecoveryStatus.Status.PREPARING || status == RecoveryStatus.Status.REPAIRING || status == RecoveryStatus.Status.SYNCING) {
        return true;
    }
    return false;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus)

Example 29 with Configuration

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

the class RecoveryManager method validateAutoBootFlag.

private void validateAutoBootFlag() {
    String siteId = coordinator.getCoordinatorClient().getSiteId();
    List<Configuration> configs = coordinator.getCoordinatorClient().queryAllConfiguration(siteId, Constants.DB_CONFIG);
    if (!isAllAutoBootTrue(configs)) {
        log.info("Auto boot flag check passed");
        return;
    }
    log.info("Auto boot flag was set true on all nodes, Change to false for one node");
    for (int i = 0; i < configs.size(); i++) {
        Configuration config = configs.get(i);
        if (config.getId() == null || config.getId().equals(Constants.GLOBAL_ID)) {
            continue;
        }
        config.setConfig(DbConfigConstants.AUTOBOOT, "false");
        coordinator.getCoordinatorClient().persistServiceConfiguration(siteId, config);
        log.info("Persist autoboot info as false on {} to zk successfully", config.getId());
        break;
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 30 with Configuration

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

the class SignatureKeyGenerator method deleteSignatureKey.

/**
 * Delete a particular signature key
 *
 * @param relKeyLocation "leaf" node under \getSignatureKeyConfig()\getSignatureKeyId()\
 * @param relKeyLocation
 * @throws Exception
 */
protected synchronized void deleteSignatureKey(String relKeyLocation) throws Exception {
    Configuration config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
    if (config != null && config.getConfig(relKeyLocation) != null) {
        InterProcessLock lock = null;
        try {
            lock = _coordinator.getLock(getDistributedSignatureKeyLock());
            lock.acquire();
            config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
            config.removeConfig(relKeyLocation);
            _coordinator.persistServiceConfiguration(config);
        } finally {
            if (lock != null) {
                lock.release();
            }
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

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