pbacsko commented on code in PR #571:
URL: https://github.com/apache/yunikorn-core/pull/571#discussion_r1233388000


##########
pkg/scheduler/objects/events.go:
##########
@@ -50,6 +51,71 @@ func (evt *applicationEvents) sendPlaceholderLargerEvent(ph 
*Allocation, request
        evt.eventSystem.AddEvent(event)
 }
 
+func (evt *applicationEvents) sendNewAllocationEvent(alloc *Allocation) {
+       if !evt.enabled {
+               return
+       }
+
+       event := events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_ADD, si.EventRecord_APP_ALLOC, 
alloc.GetAllocatedResource())
+       evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendNewAskEvent(request *AllocationAsk) {
+       if !evt.enabled {
+               return
+       }
+
+       event := events.CreateAppEventRecord(evt.app.ApplicationID, "", 
request.GetAllocationKey(), si.EventRecord_ADD, si.EventRecord_APP_REQUEST, 
request.GetAllocatedResource())
+       evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendRemoveAllocationEvent(alloc *Allocation, 
terminationType si.TerminationType) {
+       if !evt.enabled {
+               return
+       }
+
+       var event *si.EventRecord
+       switch terminationType {
+       case si.TerminationType_UNKNOWN_TERMINATION_TYPE:
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_NODEREMOVED, 
alloc.GetAllocatedResource())
+       case si.TerminationType_STOPPED_BY_RM:
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_CANCEL, 
alloc.GetAllocatedResource())
+       case si.TerminationType_TIMEOUT:
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_TIMEOUT, 
alloc.GetAllocatedResource())
+       case si.TerminationType_PREEMPTED_BY_SCHEDULER:
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_PREEMPT, 
alloc.GetAllocatedResource())
+       case si.TerminationType_PLACEHOLDER_REPLACED:
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, "", 
alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_REPLACED, 
alloc.GetAllocatedResource())
+       }
+
+       evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendRemoveAskEvent(request *AllocationAsk, 
terminationType si.TerminationType) {

Review Comment:
   It's ok to have a single method for remove/cancel, just merge the two.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to