Fix wait for schema in BindingToNormalizedNodeCodec 42/62942/3
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 10 Sep 2017 07:18:07 +0000 (09:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 12 Sep 2017 08:09:55 +0000 (10:09 +0200)
commitc17e57f8fbb159edbe41a886663e549ae120df11
tree88617e25bcf2d5e9694abc62e47330fa30392d0c
parent9f54dff05550dfa5b75659fb23f32ed3cf6ef69e
Fix wait for schema in BindingToNormalizedNodeCodec

The wait for schema mechanism does not work. A few issues were fixed:

 - FutureSchema did not add the FutureSchemaPredicate instances to the
   postponedOperations list so they always timed out.

 - The waitForSchema method in BindingToNormalizedNodeCodec checked for
   !futureSchema.waitForSchema so it only successfully returned on
   failure.

 - There was a timing issue in FutureSchema where a context update could
   occur just prior to adding a postponed operation to the list, in
   which case the operation may timeout if the new update contained the
   postponed criteria and another update didn't occur in time. To
   alleviate this, the sychronization was tighted up and runtime context
   is now stored in FutureSchema instead of BindingToNormalizedNodeCodec.

 - The runtimeContext field needs to be volatile.

I also added a wait if the runtimeContext was null b/c
onGlobalContextUpdated hadn't been initially notified yet.

Added unit tests to cover the wait for schema mechanism.

Change-Id: I7155dae021453d085f89d13dfd4b069178dd2fc8
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingToNormalizedNodeCodec.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/FutureSchema.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/BindingNormalizedCodecTest.java [new file with mode: 0644]
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/FutureSchemaTest.java
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/test/BindingNormalizedCodecTest.java [deleted file]