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);
}
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");
}
}
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);
}
}
Aggregations