ViewStatus status = new ViewStatus();
List<String> viewErrors = new ArrayList<String>();
AmbariClusterInfo clusterInfo = ambariClient.getClusterInfo();
if (clusterInfo != null) {
AmbariCluster cluster = ambariClient.getCluster(clusterInfo);
List<AmbariServiceInfo> services = cluster.getServices();
if (services != null && !services.isEmpty()) {
AmbariServiceInfo hdfsService = null, yarnService = null, zkService = null;
for (AmbariServiceInfo service : services) {
if ("HDFS".equals(service.getId())) {
hdfsService = service;
} else if ("YARN".equals(service.getId())) {
yarnService = service;
} else if ("ZOOKEEPER".equals(service.getId())) {
zkService = service;
}
}
if (hdfsService == null) {
viewErrors.add("Slider applications view requires HDFS service");
} else {
if (!hdfsService.isStarted()) {
viewErrors
.add("Slider applications view requires HDFS service to be started");
}
}
if (yarnService == null) {
viewErrors.add("Slider applications view requires YARN service");
} else {
if (!yarnService.isStarted()) {
viewErrors
.add("Slider applications view requires YARN service to be started");
}
}
if (zkService == null) {
viewErrors.add("Slider applications view requires ZooKeeper service");
} else {
if (!zkService.isStarted()) {
viewErrors
.add("Slider applications view requires ZooKeeper service to be started");
}
}
} else {
viewErrors
.add("Slider applications view is unable to locate any services");
}
// Check security
if (cluster.getDesiredConfigs() != null
&& cluster.getDesiredConfigs().containsKey("global")) {
Map<String, String> globalConfig = ambariClient.getConfiguration(
clusterInfo, "global", cluster.getDesiredConfigs().get("global"));
if (globalConfig != null
&& globalConfig.containsKey("security_enabled")) {
String securityValue = globalConfig.get("security_enabled");
if (Boolean.valueOf(securityValue)) {
viewErrors