Search in sources :

Example 6 with DiscoveryEntryWithMetaInfo

use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.

the class HighestPriorityArbitrationStrategyFunction method select.

@Override
public final Set<DiscoveryEntryWithMetaInfo> select(Map<String, String> parameters, final Collection<DiscoveryEntryWithMetaInfo> capabilities) {
    logger.trace("starting select Provider by priority");
    DiscoveryEntryWithMetaInfo highestPriorityCapability = null;
    long highestPriority = -1L;
    for (DiscoveryEntryWithMetaInfo discoveryEntry : capabilities) {
        // Search for the provider with the highest priority
        Long priority = discoveryEntry.getQos().getPriority();
        logger.trace("Looking at capability with priority " + priority.toString());
        if (highestPriority < priority) {
            highestPriority = priority;
            highestPriorityCapability = discoveryEntry;
        }
    }
    logger.trace("capability with highest priority: " + highestPriority + "\r\n" + highestPriorityCapability);
    return highestPriorityCapability == null ? null : Sets.newHashSet(highestPriorityCapability);
}
Also used : DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Example 7 with DiscoveryEntryWithMetaInfo

use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.

the class DispatcherImpl method sendSubscriptionRequest.

// CHECKSTYLE:ON
@Override
public void sendSubscriptionRequest(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, SubscriptionRequest subscriptionRequest, MessagingQos messagingQos) {
    for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
        MutableMessage message = messageFactory.createSubscriptionRequest(fromParticipantId, toDiscoveryEntry.getParticipantId(), subscriptionRequest, messagingQos);
        message.setLocalMessage(toDiscoveryEntry.getIsLocal());
        if (subscriptionRequest instanceof MulticastSubscriptionRequest) {
            String multicastId = ((MulticastSubscriptionRequest) subscriptionRequest).getMulticastId();
            messageRouter.addMulticastReceiver(multicastId, fromParticipantId, toDiscoveryEntry.getParticipantId());
        }
        logger.debug("Send SubscriptionRequest: subscriptionId: {}, messageId: {}, proxy participantId: {}, provider participantId: {}", subscriptionRequest.getSubscriptionId(), message.getId(), fromParticipantId, toDiscoveryEntry.getParticipantId());
        messageSender.sendMessage(message);
    }
}
Also used : MutableMessage(joynr.MutableMessage) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest)

Example 8 with DiscoveryEntryWithMetaInfo

use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.

the class DispatcherImpl method sendSubscriptionStop.

@Override
public void sendSubscriptionStop(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, SubscriptionStop subscriptionStop, MessagingQos messagingQos) {
    for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
        MutableMessage message = messageFactory.createSubscriptionStop(fromParticipantId, toDiscoveryEntry.getParticipantId(), subscriptionStop, messagingQos);
        message.setLocalMessage(toDiscoveryEntry.getIsLocal());
        logger.debug("UNREGISTER SUBSCRIPTION call proxy: subscriptionId: {}, messageId: {}, proxy participantId: {}, " + "provider participantId: {}", subscriptionStop.getSubscriptionId(), message.getId(), fromParticipantId, toDiscoveryEntry.getParticipantId());
        messageSender.sendMessage(message);
    }
}
Also used : MutableMessage(joynr.MutableMessage) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Example 9 with DiscoveryEntryWithMetaInfo

use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.

the class RequestReplyManagerImpl method sendOneWayRequest.

@Override
public void sendOneWayRequest(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, OneWayRequest oneWayRequest, MessagingQos messagingQos) {
    for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
        MutableMessage message = messageFactory.createOneWayRequest(fromParticipantId, toDiscoveryEntry.getParticipantId(), oneWayRequest, messagingQos);
        logger.debug("Send OneWayRequest: method: {}, messageId: {}, proxy participantId: {}, provider participantId: {}", oneWayRequest.getMethodName(), message.getId(), fromParticipantId, toDiscoveryEntry.getParticipantId());
        messageSender.sendMessage(message);
    }
}
Also used : MutableMessage(joynr.MutableMessage) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Example 10 with DiscoveryEntryWithMetaInfo

use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.

the class SubscriptionManagerImpl method registerMulticastSubscription.

@Override
public void registerMulticastSubscription(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, final MulticastSubscribeInvocation multicastSubscribeInvocation) {
    for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
        final String multicastId = MulticastIdUtil.createMulticastId(toDiscoveryEntry.getParticipantId(), multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getPartitions());
        logger.debug("SUBSCRIPTION call proxy: subscriptionId: {}, multicastId: {}, broadcast: {}, qos: {}," + " proxy participantId: {}, provider participantId: {}", multicastSubscribeInvocation.getSubscriptionId(), multicastId, multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getQos(), fromParticipantId, toDiscoveryEntry.getParticipantId());
        registerSubscription(fromParticipantId, toDiscoveryEntries, multicastSubscribeInvocation, new RegisterDataAndCreateSubscriptionRequest() {

            @Override
            public SubscriptionRequest execute() {
                String subscriptionId = multicastSubscribeInvocation.getSubscriptionId();
                logger.trace("Multicast subscription registered with Id: " + subscriptionId);
                Pattern multicastIdPattern = multicastWildcardRegexFactory.createIdPattern(multicastId);
                if (!multicastSubscribersDirectory.containsKey(multicastIdPattern)) {
                    multicastSubscribersDirectory.putIfAbsent(multicastIdPattern, Sets.<String>newHashSet());
                }
                multicastSubscribersDirectory.get(multicastIdPattern).add(subscriptionId);
                multicastBroadcastTypes.putIfAbsent(multicastIdPattern, multicastSubscribeInvocation.getOutParameterTypes());
                broadcastSubscriptionListenerDirectory.put(subscriptionId, multicastSubscribeInvocation.getListener());
                return new MulticastSubscriptionRequest(multicastId, multicastSubscribeInvocation.getSubscriptionId(), multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getQos());
            }
        });
    }
}
Also used : Pattern(java.util.regex.Pattern) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionRequest(joynr.SubscriptionRequest) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest)

Aggregations

DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)66 Test (org.junit.Test)32 Version (joynr.types.Version)29 ProviderQos (joynr.types.ProviderQos)24 DiscoveryEntry (joynr.types.DiscoveryEntry)16 HashSet (java.util.HashSet)14 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)13 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)11 Matchers.anyString (org.mockito.Matchers.anyString)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)9 Before (org.junit.Before)9 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 MessagingQos (io.joynr.messaging.MessagingQos)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Set (java.util.Set)7 Callback (io.joynr.proxy.Callback)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 Collection (java.util.Collection)5