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


##########
pkg/scheduler/objects/events.go:
##########
@@ -50,6 +51,87 @@ func (evt *applicationEvents) sendPlaceholderLargerEvent(ph 
*Allocation, request
        evt.eventSystem.AddEvent(event)
 }
 
+func (evt *applicationEvents) sendSuccessfulAllocationEvent(alloc *Allocation) 
{
+       if !evt.enabled {
+               return
+       }
+
+       message := fmt.Sprintf("Allocation '%s' in application '%s' is 
successfully allocated to node '%s'", alloc.GetUUID(), 
alloc.GetApplicationID(), alloc.GetNodeID())
+       event := events.CreateAppEventRecord(evt.app.ApplicationID, message, 
alloc.GetUUID(), si.EventRecord_ADD, si.EventRecord_APP_ALLOC, 
alloc.GetAllocatedResource())
+       evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendIncomingAllocationAskEvent(request 
*AllocationAsk) {
+       if !evt.enabled {
+               return
+       }
+
+       message := fmt.Sprintf("Incoming allocation ask '%s' for application 
'%s'", request.GetAllocationKey(), request.GetApplicationID())
+       event := events.CreateAppEventRecord(evt.app.ApplicationID, message, 
request.GetAllocationKey(), si.EventRecord_ADD, si.EventRecord_APP_REQUEST, 
request.GetAllocatedResource())
+       evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendTerminateAllocationEvent(alloc *Allocation, 
terminationType si.TerminationType) {
+       if !evt.enabled {
+               return
+       }
+
+       var message string
+       var event *si.EventRecord
+       switch terminationType {
+       case si.TerminationType_UNKNOWN_TERMINATION_TYPE:
+               message = fmt.Sprintf("Allocation '%s' in application '%s' is 
removed. Reason: node is removed", alloc.GetUUID(), alloc.GetApplicationID())
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, 
message, alloc.GetUUID(), si.EventRecord_REMOVE, 
si.EventRecord_ALLOC_NODEREMOVED, alloc.GetAllocatedResource())
+       case si.TerminationType_STOPPED_BY_RM:
+               message = fmt.Sprintf("Allocation '%s' in application '%s' is 
removed. Reason: stopped by RM", alloc.GetUUID(), alloc.GetApplicationID())
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, 
message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_CANCEL, 
alloc.GetAllocatedResource())
+       case si.TerminationType_TIMEOUT:
+               message = fmt.Sprintf("Allocation'%s' in application '%s' is 
removed. Reason: timeout", alloc.GetUUID(), alloc.GetApplicationID())
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, 
message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_TIMEOUT, 
alloc.GetAllocatedResource())
+       case si.TerminationType_PREEMPTED_BY_SCHEDULER:
+               message = fmt.Sprintf("Allocation '%s' in application '%s' is 
removed. Reason: preempted", alloc.GetUUID(), alloc.GetApplicationID())
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, 
message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_PREEMPT, 
alloc.GetAllocatedResource())
+       case si.TerminationType_PLACEHOLDER_REPLACED:
+               message := fmt.Sprintf("Placeholder '%s' in application '%s' is 
removed. Reason: replaced", alloc.GetUUID(), alloc.GetApplicationID())
+               event = events.CreateAppEventRecord(evt.app.ApplicationID, 
message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_REPLACED, 
alloc.GetAllocatedResource())
+       }
+
+       if event != nil {
+               evt.eventSystem.AddEvent(event)
+       }
+}
+
+func (evt *applicationEvents) sendTerminateAllocationAskEvent(request 
*AllocationAsk, terminationType si.TerminationType) {

Review Comment:
   `sendRemoveAskEvent()`



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