Skip to content

Commit

Permalink
ovsdb: Monitor support.
Browse files Browse the repository at this point in the history
  • Loading branch information
blp committed Nov 18, 2009
1 parent 1fd13cd commit a8425c5
Show file tree
Hide file tree
Showing 10 changed files with 857 additions and 7 deletions.
128 changes: 128 additions & 0 deletions ovsdb/SPECS
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,134 @@ form:

The "cancel" notification itself has no reply.

monitor
.......

Request object members:

"method": "monitor" required
"params": [<value>, <monitor-requests>] required
"id": any JSON value except null required

<monitor-requests> is an object that maps from a table name to a
<monitor-request>.

Each <monitor-request> is an object with the following members:

"columns": [<column>*] optional
"select": <monitor-select> optional

<monitor-select> is an object with the following members:

"initial": <boolean> optional
"insert": <boolean> optional
"delete": <boolean> optional
"modify": <boolean> optional

Response object members:

"result": <table-updates>
"error": null
"id": same "id" as request

This JSON-RPC request enables a client to replicate tables or subsets
of tables. Each <monitor-request> specifies a table to be replicated.
The JSON-RPC response to the "monitor" includes the initial contents
of each table. Afterward, when changes to those tables are committed,
the changes are automatically sent to the client using the "update"
monitor notification. This monitoring persists until the JSON-RPC
session terminates or until the client sends a "monitor_cancel"
JSON-RPC request.

Each <monitor-request> describes how to monitor a table:

The circumstances in which an "update" notification is sent for a
row within the table are determined by <monitor-select>:

If "initial" is omitted or true, every row in the table is
sent as part of the reply to the "monitor" request.

If "insert" is omitted or true, "update" notifications are
sent for rows newly inserted into the table.

If "delete" is omitted or true, "update" notifications are
sent for rows deleted from the table.

If "modify" is omitted or true, "update" notifications are
sent whenever when a row in the table is modified.

The "columns" member specifies the columns whose values are
monitored. If "columns" is omitted, all columns in the table,
except for "_uuid", are monitored.

The "result" in the JSON-RPC response to the "monitor" request is a
<table-updates> object (see below) that contains the contents of the
tables for which "initial" rows are selected. If no tables' initial
contents are requested, then "result" is an empty object.

update
......

Notification object members:

"method": "update"
"params": [<value>, <table-updates>]
"id": null

The <value> in "params" is the same as the value passed as the <value>
in "params" for the "monitor" request.

<table-updates> is an object that maps from a table name to a
<table-update>.

A <table-update> is an object that maps from the row's UUID (as a
36-byte string) to a <row-update> object.

A <row-update> is an object with the following members:

"old": <row> present for "delete" and "modify" updates
"new": <row> present for "initial", "insert", and "modify" updates

This JSON-RPC notification is sent from the server to the client to
tell it about changes to a monitored table (or the initial state of a
modified table). Each table in which one or more rows has changed (or
whose initial view is being presented) is represented in "updates".
Each row that has changed (or whose initial view is being presented)
is represented in its <table-update> as a member with its name taken
from the row's _uuid member. The corresponding value is a
<row-update>:

The "old" member is present for "delete" and "modify" updates.
For "delete" updates, each monitored column is included. For
"modify" updates, the prior value of each monitored column whose
value has changed is included (monitored columns that have not
changed are represented in "new").

The "new" member is present for "initial", "insert", and "modify"
updates. For "initial" and "insert" updates, each monitored
column is included. For "modify" updates, the new value of each
monitored column is included.

monitor_cancel
..............

Request object members:

"method": "monitor_cancel" required
"params": [<value>] required
"id": any JSON value except null required

Response object members:

"result": {}
"error": null
"id": the request "id" member

Cancels the ongoing table monitor request, identified by the <value>
in "params" matching the <value> in "params" for an ongoing "monitor"
request. No more "update" messages will be sent for this table
monitor.

echo
....

Expand Down
13 changes: 13 additions & 0 deletions ovsdb/column.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ ovsdb_column_set_from_json(const struct json *json,
"array of distinct column names expected");
}

struct json *
ovsdb_column_set_to_json(const struct ovsdb_column_set *set)
{
struct json *json;
size_t i;

json = json_array_create_empty();
for (i = 0; i < set->n_columns; i++) {
json_array_add(json, json_string_create(set->columns[i]->name));
}
return json;
}

void
ovsdb_column_set_add(struct ovsdb_column_set *set,
const struct ovsdb_column *column)
Expand Down
1 change: 1 addition & 0 deletions ovsdb/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void ovsdb_column_set_clone(struct ovsdb_column_set *,
struct ovsdb_error *ovsdb_column_set_from_json(const struct json *,
const struct ovsdb_table *,
struct ovsdb_column_set *);
struct json *ovsdb_column_set_to_json(const struct ovsdb_column_set *);

void ovsdb_column_set_add(struct ovsdb_column_set *,
const struct ovsdb_column *);
Expand Down
Loading

0 comments on commit a8425c5

Please sign in to comment.