Map<String, ExternalView> curExtViews =
dataAccessor.getChildValuesMap(keyBuilder.externalViews());
for (String resourceName : resourceMap.keySet()) {
ExternalView view = new ExternalView(resourceName);
// view.setBucketSize(currentStateOutput.getBucketSize(resourceName));
// if resource ideal state has bucket size, set it
// otherwise resource has been dropped, use bucket size from current state instead
Resource resource = resourceMap.get(resourceName);
if (resource.getBucketSize() > 0) {
view.setBucketSize(resource.getBucketSize());
} else {
view.setBucketSize(currentStateOutput.getBucketSize(resourceName));
}
for (Partition partition : resource.getPartitions()) {
Map<String, String> currentStateMap =
currentStateOutput.getCurrentStateMap(resourceName, partition);
if (currentStateMap != null && currentStateMap.size() > 0) {
// Set<String> disabledInstances
// = cache.getDisabledInstancesForResource(resource.toString());
for (String instance : currentStateMap.keySet()) {
// if (!disabledInstances.contains(instance))
// {
view.setState(partition.getPartitionName(), instance, currentStateMap.get(instance));
// }
}
}
}
// Update cluster status monitor mbean
ClusterStatusMonitor clusterStatusMonitor =
(ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
IdealState idealState = cache._idealStateMap.get(view.getResourceName());
if (idealState != null) {
if (clusterStatusMonitor != null
&& !idealState.getStateModelDefRef().equalsIgnoreCase(
DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE)) {
clusterStatusMonitor.onExternalViewChange(view,
cache._idealStateMap.get(view.getResourceName()));
}
}
// compare the new external view with current one, set only on different
ExternalView curExtView = curExtViews.get(resourceName);
if (curExtView == null || !curExtView.getRecord().equals(view.getRecord())) {
keys.add(keyBuilder.externalView(resourceName));
newExtViews.add(view);
// For SCHEDULER_TASK_RESOURCE resource group (helix task queue), we need to find out which
// task