-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Database Model and Schema #253
Commits on Oct 21, 2021
-
client_test: fix monitor cookie json
MonitorCookies are marshalled as a json object, not an array. Fix it so that benchmark test works Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e9eb8bb - Browse repository at this point
Copy the full SHA e9eb8bbView commit details -
example: fix ovsdb-server schema file
Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1a2bb3f - Browse repository at this point
Copy the full SHA 1a2bb3fView commit details -
rename DBModel to ClientDBModel
Clearly DBModel does not hold the full database model. Instead, only the combination of model.DBModel, mapper.Mapper and ovsdb.Schema is a useful database model as is used internally by libovsdb. The fact that server.go had to defined a struct called DatabaseModel with model.DBModel and ovsdb.Schema and dymanically create Mapper objects from them is a proof of this. In order to prepare for a DBModel refactoring, rename it to ClientDBModel as it's the client's view of the DatabaseModel. This patch does not contain functional changes Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 05556ad - Browse repository at this point
Copy the full SHA 05556adView commit details -
model: Introduce DatabaseModel
Replace the one that server.go had to define. For now, it's just a drop-in replacement of the previous type. Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c099652 - Browse repository at this point
Copy the full SHA c099652View commit details -
database: Add 2-step initialization
It is common to first create a DatabaseModel only based on the ClientDBModel, and then add / remove the schema to it when, e.g: when the client (re) connects. Validation is performed when the schema is added. Since the schema and mapper can be dynamically added and purged, protect them with a RWMutex Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d45fd33 - Browse repository at this point
Copy the full SHA d45fd33View commit details
Commits on Oct 25, 2021
-
client: Use DatabaseModel in client and cache
For the cache, it's simply replacing three fields with one For the client, use the 2-step DatabaseModel initialization Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for da029df - Browse repository at this point
Copy the full SHA da029dfView commit details -
model: move methods from ClientModel to DatabaseModel
Now that client, cache and server uses the DatabaseModel as central point of model creation and introspection, we can hide the dbModelClient and move its public functions to the DatabaseModel Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 15361fc - Browse repository at this point
Copy the full SHA 15361fcView commit details -
mapper: make Mapper use mapper.Info as input
All around the codebase we're creating mapper.Info structures and then calling Mapper functions that create Info structures again. Given that mapper.Info already defines all the metadata that Mapper needs to do the native-to-ovs transations, it makes sense to use Info structures as input to all functions. That simplifies the code inside the mapper module. Also, I'd expect some performance improvement since we were creating multiple Info structs unnecessarily in the host path. It's true that, for now, it makes it sligthly more cumbersone to call mapper functions, since the Info struct has to be created first and it now requires an additional argument (the table name). However, this can be improved later on by having the database model build the Info structs for us. Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 499e004 - Browse repository at this point
Copy the full SHA 499e004View commit details -
model: Use DatabaseModel to create mapper.Info
The core mapper API uses mapper.Info sctructs which can be created just by inspecting a TableSchema. However, having the DatabaseModel now centralizing accesses to the mapper API and containing both the Model types and the Schema, we can pre-create the mapper.Info.Metadata sctructs and cache them so we create Info sctructs more efficiently Signed-off-by: Adrian Moreno <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d797727 - Browse repository at this point
Copy the full SHA d797727View commit details