Developing lightweight computation at the DSG edge

Commit 2bbf93d5 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Save timestamp on monitor registration


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 3b6a533d
......@@ -42,6 +42,7 @@ var idNum int
// ID represents the ID of the monitor, in alfanumeric form
var ID = "0"
var IDts = "0_ts"
var idHelp = "Numeric ID of this monitoring instance"
// maxDevs defines the default maximum number of nodes a monitor is assigned to
......@@ -134,11 +135,13 @@ func initializeFlags() {
if *idPtr > 0 {
idNum = *idPtr
ID = fmt.Sprint(*idPtr)
IDts = fmt.Sprintf("%s_ts", ID)
fmt.Println("Using ID", ID)
} else {
randsource := rand.New(rand.NewSource(time.Now().UnixNano()))
ID = fmt.Sprint("a", 100000+randsource.Intn(900000))
fmt.Println("Using anonymous id", ID)
IDts = fmt.Sprintf("%s_ts", ID)
}
//Maximum devices to monitor
......@@ -466,11 +469,19 @@ func startLocalAssignTimer() {
}
func registerMonitorInAntidote() {
updateMonitorTimestampInAntidote()
goclidote.AntidoteAddItemToSetInBucket("guifi", "monitors", ID)
}
func updateMonitorTimestampInAntidote() {
timestamp := time.Now().Unix()
goclidote.AntidoteSetRegisterInBucket("guifi", IDts, fmt.Sprintf("%d", timestamp))
fmt.Println("Setting timestamp to", timestamp)
}
func deregisterMonitorInAntidote() {
goclidote.AntidoteRemoveItemFromSetInBucket("guifi", "monitors", ID)
goclidote.AntidoteRemoveRegisterInBucket("guifi", IDts)
}
func errCheck(e error, level int, message string) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment