mitdesai commented on code in PR #579:
URL: https://github.com/apache/yunikorn-core/pull/579#discussion_r1280266353


##########
pkg/events/event_system.go:
##########
@@ -125,3 +169,38 @@ func (ec *EventSystemImpl) AddEvent(event *si.EventRecord) 
{
                metrics.GetEventMetrics().IncEventsNotChanneled()
        }
 }
+
+func (ec *EventSystemImpl) readIsTrackingEnabled() bool {
+       return common.GetConfigurationBool(configs.GetConfigMap(), 
configs.CMEventTrackingEnabled, configs.DefaultEventTrackingEnabled)
+}
+
+func (ec *EventSystemImpl) readRequestCapacity() int {
+       return common.GetConfigurationInt(configs.GetConfigMap(), 
configs.CMEventRequestCapacity, configs.DefaultEventRequestCapacity)
+}
+
+func (ec *EventSystemImpl) readRingBufferCapacity() uint64 {
+       return common.GetConfigurationUint(configs.GetConfigMap(), 
configs.CMEventRingBufferCapacity, configs.DefaultEventRingBufferCapacity)
+}
+
+func (ec *EventSystemImpl) isRestartNeeded() bool {
+       ec.Lock()
+       defer ec.Unlock()
+       return ec.readIsTrackingEnabled() != ec.trackingEnabled
+}
+
+func (ec *EventSystemImpl) Restart() {
+       ec.Stop()
+       ec.StartServiceWithPublisher(true)
+}
+
+func (ec *EventSystemImpl) reloadConfig() {
+       ec.requestCapacity = ec.readRequestCapacity()
+       newRingBufferCapacity := ec.readRingBufferCapacity()
+
+       // resize the ring buffer with new capacity
+       ec.eventBuffer.Resize(newRingBufferCapacity)

Review Comment:
   added INFO message during resize() and DEBUG message in buffer overflow case



##########
pkg/events/event_system_test.go:
##########
@@ -116,3 +117,37 @@ func TestGetEvents(t *testing.T) {
        assert.Equal(t, "4", records[1].Message)
        assert.Equal(t, "5", records[2].Message)
 }
+
+func TestConfigUpdate(t *testing.T) {
+       configs.SetConfigMap(map[string]string{configs.CMEventTrackingEnabled: 
"true"})
+       configs.SetConfigMap(map[string]string{})
+       defer configs.SetConfigMap(map[string]string{})
+
+       CreateAndSetEventSystem()
+       eventSystem := GetEventSystem().(*EventSystemImpl) //nolint:errcheck
+       eventSystem.StartService()
+       defer eventSystem.Stop()
+
+       assert.Assert(t, eventSystem.IsEventTrackingEnabled(), "Event tracking 
should be enabled by default")
+       assert.Assert(t, eventSystem.GetRingBufferCapacity() == 
configs.DefaultEventRingBufferCapacity, "Invalid event buffer capacity")
+       assert.Assert(t, eventSystem.GetRequestCapacity() == 
configs.DefaultEventRequestCapacity, "Invalid request capacity")
+       assert.Assert(t, eventSystem.eventBuffer.capacity == 
configs.DefaultEventRingBufferCapacity, "Event buffer capacity mismatch")
+
+       // update config and wait for refresh
+       var newRingBufferCapacity uint64 = 123
+       newRequestCapacity := 555
+
+       configs.SetConfigMap(
+               map[string]string{configs.CMEventTrackingEnabled: "false",
+                       configs.CMEventRingBufferCapacity: 
strconv.FormatUint(newRingBufferCapacity, 10),
+                       configs.CMEventRequestCapacity:    
strconv.Itoa(int(newRequestCapacity)),
+               })
+       err := common.WaitForCondition(func() bool {
+               return eventSystem.IsEventTrackingEnabled() == false

Review Comment:
   done!



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