Search in sources :

Example 16 with MqttAddress

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

the class StaticCapabilitiesProvisioning method substituteInProcessAddressIfLocal.

private void substituteInProcessAddressIfLocal(ObjectMapper objectMapper, String localChannelId, GlobalDiscoveryEntry globalDiscoveryEntry, Address address) throws JsonProcessingException {
    if ((address instanceof ChannelAddress && localChannelId.equals(((ChannelAddress) address).getChannelId())) || (address instanceof MqttAddress && localChannelId.equals(((MqttAddress) address).getTopic()))) {
        Address localAddress = new InProcessAddress();
        globalDiscoveryEntry.setAddress(objectMapper.writeValueAsString(localAddress));
    }
}
Also used : ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 17 with MqttAddress

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

the class CapabilitiesUtilsTest method testConvertGlobalDiscoveryEntryToDiscoveryEntryWithMetaInfo.

@Test
public void testConvertGlobalDiscoveryEntryToDiscoveryEntryWithMetaInfo() {
    boolean isLocal = false;
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(42, 23), "testDomain", "testInterfaceName", "testParticipantId", new ProviderQos(), 4711l, 4712l, "testPublicKeyId");
    GlobalDiscoveryEntry globalDiscoveryEntry = CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, new MqttAddress());
    DiscoveryEntryWithMetaInfo convertedEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, discoveryEntry);
    compareDiscoveryEntries(isLocal, discoveryEntry, convertedEntry);
    DiscoveryEntryWithMetaInfo convertedGlobalEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, globalDiscoveryEntry);
    compareDiscoveryEntries(isLocal, globalDiscoveryEntry, convertedGlobalEntry);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 18 with MqttAddress

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

the class LegacyCapabilitiesProvisioning method createDiscoveryEntryFor.

private void createDiscoveryEntryFor(Class<?> interfaceClass, String interfaceName, String channelId, String participantId, String urlForAddress, String localChannelId, String domain) {
    boolean hasUrl = isPresent(urlForAddress);
    boolean hasParticipantId = isPresent(participantId);
    if (hasUrl && !hasParticipantId) {
        throw new IllegalArgumentException(format("When configuring the discovery directory or domain access controller " + "via properties, you must provide both a URL and a participant ID per service.%n" + "You provided the URL '%s' and the participant ID '%s' for the service %s.%n" + "Please complete the configuration and restart the application.", urlForAddress, participantId, interfaceName));
    }
    if (hasParticipantId && hasUrl && isPresent(channelId) && isPresent(domain)) {
        Address address;
        if (localChannelId.equals(channelId)) {
            address = new InProcessAddress();
        } else if (urlForAddress.startsWith("tcp") || urlForAddress.startsWith("mqtt")) {
            address = new MqttAddress(urlForAddress, channelId);
        } else {
            address = new ChannelAddress(urlForAddress, channelId);
        }
        DiscoveryEntry discoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), domain, interfaceName, participantId, new ProviderQos(), System.currentTimeMillis(), Long.MAX_VALUE, "", address);
        logger.debug("Created legacy discovery entry: {}", discoveryEntry);
        legacyDiscoveryEntries.put(interfaceClass, discoveryEntry);
        legacyAddresses.put(interfaceClass, address);
    } else {
        logger.trace("Insufficient properties data to create entry for interface {}", interfaceName);
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) Version(joynr.types.Version) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 19 with MqttAddress

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

the class GlobalCapabilitiesDirectoryEjb method add.

@Override
public void add(GlobalDiscoveryEntry globalDiscoveryEntry) {
    logger.debug("Adding global discovery entry {}", globalDiscoveryEntry);
    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 {
        clusterControllerId = String.valueOf(address);
    }
    GlobalDiscoveryEntryPersisted entity = new GlobalDiscoveryEntryPersisted(globalDiscoveryEntry, clusterControllerId);
    GlobalDiscoveryEntryPersisted persisted = entityManager.find(GlobalDiscoveryEntryPersisted.class, entity.getParticipantId());
    if (persisted == null) {
        entityManager.persist(entity);
    } else {
        entityManager.merge(entity);
    }
}
Also used : ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) GlobalDiscoveryEntryPersisted(io.joynr.capabilities.GlobalDiscoveryEntryPersisted) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Aggregations

MqttAddress (joynr.system.RoutingTypes.MqttAddress)19 Address (joynr.system.RoutingTypes.Address)11 ProviderQos (joynr.types.ProviderQos)10 Test (org.junit.Test)9 Version (joynr.types.Version)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)7 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)6 DiscoveryEntry (joynr.types.DiscoveryEntry)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 HashSet (java.util.HashSet)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 GlobalDiscoveryEntryPersisted (io.joynr.capabilities.GlobalDiscoveryEntryPersisted)2 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 MessagingQos (io.joynr.messaging.MessagingQos)2 InProcessAddress (io.joynr.messaging.inprocess.InProcessAddress)2 Callback (io.joynr.proxy.Callback)2 Future (io.joynr.proxy.Future)2 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)2 ArrayList (java.util.ArrayList)2