use of akka.actor.ActorSelection in project controller by opendaylight.
the class AbstractDataListenerSupport method onLeadershipChange.
@Override
void onLeadershipChange(boolean isLeader, boolean hasLeader) {
log.debug("{}: onLeadershipChange, isLeader: {}, hasLeader : {}", persistenceId(), isLeader, hasLeader);
final EnableNotification msg = new EnableNotification(isLeader, persistenceId());
for (ActorSelection dataChangeListener : leaderOnlyListenerActors) {
dataChangeListener.tell(msg, getSelf());
}
if (hasLeader) {
for (DelayedListenerRegistration<L, M> reg : delayedListenerOnAllRegistrations) {
reg.doRegistration(this);
}
delayedListenerOnAllRegistrations.clear();
}
if (isLeader) {
for (DelayedListenerRegistration<L, M> reg : delayedListenerRegistrations) {
reg.doRegistration(this);
}
delayedListenerRegistrations.clear();
}
}
use of akka.actor.ActorSelection in project controller by opendaylight.
the class DataTreeChangeListenerSupport method doRegistration.
@Override
void doRegistration(final RegisterDataTreeChangeListener message, final ActorRef registrationActor) {
final ActorSelection listenerActor = processListenerRegistrationMessage(message);
DOMDataTreeChangeListener listener = new ForwardingDataTreeChangeListener(listenerActor);
log().debug("{}: Registering listenerActor {} for path {}", persistenceId(), listenerActor, message.getPath());
final ShardDataTree shardDataTree = getShard().getDataStore();
shardDataTree.registerTreeChangeListener(message.getPath(), listener, shardDataTree.readCurrentData(), registration -> registrationActor.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(registration, () -> removeListenerActor(listenerActor)), ActorRef.noSender()));
}
use of akka.actor.ActorSelection in project controller by opendaylight.
the class DataChangeListenerSupport method doRegistration.
@Override
void doRegistration(final RegisterChangeListener message, final ActorRef registrationActor) {
final ActorSelection listenerActor = processListenerRegistrationMessage(message);
AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener = new DataChangeListenerProxy(listenerActor);
log().debug("{}: Registering for path {}", persistenceId(), message.getPath());
final ShardDataTree shardDataTree = getShard().getDataStore();
shardDataTree.registerDataChangeListener(message.getPath(), listener, message.getScope(), shardDataTree.readCurrentData(), registration -> registrationActor.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(registration, () -> removeListenerActor(listenerActor)), ActorRef.noSender()));
}
use of akka.actor.ActorSelection in project controller by opendaylight.
the class ActorContextTest method testExecuteRemoteOperation.
@Test
public void testExecuteRemoteOperation() {
new TestKit(getSystem()) {
{
ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
ActorRef shardManagerActorRef = getSystem().actorOf(MockShardManager.props(true, shardActorRef));
ActorContext actorContext = new ActorContext(getSystem(), shardManagerActorRef, mock(ClusterWrapper.class), mock(Configuration.class));
ActorSelection actor = actorContext.actorSelection(shardActorRef.path());
Object out = actorContext.executeOperation(actor, "hello");
assertEquals("hello", out);
}
};
}
use of akka.actor.ActorSelection in project controller by opendaylight.
the class AbstractClientHistoryTest method createActorContextMock.
protected static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
final ActorContext mock = mock(ActorContext.class);
final Promise<PrimaryShardInfo> promise = new DefaultPromise<>();
final ActorSelection selection = system.actorSelection(actor.path());
final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);
promise.success(shardInfo);
when(mock.findPrimaryShardAsync(any())).thenReturn(promise.future());
return mock;
}
Aggregations