use of org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState in project controller by opendaylight.
the class IntegrationTestKit method verifyShardState.
public static void verifyShardState(final AbstractDataStore datastore, final String shardName, final Consumer<OnDemandShardState> verifier) throws Exception {
ActorContext actorContext = datastore.getActorContext();
Future<ActorRef> future = actorContext.findLocalShardAsync(shardName);
ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
AssertionError lastError = null;
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 5) {
OnDemandShardState shardState = (OnDemandShardState) actorContext.executeOperation(shardActor, GetOnDemandRaftState.INSTANCE);
try {
verifier.accept(shardState);
return;
} catch (AssertionError e) {
lastError = e;
Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
}
}
throw lastError;
}
use of org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState in project controller by opendaylight.
the class OnDemandShardStateCache method retrieveState.
private OnDemandShardState retrieveState() throws Exception {
stateRetrievalTime = null;
Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
Stopwatch timer = Stopwatch.createStarted();
OnDemandShardState state = (OnDemandShardState) Await.result(Patterns.ask(shardActor, GetOnDemandRaftState.INSTANCE, timeout), timeout.duration());
stateRetrievalTime = timer.stop().toString();
return state;
}
Aggregations