Search in sources :

Example 6 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class JeeHttpMessagingModule method configure.

@Override
protected void configure() {
    messagingSkeletonFactory.addBinding(ChannelAddress.class).to(ChannelMessagingSkeleton.class);
    messagingStubFactory.addBinding(ChannelAddress.class).to(ChannelMessagingStubFactory.class);
    Multibinder<GlobalAddressFactory<? extends Address>> globalAddresses;
    globalAddresses = Multibinder.newSetBinder(binder(), new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
    }, Names.named(GlobalAddressProvider.GLOBAL_ADDRESS_PROVIDER));
    globalAddresses.addBinding().to(ServletHttpGlobalAddressFactory.class);
    Multibinder<GlobalAddressFactory<? extends Address>> replyToAddresses;
    replyToAddresses = Multibinder.newSetBinder(binder(), new TypeLiteral<GlobalAddressFactory<? extends Address>>() {
    }, Names.named(ReplyToAddressProvider.REPLY_TO_ADDRESS_PROVIDER));
    replyToAddresses.addBinding().to(ServletHttpGlobalAddressFactory.class);
    install(new AccessControlClientModule());
    bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
    bind(CloseableHttpClient.class).toProvider(HttpClientProvider.class).in(Singleton.class);
    bind(HttpRequestFactory.class).to(ApacheHttpRequestFactory.class);
    bind(MessageRouter.class).to(CcMessageRouter.class).in(Singleton.class);
    bind(MessageSender.class).to(CcMessageSender.class);
    bind(MessageReceiver.class).to(JeeServletMessageReceiver.class);
    bind(ServletMessageReceiver.class).to(JeeServletMessageReceiver.class);
}
Also used : ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) Address(joynr.system.RoutingTypes.Address) HttpRequestFactory(io.joynr.messaging.http.operation.HttpRequestFactory) ApacheHttpRequestFactory(io.joynr.messaging.http.operation.ApacheHttpRequestFactory) MessageSender(io.joynr.messaging.sender.MessageSender) CcMessageSender(io.joynr.messaging.sender.CcMessageSender) ServletHttpGlobalAddressFactory(io.joynr.messaging.http.ServletHttpGlobalAddressFactory) GlobalAddressFactory(io.joynr.messaging.routing.GlobalAddressFactory) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) ServletMessageReceiver(io.joynr.dispatcher.ServletMessageReceiver) HttpDefaultRequestConfigProvider(io.joynr.messaging.http.operation.HttpDefaultRequestConfigProvider) TypeLiteral(com.google.inject.TypeLiteral) HttpClientProvider(io.joynr.messaging.http.operation.HttpClientProvider) ServletMessageReceiver(io.joynr.dispatcher.ServletMessageReceiver) MessageReceiver(io.joynr.messaging.MessageReceiver) CcMessageRouter(io.joynr.messaging.routing.CcMessageRouter) AccessControlClientModule(io.joynr.accesscontrol.AccessControlClientModule)

Example 7 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class DiscoveryEntryStorePersistedTest method createDiscoveryEntry.

private GlobalDiscoveryEntryPersisted createDiscoveryEntry(String domain, String interfaceName, String participantId) throws Exception {
    ProviderQos qos = new ProviderQos();
    long lastSeenDateMs = 123L;
    long expiryDateMs = Long.MAX_VALUE;
    String publicKeyId = "publicKeyId";
    Address address = new MqttAddress("brokerUri", "topic");
    String addressSerialized = new ObjectMapper().writeValueAsString(address);
    GlobalDiscoveryEntryPersisted discoveryEntry = new GlobalDiscoveryEntryPersisted(new Version(47, 11), domain, interfaceName, participantId, qos, lastSeenDateMs, expiryDateMs, publicKeyId, addressSerialized, "clusterControllerId");
    return discoveryEntry;
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) ProviderQos(joynr.types.ProviderQos) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 8 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class CapabilitiesDirectoryImpl method add.

