You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2020/03/31 12:01:26 UTC

[GitHub] [incubator-yunikorn-core] adamantal commented on a change in pull request #118: YUNIKORN-42 (Work in progress changes for recorder)

adamantal commented on a change in pull request #118: YUNIKORN-42 (Work in progress changes for recorder)
URL: https://github.com/apache/incubator-yunikorn-core/pull/118#discussion_r400851384
 
 

 ##########
 File path: pkg/diagnostic/diagnostic_events_recorder.go
 ##########
 @@ -0,0 +1,173 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package diagnostic
+
+import (
+    "github.com/apache/incubator-yunikorn-core/pkg/api"
+    "github.com/apache/incubator-yunikorn-core/pkg/common"
+    "sync"
+    "time"
+)
+
+var initOnce sync.Once
+var recorder *DiagEventsRecorder
+
+type Level int
+
+const (
+    Debug Level = iota
+    Info        = iota
+    Warn        = iota
+    Error       = iota
+)
+
+type DiagEventsRecorder struct {
+    eventMap map[string]*api.DiagnosticEvent
+    timer    common.Timer
+
+    // Nano-second interval of record for same key
+    minimumRecordIntervalForSameKeyInNS int64
+    // How long it takes to expire an event (and will be removed from cache)
+    recordExpireIntervalInNS int64
+    // Wait time In NS between cleanup runs
+    waitTimeBetweenCleanupRuns time.Duration
+
+    sync.RWMutex
+}
+
+func emptyOrAlternative(s string) string {
+    if s == "" {
+        return "(_)"
+    }
+    return s
+}
+
+func (de *DiagEventsRecorder) shouldRecord(level Level, uid string) bool {
+    de.RLock()
+    defer de.RUnlock()
+
+    // check level
+    // TODO
+
+    // check timestamp
+    event := de.eventMap[uid]
+    if event == nil {
+        return true
+    }
+    if de.timer.NanoTimeNow()-event.NanoTimestamp < de.minimumRecordIntervalForSameKeyInNS {
+        return false
+    }
+
+    return true
+}
+
+func (de *DiagEventsRecorder) RecordResourceRequestEvent(level Level, requestId string, appId string, queueName string, nodeId string, message string) {
 
 Review comment:
   A technical question: just by looking at the datastructure I assume we only allow one event per request. Is this intended? Isn't it a bit too strict? I can imagine scenarios where for a request we can emit multiple event records.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services