Search in sources :

Example 21 with ConfigurationImpl

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

the class RecoveryManager method persistNodeRecoveryStatus.

/**
 * Persist recovery status to ZK
 */
private void persistNodeRecoveryStatus(RecoveryStatus status) {
    log.info("Set node recovery status: {}", status);
    if (status == null) {
        return;
    }
    ConfigurationImpl cfg = new ConfigurationImpl();
    cfg.setKind(Constants.NODE_RECOVERY_STATUS);
    cfg.setId(Constants.GLOBAL_ID);
    cfg.setConfig(RecoveryConstants.RECOVERY_STATUS, status.getStatus().toString());
    if (status.getStartTime() != null) {
        cfg.setConfig(RecoveryConstants.RECOVERY_STARTTIME, String.valueOf(status.getStartTime().getTime()));
    }
    if (status.getEndTime() != null) {
        cfg.setConfig(RecoveryConstants.RECOVERY_ENDTIME, String.valueOf(status.getEndTime().getTime()));
    }
    if (status.getErrorCode() != null) {
        cfg.setConfig(RecoveryConstants.RECOVERY_ERRCODE, status.getErrorCode().toString());
    }
    coordinator.getCoordinatorClient().persistServiceConfiguration(cfg);
    log.debug("Persist node recovery status({}) to zk successfully", status);
}
Also used : ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 22 with ConfigurationImpl

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

the class CoordinatorConfigStoringHelper method createOrUpdateConfig.

/**
 * Creates or updates a new entry of the specified type in coordinator. If siteId
 * is not null, the config is in zk site specific area. Otherwise in global area
 *
 * @param objToPersist
 *            the object to store in coordinator
 * @param lockName
 *            the name of the lock to use while storing this object
 *            If passed as Null, lock is assumed to be already owned
 * @param configKInd
 * @param configId
 * @param ConfigKey
 * @throws Exception
 */
public void createOrUpdateConfig(Object objToPersist, String lockName, String siteId, String configKInd, String configId, String ConfigKey) throws Exception {
    InterProcessLock lock = acquireLock(lockName);
    try {
        if (lock != null) {
            Configuration config = coordinator.queryConfiguration(siteId, configKInd, configId);
            ConfigurationImpl configImpl = null;
            if (config == null) {
                configImpl = new ConfigurationImpl();
                configImpl.setId(configId);
                configImpl.setKind(configKInd);
                log.debug("Creating new config");
            } else {
                configImpl = (ConfigurationImpl) config;
                if (config.getKind() == null) {
                    ((ConfigurationImpl) config).setKind(configKInd);
                }
                if (config.getId() == null) {
                    ((ConfigurationImpl) config).setId(configId);
                }
                log.debug("Updating existing config");
            }
            configImpl.setConfig(ConfigKey, SerializerUtils.serializeAsBase64EncodedString(objToPersist));
            coordinator.persistServiceConfiguration(siteId, configImpl);
            log.debug("Updated config successfully");
        }
    } finally {
        releaseLock(lock);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 23 with ConfigurationImpl

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

the class GeoDbSvcStartupTest method setLocalDbCurrentVersion.

private static void setLocalDbCurrentVersion(CoordinatorClient coordinator) throws Exception {
    Configuration config = coordinator.queryConfiguration(coordinator.getSiteId(), Constants.DB_CONFIG, Constants.GLOBAL_ID);
    if (config == null) {
        ConfigurationImpl cfg = new ConfigurationImpl();
        cfg.setId(Constants.GLOBAL_ID);
        cfg.setKind(Constants.DB_CONFIG);
        config = cfg;
    }
    config.setConfig(Constants.SCHEMA_VERSION, DbSvcRunner.SVC_VERSION);
    coordinator.persistServiceConfiguration(coordinator.getSiteId(), config);
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 24 with ConfigurationImpl

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

the class VdcConfigHelper method createVdcConfigInZk.

public void createVdcConfigInZk(VdcConfig vdc, String ipsecKey) {
    log.info("Update Vdc info to zk {}", vdc.getShortId());
    // Insert vdc info
    ConfigurationImpl vdcConfig = new ConfigurationImpl();
    vdcConfig.setKind(Site.CONFIG_KIND);
    vdcConfig.setId(vdc.getShortId());
    coordinator.persistServiceConfiguration(vdcConfig);
    // insert DR active site info to ZK
    Site site = new Site();
    site.setUuid(vdc.getActiveSiteId());
    site.setName("Default Active Site");
    site.setVdcShortId(vdc.getShortId());
    site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
    site.setHostIPv4AddressMap(vdc.getHostIPv4AddressesMap());
    site.setHostIPv6AddressMap(vdc.getHostIPv6AddressesMap());
    site.setState(SiteState.ACTIVE);
    site.setCreationTime(System.currentTimeMillis());
    String vdcEndpoint = vdc.getApiEndpoint();
    if (vdcEndpoint.contains(":")) {
        site.setVip6(vdcEndpoint);
        site.setVip(PropertyConstants.IPV4_ADDR_DEFAULT);
    } else {
        site.setVip(vdcEndpoint);
        site.setVip6(PropertyConstants.IPV6_ADDR_DEFAULT);
    }
    site.setNodeCount(vdc.getHostCount());
    coordinator.persistServiceConfiguration(site.toConfiguration());
    ipsecConfig.setPreSharedKey(ipsecKey);
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 25 with ConfigurationImpl

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

the class BackupOps method setGeoFlag.

public synchronized void setGeoFlag(String backupName, boolean isLocal) {
    BackupRestoreStatus state = queryBackupRestoreStatus(backupName, isLocal);
    state.setGeo(true);
    log.info("Persist backup restore status {} stack=", state, new Throwable());
    Map<String, String> allItems = state.toMap();
    ConfigurationImpl config = new ConfigurationImpl();
    config.setKind(getBackupConfigKind(isLocal));
    config.setId(backupName);
    for (Map.Entry<String, String> entry : allItems.entrySet()) {
        config.setConfig(entry.getKey(), entry.getValue());
    }
    coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
    log.info("Persist backup restore status to zk successfully");
}
Also used : BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)

Aggregations

ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)51 Configuration (com.emc.storageos.coordinator.common.Configuration)16 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)8 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 IOException (java.io.IOException)6 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)6 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)5 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)5 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)5 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)4 Site (com.emc.storageos.coordinator.client.model.Site)4 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)4 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)4 HashMap (java.util.HashMap)4 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 Map (java.util.Map)3 CoordinatorClassInfo (com.emc.storageos.coordinator.client.model.CoordinatorClassInfo)2 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)2 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)2