wilfred-s commented on a change in pull request #252:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/252#discussion_r582679246



##########
File path: pkg/scheduler/partition.go
##########
@@ -967,6 +980,11 @@ func (pc *PartitionContext) GetAppsByState(state string) 
[]*objects.Application
                        appList = append(appList, app)
                }
        }
+       for _, app := range pc.completedApplications {
+               if app.CurrentState() == state {
+                       appList = append(appList, app)

Review comment:
       We should not range over both lists. If the state is _completed_ we 
range over the `completedApplications` map in all other cases we range over the 
`applications` map.

##########
File path: pkg/scheduler/partition.go
##########
@@ -78,6 +79,7 @@ func newPartitionContext(conf configs.PartitionConfig, rmID 
string, cc *ClusterC
                stateMachine: objects.NewObjectState(),
                stateTime:    time.Now(),
                applications: make(map[string]*objects.Application),
+               completedApplications: make(map[string]*objects.Application),

Review comment:
       please run `gofmt` over the file

##########
File path: pkg/scheduler/partition.go
##########
@@ -1222,3 +1240,12 @@ func (pc *PartitionContext) GetNodeSortingPolicy() 
policies.SortingPolicy {
        defer pc.RUnlock()
        return pc.nodeSortingPolicy.PolicyType
 }
+
+func (pc *PartitionContext) moveCompletedApp(appID string) {
+       pc.Lock()
+       defer pc.Unlock()
+       if app, ok := pc.applications[appID]; ok {
+               delete(pc.applications, appID)
+               pc.completedApplications[appID] = app

Review comment:
       We need to be careful: there is no reason to assume that the same 
application ID is not re-used multiple times in the time we keep the old 
application around. A simple time stamp addition will allow us to re-use the 
appID multiple times:
   ```
   // new ID as completedApplications map key, use negative value to get a 
divider
   newID := appID + strconv.FormatInt(-(time.Now()).Unix(), 10)
   ```
   The `newID` is then only used as the key in the _completedApplications_ map. 
No updates in the application object.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to