Developing lightweight computation at the DSG edge

Commit 3e11e4be authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[goclidote] Add 1 ms waits in certain repetitive calls



Adding this wait time makes the AntidoteDB go client not crash.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 3356bfed
......@@ -3,6 +3,7 @@ package goclidote
import (
"fmt"
"strconv"
"time"
"uc-monitor-go-test/cnml"
......@@ -117,6 +118,7 @@ func AntidoteAddArrayToSetInMapInBucket(bucketName string, mapName string, setNa
err = bucket.Update(tx, antidoteclient.MapUpdate(mapKey,
antidoteclient.SetAdd(setKey, []byte(v))))
errCheck(err, ERROR, fmt.Sprintf("[AntidoteAddArrayToSetInMapInBucket]: Unable to add value %s to set %s in bucket %s", v, setName, bucketName))
time.Sleep(time.Millisecond)
}
mapVal, err := bucket.ReadMap(tx, mapKey)
......@@ -301,14 +303,17 @@ func ReadDevicesFromAntidote(DatabaseHost string, DatabasePort int) []cnml.Devic
var devices []cnml.DeviceIpv4sGraphserver
for _, v := range AntidoteReadItemsFromSetInBucket("guifi", "devices", DatabaseHost, DatabasePort) {
time.Sleep(time.Millisecond)
thisDevID, err := strconv.Atoi(v)
errCheck(err, WARNING, fmt.Sprintf("[ReadDevicesFromAntidote]: An error occurred when converting %s to int", v))
//fmt.Printf("%s, ",v)
var thisDev cnml.DeviceIpv4sGraphserver
thisDev.ID = thisDevID
thisDev.GraphServer, err = strconv.Atoi(AntidoteReadRegisterInBucket(fmt.Sprintf("device-%d", thisDevID), "graphserver", DatabaseHost, DatabasePort))
if err != nil {
thisDev.GraphServer = 0
}
time.Sleep(time.Millisecond)
thisDev.Addresses = AntidoteReadItemsFromSetInBucket(fmt.Sprintf("device-%d", thisDevID), "ipv4s", DatabaseHost, DatabasePort)
devices = append(devices, thisDev)
}
......
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