Search in sources :

Example 1 with CoordinatorClassInfo

use of com.emc.storageos.coordinator.client.model.CoordinatorClassInfo in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method getTargetInfo.

@Override
public <T extends CoordinatorSerializable> T getTargetInfo(String siteId, final Class<T> clazz) throws CoordinatorException {
    T info;
    try {
        info = clazz.newInstance();
    } catch (Exception e) {
        log.error("Failed to create instance according class {}, {}", clazz, e);
        throw CoordinatorException.fatals.unableToCreateInstanceOfTargetInfo(clazz.getName(), e);
    }
    final CoordinatorClassInfo coordinatorInfo = info.getCoordinatorClassInfo();
    String id = coordinatorInfo.id;
    String kind = coordinatorInfo.kind;
    return getTargetInfo(siteId, clazz, id, kind);
}
Also used : CoordinatorClassInfo(com.emc.storageos.coordinator.client.model.CoordinatorClassInfo) 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 2 with CoordinatorClassInfo

use of com.emc.storageos.coordinator.client.model.CoordinatorClassInfo in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method removeTargetInfo.

/**
 * Remove target info shared by all nodes.
 * checkClusterUpgradable = true is used for rest api's. It forces to check the cluster state stable or not.
 * checkClusterUpgradable = false will not check the cluster state. It is used when cluster is not in stable state,
 * but we have to set target info at the same time.
 *
 * @param info
 * @param checkClusterUpgradable
 * @throws CoordinatorClientException
 */
public void removeTargetInfo(final CoordinatorSerializable info, boolean checkClusterUpgradable) throws CoordinatorClientException {
    if (info == null) {
        return;
    }
    final CoordinatorClassInfo coordinatorInfo = info.getCoordinatorClassInfo();
    String id = coordinatorInfo.id;
    String kind = coordinatorInfo.kind;
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state if checkState = true specified
            if (checkClusterUpgradable && !isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl cfg = new ConfigurationImpl();
            cfg.setId(id);
            cfg.setKind(kind);
            cfg.setConfig(TARGET_INFO, info.encodeAsString());
            _coordinator.removeServiceConfiguration(cfg);
            _log.info("Target info removed: {}", info);
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. Unable to obtain target lock");
    }
}
Also used : CoordinatorClassInfo(com.emc.storageos.coordinator.client.model.CoordinatorClassInfo) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 3 with CoordinatorClassInfo

use of com.emc.storageos.coordinator.client.model.CoordinatorClassInfo in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method setTargetInfo.

/**
 * Update target info(for specific site) to ZK
 *
 * @param info
 * @throws CoordinatorException
 */
public void setTargetInfo(String siteId, final CoordinatorSerializable info) throws CoordinatorException {
    final CoordinatorClassInfo coordinatorInfo = info.getCoordinatorClassInfo();
    String id = coordinatorInfo.id;
    String kind = coordinatorInfo.kind;
    ConfigurationImpl cfg = new ConfigurationImpl();
    cfg.setId(id);
    cfg.setKind(kind);
    cfg.setConfig(TARGET_INFO, info.encodeAsString());
    persistServiceConfiguration(siteId, cfg);
    if (siteId == null) {
        log.info("Target info set: {} for local site", info);
    } else {
        log.info("Target info set: {} for site {}", info, siteId);
    }
}
Also used : CoordinatorClassInfo(com.emc.storageos.coordinator.client.model.CoordinatorClassInfo) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Aggregations

CoordinatorClassInfo (com.emc.storageos.coordinator.client.model.CoordinatorClassInfo)3 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)2 IOException (java.io.IOException)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)1 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)1 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)1 UnknownHostException (java.net.UnknownHostException)1 KeeperException (org.apache.zookeeper.KeeperException)1