Developing lightweight computation at the DSG edge

Commit 075a3235 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[goclidote] Use a transaction per device in RemoveDevicesFromAntidote()



Removing a large array of devices, with thousands of updates inside a
single client.StartTransaction() terribly slow down the request.
Instead, do a transaction commit after processing each item in the
array, still inside a single connection to AntidoteDB.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 6a87410a
......@@ -388,10 +388,10 @@ func RemoveDevicesFromAntidote(oldDevices []cnml.DeviceIpv4sGraphserver, Databas
errCheck(err, ERROR, "[RemoveDevicesFromAntidote]: Unable to create a new AntidoteDB go client")
defer client.Close()
tx, err := client.StartTransaction()
errCheck(err, ERROR, "[RemoveDevicesFromAntidote]: Unable to start a transaction using the go client")
for _, v := range oldDevices {
tx, err := client.StartTransaction()
errCheck(err, ERROR, "[RemoveDevicesFromAntidote]: Unable to start a transaction using the go client")
// Remove the graphserver register from the device-id bucket
//fmt.Println(v)
bucketName := fmt.Sprintf("device-%d", v.ID)
......@@ -494,10 +494,10 @@ func RemoveDevicesFromAntidote(oldDevices []cnml.DeviceIpv4sGraphserver, Databas
// Device successfully removed
remDevices = append(remDevices, v)
}
}
err = tx.Commit()
errCheck(err, ERROR, "[AntidoteRemoveRegisterInBucket]: Unable to commit transaction")
err = tx.Commit()
errCheck(err, ERROR, "[AntidoteRemoveRegisterInBucket]: Unable to commit transaction")
}
return remDevices
}
......
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