NVPd also calls idl.run() :: psi
On Aug 7, 2013, at 1:37 PM, Reid Price <rpr...@nicira.com> wrote: > I like this one better. I am surprised that test-ovsdb has the only > invocations of idl.run(), but if that is true, LGTM. > > > On Tue, Aug 6, 2013 at 3:14 PM, Aaron Rosen <aro...@nicira.com> wrote: > This patch changes what is being returned from Idl.run() to a tuple > (changed, changes) so one can determine what changes have occurred to > the database without having to read the entire table. > > Signed-off-by: Aaron Rosen <aro...@nicira.com> > --- > python/ovs/db/idl.py | 16 ++++++++++------ > tests/test-ovsdb.py | 4 ++-- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py > index 55fbcba..1affd54 100644 > --- a/python/ovs/db/idl.py > +++ b/python/ovs/db/idl.py > @@ -134,11 +134,13 @@ class Idl: > > def run(self): > """Processes a batch of messages from the database server. Returns > - True if the database as seen through the IDL changed, False if it did > - not change. The initial fetch of the entire contents of the remote > - database is considered to be one kind of change. If the IDL has been > - configured to acquire a database lock (with Idl.set_lock()), then > - successfully acquiring the lock is also considered to be a change. > + a tuple (changed, changes) where changed is True if the database as > + seen through the IDL changed, False if it did not change. The changes > + variable contain all of the jsonrpc messages that have been > processed. > + The initial fetch of the entire contents of the remote database is > + considered to be one kind of change. If the IDL has been configured > + to acquire a database lock (with Idl.set_lock()), then successfully > + acquiring the lock is also considered to be a change. > > This function can return occasional false positives, that is, report > that the database changed even though it didn't. This happens if the > @@ -153,6 +155,7 @@ class Idl: > assert not self.txn > initial_change_seqno = self.change_seqno > self._session.run() > + changes = [] > i = 0 > while i < 50: > i += 1 > @@ -176,6 +179,7 @@ class Idl: > and len(msg.params) == 2 > and msg.params[0] == None): > # Database contents changed. > + changes.append(msg) > self.__parse_update(msg.params[1]) > elif (msg.type == ovs.jsonrpc.Message.T_REPLY > and self._monitor_request_id is not None > @@ -218,7 +222,7 @@ class Idl: > % (self._session.get_name(), > ovs.jsonrpc.Message.type_to_string(msg.type))) > > - return initial_change_seqno != self.change_seqno > + return (initial_change_seqno != self.change_seqno, changes) > > def wait(self, poller): > """Arranges for poller.block() to wake up when self.run() has > something > diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py > index 392ed4b..afc8287 100644 > --- a/tests/test-ovsdb.py > +++ b/tests/test-ovsdb.py > @@ -366,7 +366,7 @@ def do_idl(schema_file, remote, *commands): > command = command[1:] > else: > # Wait for update. > - while idl.change_seqno == seqno and not idl.run(): > + while idl.change_seqno == seqno and not idl.run()[0]: > rpc.run() > > poller = ovs.poller.Poller() > @@ -415,7 +415,7 @@ def do_idl(schema_file, remote, *commands): > > if rpc: > rpc.close() > - while idl.change_seqno == seqno and not idl.run(): > + while idl.change_seqno == seqno and not idl.run()[0]: > poller = ovs.poller.Poller() > idl.wait(poller) > poller.block() > -- > 1.7.9.5 > > > > On Tue, Aug 6, 2013 at 2:45 PM, Aaron Rosen <aro...@nicira.com> wrote: > This patch changes what is being returned from Idl.run() to a tuple > (changed, changes) so one can determine what changes have occurred to > the database without having to read the entire table. > > Signed-off-by: Aaron Rosen <aro...@nicira.com> > --- > python/ovs/db/idl.py | 16 ++++++++++------ > tests/test-ovsdb.py | 4 ++-- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py > index 55fbcba..095cf4f 100644 > --- a/python/ovs/db/idl.py > +++ b/python/ovs/db/idl.py > @@ -134,11 +134,13 @@ class Idl: > > def run(self): > """Processes a batch of messages from the database server. Returns > - True if the database as seen through the IDL changed, False if it did > - not change. The initial fetch of the entire contents of the remote > - database is considered to be one kind of change. If the IDL has been > - configured to acquire a database lock (with Idl.set_lock()), then > - successfully acquiring the lock is also considered to be a change. > + a tuple (changed, changes) where changed is True if the database as > + seen through the IDL changed, False if it did not change. The changes > + variable contain all of the jsonrpc messages that have been > processed. > + The initial fetch of the entire contents of the remote database is > + considered to be one kind of change. If the IDL has been configured > + to acquire a database lock (with Idl.set_lock()), then successfully > + acquiring the lock is also considered to be a change. > > This function can return occasional false positives, that is, report > that the database changed even though it didn't. This happens if the > @@ -153,6 +155,7 @@ class Idl: > assert not self.txn > initial_change_seqno = self.change_seqno > self._session.run() > + changes = [] > i = 0 > while i < 50: > i += 1 > @@ -171,6 +174,7 @@ class Idl: > msg = self._session.recv() > if msg is None: > break > + changes.append(msg) > if (msg.type == ovs.jsonrpc.Message.T_NOTIFY > and msg.method == "update" > and len(msg.params) == 2 > @@ -218,7 +222,7 @@ class Idl: > % (self._session.get_name(), > ovs.jsonrpc.Message.type_to_string(msg.type))) > > - return initial_change_seqno != self.change_seqno > + return (initial_change_seqno != self.change_seqno, changes) > > def wait(self, poller): > """Arranges for poller.block() to wake up when self.run() has > something > diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py > index 392ed4b..afc8287 100644 > --- a/tests/test-ovsdb.py > +++ b/tests/test-ovsdb.py > @@ -366,7 +366,7 @@ def do_idl(schema_file, remote, *commands): > command = command[1:] > else: > # Wait for update. > - while idl.change_seqno == seqno and not idl.run(): > + while idl.change_seqno == seqno and not idl.run()[0]: > rpc.run() > > poller = ovs.poller.Poller() > @@ -415,7 +415,7 @@ def do_idl(schema_file, remote, *commands): > > if rpc: > rpc.close() > - while idl.change_seqno == seqno and not idl.run(): > + while idl.change_seqno == seqno and not idl.run()[0]: > poller = ovs.poller.Poller() > idl.wait(poller) > poller.block() > -- > 1.7.9.5 > > > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev
_______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev