Search in sources :

Example 26 with Address

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();
}
Also used : Address(akka.actor.Address)

Example 27 with Address

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();
}
Also used : Address(akka.actor.Address) Matchers.anyMap(org.mockito.Matchers.anyMap) Map(java.util.Map) Test(org.junit.Test)

Example 28 with Address

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);
}
Also used : Address(akka.actor.Address) Optional(java.util.Optional) UpdateRemoteEndpoints(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints) Test(org.junit.Test)

Example 29 with Address

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);
    }
}
Also used : UniqueAddress(akka.cluster.UniqueAddress) Address(akka.actor.Address) ArrayList(java.util.ArrayList) FiniteDuration(scala.concurrent.duration.FiniteDuration) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) TestKit(akka.testkit.javadsl.TestKit) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint) AddOrUpdateRoutes(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes) Bucket(org.opendaylight.controller.remote.rpc.registry.gossip.Bucket) Test(org.junit.Test)

Example 30 with Address

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);
}
Also used : UniqueAddress(akka.cluster.UniqueAddress) Address(akka.actor.Address) Optional(java.util.Optional) ActorRef(akka.actor.ActorRef) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)

Aggregations

Address (akka.actor.Address)36 Test (org.junit.Test)15 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)9 UniqueAddress (akka.cluster.UniqueAddress)7 HashMap (java.util.HashMap)6 DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)6 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)6 TestKit (akka.testkit.javadsl.TestKit)5 Optional (java.util.Optional)5 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)4 ActorRef (akka.actor.ActorRef)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ActorSelection (akka.actor.ActorSelection)2 ActorSystem (akka.actor.ActorSystem)2 Props (akka.actor.Props)2 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 LeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService)2 WebMonitor (org.apache.flink.runtime.webmonitor.WebMonitor)2