use of akka.actor.Address in project controller by opendaylight.
the class ShardingServiceAddressResolver method resolve.
public String resolve(final MemberName memberName) {
Preconditions.checkNotNull(memberName);
final Address address = memberNameToAddress.get(memberName);
Preconditions.checkNotNull(address, "Requested member[%s] is not present in the resolver ", memberName.toString());
return getActorPathBuilder(address).toString();
}
use of akka.actor.Address in project controller by opendaylight.
the class GossiperTest method testReceiveGossipStatus_WhenSenderIsNonMemberShouldIgnore.
@SuppressWarnings("unchecked")
@Test
public void testReceiveGossipStatus_WhenSenderIsNonMemberShouldIgnore() {
Address nonMember = new Address("tcp", "non-member");
GossipStatus remoteStatus = new GossipStatus(nonMember, mock(Map.class));
// add a member
mockGossiper.setClusterMembers(new Address("tcp", "member"));
mockGossiper.receiveGossipStatus(remoteStatus);
verify(mockGossiper, times(0)).getSender();
}
use of akka.actor.Address in project controller by opendaylight.
the class RpcRegistrarTest method testHandleReceiveAddEndpoint.
@Test
public void testHandleReceiveAddEndpoint() throws Exception {
final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = ImmutableMap.of(endpointAddress, Optional.of(firstEndpoint));
testActorRef.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
Mockito.verify(service).registerRpcImplementation(Mockito.any(RemoteRpcImplementation.class), Mockito.eq(firstEndpoint.getRpcs()));
Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
use of akka.actor.Address in project controller by opendaylight.
the class RpcRegistryTest method testAddRoutesConcurrency.
@Test
public void testAddRoutesConcurrency() {
final TestKit testKit = new TestKit(node1);
final int nRoutes = 500;
final Collection<DOMRpcIdentifier> added = new ArrayList<>(nRoutes);
for (int i = 0; i < nRoutes; i++) {
final DOMRpcIdentifier routeId = DOMRpcIdentifier.create(SchemaPath.create(true, QName.create(URI.create("/mockrpc"), "type" + i)));
added.add(routeId);
// Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
registry1.tell(new AddOrUpdateRoutes(Arrays.asList(routeId)), ActorRef.noSender());
}
FiniteDuration duration = Duration.create(3, TimeUnit.SECONDS);
int numTries = 0;
while (true) {
registry1.tell(GET_ALL_BUCKETS, testKit.getRef());
@SuppressWarnings("unchecked") Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(duration, Map.class);
Bucket<RoutingTable> localBucket = buckets.values().iterator().next();
RoutingTable table = localBucket.getData();
if (table != null && table.size() == nRoutes) {
for (DOMRpcIdentifier r : added) {
Assert.assertTrue("RoutingTable contains " + r, table.contains(r));
}
break;
}
if (++numTries >= 50) {
Assert.fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
}
Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
}
}
use of akka.actor.Address in project controller by opendaylight.
the class RpcRegistryTest method assertEndpoints.
private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address, final TestKit invoker) {
final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = msg.getEndpoints();
Assert.assertEquals(1, endpoints.size());
final Optional<RemoteRpcEndpoint> maybeEndpoint = endpoints.get(address);
Assert.assertNotNull(maybeEndpoint);
Assert.assertTrue(maybeEndpoint.isPresent());
final RemoteRpcEndpoint endpoint = maybeEndpoint.get();
final ActorRef router = endpoint.getRouter();
Assert.assertNotNull(router);
router.tell("hello", ActorRef.noSender());
final String s = invoker.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), String.class);
Assert.assertEquals("hello", s);
}
Aggregations