ExternalView view = new ExternalView(resourceId.stringify());
// 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
ResourceConfig resource = resourceMap.get(resourceId);
RebalancerConfig rebalancerConfig = resource.getRebalancerConfig();
SchedulerTaskConfig schedulerTaskConfig = resource.getSchedulerTaskConfig();
if (resource.getBucketSize() > 0) {
view.setBucketSize(resource.getBucketSize());
} else {
view.setBucketSize(currentStateOutput.getBucketSize(resourceId));
}
for (PartitionId partitionId : resource.getSubUnitMap().keySet()) {
Map<ParticipantId, State> currentStateMap =
currentStateOutput.getCurrentStateMap(resourceId, partitionId);
if (currentStateMap != null && currentStateMap.size() > 0) {
// Set<String> disabledInstances
// = cache.getDisabledInstancesForResource(resource.toString());
for (ParticipantId participantId : currentStateMap.keySet()) {
// if (!disabledInstances.contains(instance))
// {
view.setState(partitionId.stringify(), participantId.stringify(),
currentStateMap.get(participantId).toString());
// }
}
}
}
// TODO fix this
// 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(resourceId.stringify());
if (curExtView == null || !curExtView.getRecord().equals(view.getRecord())) {
keys.add(keyBuilder.externalView(resourceId.stringify()));
newExtViews.add(view);
// For SCHEDULER_TASK_RESOURCE resource group (helix task queue), we need to find out which
// task
// partitions are finished (COMPLETED or ERROR), update the status update of the original
// scheduler
// message, and then remove the partitions from the ideal state
RebalancerContext rebalancerContext =
(rebalancerConfig != null) ? rebalancerConfig
.getRebalancerContext(RebalancerContext.class) : null;
if (rebalancerContext != null
&& rebalancerContext.getStateModelDefId().equalsIgnoreCase(
StateModelDefId.SchedulerTaskQueue)) {
updateScheduledTaskStatus(resourceId, view, manager, schedulerTaskConfig);