summaryrefslogtreecommitdiff
path: root/ovsdb/monitor.h
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-monitor: Support monitor_cond_since.Han Zhou2019-02-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support the new monitor method monitor_cond_since so that a client can request monitoring start from a specific point instead of always from beginning. This will reduce the cost at scenarios when server is restarted/failed-over but client still has all existing data. In these scenarios only new changes (and in most cases no change) needed to be transfered to client. When ovsdb-server restarted, history transactions are read from disk file; when ovsdb-server failed over, history transactions exists already in the memory of the new server. There are situations that the requested transaction may not be found. For example, a transaction that is too old and has been discarded from the maintained history list in memory, or the transactions on disk has been compacted during ovsdb compaction. In those situations the server fall backs to transfer all data start from begining. For more details of the protocol change, see Documentation/ref/ovsdb-server.7.rst. This change includes both server side and ovsdb-client side changes with the new protocol. IDLs using this capability will be added in future patches. Now the feature takes effect only for cluster mode of ovsdb-server, because cluster mode is the only mode that supports unique transcation uuid today. For other modes, the monitor_cond_since always fall back to transfer all data with found = false. Support for those modes can be added in the future. Signed-off-by: Han Zhou <hzhou8@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-monitor: Refactor ovsdb monitor implementation.Han Zhou2019-02-281-4/+6
| | | | | | | | | | | | | | | | | | | | | Current ovsdb monitor maintains its own transaction version through an incremental integer and use it to identify changes starting from different version, and also use it to figure out if each set of changes should be flushed. In particular, it uses number 0 to represent that the change set contains all data for initial client population. It is a smart way but it prevents further extension of the monitoring mechanism to support future use case for clients to request changes starting from a given history point. This patch refactors the structures so that change sets are referenced directly through the pointer. It uses additional members such as init_change_set, new_change_set to indicates the specific change set explicitely, instead of through calculated version numbers based on implicite rules. At the same time, this patch provides better encapsulation for change set (composed of data in a list of tables), while still allowing traversing across change sets for a given table. Signed-off-by: Han Zhou <hzhou8@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb_monitor: Fix style of prototypes.Han Zhou2019-02-221-33/+33
| | | | | | | | | | | Ommiting the parameter names in prototypes, as suggested by coding style: Omit parameter names from function prototypes when the names do not give useful information. Adjust orders of parameters as suggested by coding style. Signed-off-by: Han Zhou <hzhou8@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: Add support for online schema conversion.Ben Pfaff2018-03-241-0/+2
| | | | | | | | | | | With this change, "ovsdb-client convert" can be used to convert a database from one schema to another without taking the database offline. This can be useful to minimize downtime for a database during a software upgrade. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovsdb: Drop distinction between monitors and replicas.Ben Pfaff2018-03-241-1/+7
| | | | | | | | | | | | | | | Until now, OVSDB distinguished "monitors", which are associated with OVSDB JSON-RPC client sessions and allow clients to find out about database changes, from "replicas", which are associated with databases and also find out about database changes and act on them in some way. Now that committing to disk has been broken into a separate concept, there is a one-to-one and "onto" relationship between monitors and replicas: every monitor M has a replica R and R is associated with M as well. It's easier if we just treat them as a single entity, and that's what this commit implements. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovsdb: enable jsonrpc-server to service "monitor_cond_change" requestLiran Schour2016-07-181-11/+21
| | | | | | | | | | | ovsdb-server now accepts "monitor_cond_change" request. After conditions change we compose update notification according to the current state of the database without using a change list before sending reply to the monitor_cond_change request. Sees ovsdb-server (1) man page for details of monitor_cond_change. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: generate update notifications for monitor_cond sessionLiran Schour2016-07-181-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hold session's conditions in ovsdb_monitor_session_condition. Pass it to ovsdb_monitor for generating "update2" notifications. Add functions that can generate "update2" notification for a "monitor_cond" session. JSON cache is enabled only for session's with true condition only. "monitor_cond" and "monitor_cond_change" are RFC 7047 extensions described by ovsdb-server(1) manpage. Performance evaluation: OVN is the main candidate for conditional monitoring usage. It is clear that conditional monitoring reduces computation on the ovn-controller (client) side due to the reduced size of flow tables and update messages. Performance evaluation shows up to 75% computation reduction. However, performance evaluation shows also a reduction in computation on the SB ovsdb-server side proportional to the degree that each logical network is spread over physical hosts in the DC. Evaluation shows that in a realistic scenarios there is a computation reduction also in the server side. Evaluation on simulated environment of 50 hosts and 1000 logical ports shows the following results (cycles #): LN spread over # hosts| master | patch | change ------------------------------------------------------------- 1 | 24597200127 | 24339235374 | 1.0% 6 | 23788521572 | 19145229352 | 19.5% 12 | 23886405758 | 17913143176 | 25.0% 18 | 25812686279 | 23675094540 | 8.2% 24 | 28414671499 | 24770202308 | 12.8% 30 | 31487218890 | 28397543436 | 9.8% 36 | 36116993930 | 34105388739 | 5.5% 42 | 37898342465 | 38647139083 | -1.9% 48 | 41637996229 | 41846616306 | -0.5% 50 | 41679995357 | 43455565977 | -4.2% Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: allow unmonitored columns in condition evaluationLiran Schour2016-07-181-1/+1
| | | | | | | | | | | | This commit allows to add unmonitored columns to a monitored table due to condition update. It will be used to evaluate conditions on unmonitored columns. Update notification includes only monitored columns. Due to the limited number of columns, we do not remove unused unmonitored columns on condition update for code simplicity. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: create column index mapping between ovsdb row to monitor rowLiran Schour2016-07-181-5/+1
| | | | | | | | Columns indexing is different in ovsdb_row then in ovsdb_monitor_row. We need mapping between the 2 for condition evaluation. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-server: Fix a reference count leak bugandy zhou2016-03-081-4/+2
| | | | | | | | | | | | | | | | | | | | | When destroying an ovsdb_jsonrpc_monitor, the jsonrpc monitor still holds a reference count to the monitors 'changes' indexed with 'unflushed' transaction id. The bug is that the reference count was not decremented as it should in the code path. The bug caused 'changes' that have been flushed to all jsonrpc clients to linger around unnecessarily, occupying increasingly large amount of memory. See "Reported-at" URL for more details. This bug is tricky to find since the memory is not leaked; they will eventually be freed when monitors are destroyed. Reported-by: Lei Huang <huang.f.lei@gmail.com> Reported-at: http://openvswitch.org/pipermail/dev/2016-March/067274.html Signed-off-by: Andy Zhou <azhou@ovn.org> Tested-by: Han Zhou <zhouhan@gmail.com> Acked-by: Han Zhou <zhouhan@gmail.com> Acked-by: Liran Schour <lirans@il.ibm.com>
* ovsdb-server: fix monitor counters reported by memory/showAndy Zhou2016-02-051-0/+2
| | | | | | | | | | | | | | Commit 4c2809787cdbc774 (ovsdb-monitor: add json cache) introduced an optimization that allows jsonrpc session to share monitors. However, the memory/show implementation was not updated to match the implementation; it still assumes that each jsonrpc session uses its own monitor, thus are likely to over reporting the number. This patch fix the bug and reports the actual number of monitor used by the ovsdb-server. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb-client: support monitor2Andy Zhou2015-12-111-0/+1
| | | | | | | | Add monitor2 option to ovsdb-client. See ovsdb-client(1) manpage patch for details. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb: generate update2 notification for a monitor2 sessionAndy Zhou2015-12-111-1/+12
| | | | | | | | | | Add functions that can generate "update2" notification for a "monitor2" session. "monitor2" and "update2" are RFC 7047 extensions described by ovsdb-server(1) manpage. See the manpage changes for more details. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb-monitor: add json cacheAndy Zhou2015-06-081-1/+1
| | | | | | | | | | | | | | | | | | | Although multiple jsonrpc monitors can share the same ovsdb monitor, each change still needs to translated into json object from scratch. This can be wasteful if multiple jsonrpc monitors are interested in the same changes. Json cache improves this by keeping an copy of json object generated for transaction X to current transaction. When jsonrpc is interested in a change, the cache is searched first, if an json object is found, a copy of it is handed back, skipping the regeneration process. Any commit to the monitor will empty the cache. This can be further optimized to not throw away the cache if the updated tables and columns are not being monitored. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-monitor: allow multiple jsonrpc monitors to share a single ovsdbAndy Zhou2015-06-081-1/+9
| | | | | | | | | | | | | | | | | monitor Store ovsdb monitor in a global hmap. If a newly created ovsdb monitor object monitors the same tables and columns as an existing one, the existing monitor will be reused. With this patch, jsonrpc monitor and ovsdb monitor now have N:1 mapping. The goals are to: 1) Reduce the cost of maintaining duplicated monitors. 2) Allow for create Json cache for the same updates. Json cache will be introduced in the following patch. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-monitor: rename jsonrpc_monitor_compose_table_update()Andy Zhou2015-05-291-2/+2
| | | | | | | | | | jsonrpc_monitor_compose_update() seems to fit better than jsonrpc_monitor_compose_table_update(), since it composes changes from all tables. Albeit the original one is named after the <table-updates> object described in RFC 7047. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-monitor: add transaction idsAndy Zhou2015-05-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | With N:1 mappings, multiple jsonrpc server may be servicing the rpc connection at a different pace. ovsdb-monitor thus needs to maintain different change sets, depends on connection speed of each rpc connections. Connections servicing at the same speed can share the same change set. Transaction ID is an concept added to describe the change set. One possible view of the database state is a sequence of changes, more precisely, commits be applied to it in order, starting from an initial state, with commit 0. The logic can also be applied to the jsonrpc monitor; each change it pushes corresponds to commits between two transaction IDs. This patch introduces transaction IDs. For ovsdb-monitor, it maintains n_transactions, starting from 0. Each commit add 1 to the number. Jsonrpc maintains and 'unflushed' transaction number, corresponding to the next commit the remote has not seen. jsonrpc's job is simply to notice there are changes in the ovsdb-monitor that it is interested in, i.e. 'n_transactions' >= 'unflushed', get the changes in json format, and push them to the remote site. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-monitor: stores jsonrpc-monitor in a linked-listAndy Zhou2015-05-291-2/+3
| | | | | | | | | | | | | | | | | | | Currently, each ovsdb-monitor points to a single jsonrpc_monitor object. This means there is 1:1 relationship between them. In case multiple jsonrpc-monitors need to monitor the same tables and the columns within them, then can share a single ovsdb-monitor, so the updates only needs to be maintained once. This patch, with a few following patches, will allow for N:1 mapping between jsonrpc-monitor and ovsdb-monitor. Maintaining jsonrpc-monitor pointers in a linked-list is essential in allowing N:1 mapping. The ovsdb-monitor life cycle is now reference counted. An empty list means zero references. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-monitor: refactoring ovsdb_monitor_get_initialAndy Zhou2015-05-291-1/+1
| | | | | | | | | | | | Refactoring ovsdb_monitor_get_initial() to not generate JSON object. It only collect changes within the ovsdb_monitor(). ovsdb_jsonrpc_monitor_compose_table_update() is then used to generate JSON object. This change will also make future patch easier. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* jsonrpc-server: Split out monitor backend functions to monitor.c/hAndy Zhou2015-05-291-0/+58
Added new files monitor.[ch] for monitor backend functions. There is no functional changes. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>