@Override
public Promise<DeferredVoid> add(GlobalDiscoveryEntry globalDiscoveryEntry) {
    DeferredVoid deferred = new DeferredVoid();
    Promise<DeferredVoid> promise = new Promise<DeferredVoid>(deferred);
    Address address = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
    String clusterControllerId;
    if (address instanceof MqttAddress) {
        clusterControllerId = ((MqttAddress) address).getTopic();
    } else if (address instanceof ChannelAddress) {
        clusterControllerId = ((ChannelAddress) address).getChannelId();
    } else {
        deferred.reject(new ProviderRuntimeException(""));
        return promise;
    }
    GlobalDiscoveryEntryPersisted discoveryEntry = new GlobalDiscoveryEntryPersisted(globalDiscoveryEntry, clusterControllerId);
    logger.debug("registered discovery entry: {}", discoveryEntry);
    discoveryEntryStore.add(discoveryEntry);
    deferred.resolve();
    return promise;
}
Also used : Promise(io.joynr.provider.Promise) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) DeferredVoid(io.joynr.provider.DeferredVoid) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) GlobalDiscoveryEntryPersisted(io.joynr.capabilities.GlobalDiscoveryEntryPersisted) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 9 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class AddressManagerTest method testGetLocalMulticastParticipantWithoutGlobalTransports.

@Test
public void testGetLocalMulticastParticipantWithoutGlobalTransports() {
    createAddressManager(NO_PRIMARY_GLOBAL_TRANSPORT_SELECTED);
    when(joynrMessage.getSender()).thenReturn("from");
    String multicastId = "from/to";
    when(joynrMessage.getRecipient()).thenReturn(multicastId);
    Set<String> particpantIds = Sets.newHashSet("one");
    when(multicastReceiverRegistry.getReceivers(multicastId)).thenReturn(particpantIds);
    Address one = mock(Address.class);
    when(routingTable.get("one")).thenReturn(one);
    Set<Address> result = subject.getAddresses(joynrMessage);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains(one));
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 10 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class AddressManagerTest method testGetLocalAndGlobalAddressesForNonExistingProvider.

@Test
public void testGetLocalAndGlobalAddressesForNonExistingProvider() {
    createAddressManager(GLOBAL_TRANSPORT_MQTT, multicastAddressCalculator);
    when(joynrMessage.getSender()).thenReturn("participantId");
    String multicastId = participantId + "/to";
    when(joynrMessage.getRecipient()).thenReturn(multicastId);
    when(routingTable.getIsGloballyVisible(participantId)).thenThrow(new JoynrRuntimeException());
    Set<String> localParticipantIds = Sets.newHashSet("one");
    when(multicastReceiverRegistry.getReceivers(multicastId)).thenReturn(localParticipantIds);
    Address localAddress = mock(Address.class);
    when(routingTable.get("one")).thenReturn(localAddress);
    Address globalAddress = mock(Address.class);
    when(multicastAddressCalculator.supports(GLOBAL_TRANSPORT_MQTT)).thenReturn(true);
    when(multicastAddressCalculator.createsGlobalTransportAddresses()).thenReturn(true);
    when(multicastAddressCalculator.calculate(joynrMessage)).thenReturn(globalAddress);
    Set<Address> result = subject.getAddresses(joynrMessage);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains(localAddress));
    assertFalse(result.contains(globalAddress));
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Aggregations

Address (joynr.system.RoutingTypes.Address)43 Test (org.junit.Test)21 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)15 MqttAddress (joynr.system.RoutingTypes.MqttAddress)13 ProviderQos (joynr.types.ProviderQos)9 Version (joynr.types.Version)9 InProcessAddress (io.joynr.messaging.inprocess.InProcessAddress)7 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)6 TypeLiteral (com.google.inject.TypeLiteral)5 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)5 AbstractModule (com.google.inject.AbstractModule)4 HashSet (java.util.HashSet)4 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)4 DiscoveryException (io.joynr.exceptions.DiscoveryException)3 AbstractMiddlewareMessagingStubFactory (io.joynr.messaging.AbstractMiddlewareMessagingStubFactory)3 IMessagingSkeleton (io.joynr.messaging.IMessagingSkeleton)3 IMessagingStub (io.joynr.messaging.IMessagingStub)3 CcMessageRouter (io.joynr.messaging.routing.CcMessageRouter)3 ArrayList (java.util.ArrayList)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2