Github user kongweihan commented on a diff in the pull request:

    https://github.com/apache/helix/pull/88#discussion_r117354732
  
    --- Diff: helix-core/src/main/java/org/apache/helix/task/JobRebalancer.java 
---
    @@ -455,6 +454,44 @@ private ResourceAssignment 
computeResourceMapping(String jobResource,
         return ra;
       }
     
    +  /**
    +   * If assignment is different from previous assignment, drop the old 
running task if it's no
    +   * longer assigned to the same instance, but not removing it from 
excludeSet because the same task
    +   * should not be assigned to the new instance right way.
    +   */
    +  private void dropRebalancedRunningTasks(Map<String, SortedSet<Integer>> 
newAssignment,
    +      Map<String, SortedSet<Integer>> oldAssignment, Map<Integer, 
PartitionAssignment> paMap,
    +      JobContext jobContext) {
    +    for (String instance : oldAssignment.keySet()) {
    +      for (Integer pId : oldAssignment.get(instance)) {
    +        if (jobContext.getPartitionState(pId) == TaskPartitionState.RUNNING
    +            && !newAssignment.get(instance).contains(pId)) {
    +          paMap.put(pId, new PartitionAssignment(instance, 
TaskPartitionState.DROPPED.name()));
    +          jobContext.setPartitionState(pId, TaskPartitionState.DROPPED);
    --- End diff --
    
    You're right. However, on the other hand, if we don't set it, after the 
task is actually dropped, its CurrentState is deleted and JobRebalancer won't 
update the DROPPED state into JobContext. After the same task is scheduled 
again, it will be set to INIT. If something's wrong and the task is not 
scheduled, during this period the JobContext state is RUNNING but the task is 
already dropped.
    
    Which way do you think is better?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to