boolean ignoreObsoleteNode) {
ClusterEntity cluster = findByName(clusterName);
if (cluster == null) {
throw BddException.NOT_FOUND("Cluster", clusterName);
}
ClusterStatus clusterStatus = cluster.getStatus();
ClusterRead clusterRead = new ClusterRead();
clusterRead
.setInstanceNum(cluster.getRealInstanceNum(ignoreObsoleteNode));
clusterRead.setName(cluster.getName());
clusterRead.setStatus(clusterStatus);
clusterRead.setAppManager(cluster.getAppManager());
clusterRead.setDistro(cluster.getDistro());
clusterRead.setDistroVendor(cluster.getDistroVendor());
clusterRead.setTopologyPolicy(cluster.getTopologyPolicy());
clusterRead.setAutomationEnable(cluster.getAutomationEnable());
clusterRead.setVhmMinNum(cluster.getVhmMinNum());
clusterRead.setVhmMaxNum(cluster.getVhmMaxNum());
clusterRead.setVhmTargetNum(cluster.getVhmTargetNum());
clusterRead.setIoShares(cluster.getIoShares());
clusterRead.setVersion(cluster.getVersion());
if (!CommonUtil.isBlank(cluster.getAdvancedProperties())) {
Gson gson = new Gson();
Map<String, String> advancedProperties =
gson.fromJson(cluster.getAdvancedProperties(), Map.class);
clusterRead.setExternalHDFS(advancedProperties.get("ExternalHDFS"));
clusterRead.setExternalMapReduce(advancedProperties
.get("ExternalMapReduce"));
clusterRead.setLocalRepoURL(advancedProperties.get("LocalRepoURL"));
}
SoftwareManager softMgr = null;
try {
softMgr =
softwareManagerCollector.getSoftwareManager(cluster
.getAppManager());
} catch (Exception e) {
logger.error("Failed to get softwareManger.");
// do not throw exception for exporting cluster info
}
List<NodeGroupRead> groupList = new ArrayList<NodeGroupRead>();
for (NodeGroupEntity group : cluster.getNodeGroups()) {
NodeGroupRead groupRead = group.toNodeGroupRead(ignoreObsoleteNode);
groupRead.setComputeOnly(false);
try {
groupRead.setComputeOnly(softMgr.isComputeOnlyRoles(groupRead
.getRoles()));
} catch (Exception e) {
}
groupList.add(groupRead);
}
clusterRead.setNodeGroups(groupList);
Set<VcResourcePoolEntity> rps = cluster.getUsedRps();
List<ResourcePoolRead> rpReads =
new ArrayList<ResourcePoolRead>(rps.size());
for (VcResourcePoolEntity rp : rps) {
ResourcePoolRead rpRead = rp.toRest();
rpRead.setNodes(null);
rpReads.add(rpRead);
}
clusterRead.setResourcePools(rpReads);
if (clusterStatus.isActiveServiceStatus()
|| clusterStatus == ClusterStatus.STOPPED) {
clusterRead.setDcSeperation(clusterRead.validateSetManualElasticity());
}
return clusterRead;