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);
}
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);
}
}
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);
}
}
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);
}
}
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());
}
});
}
}
Aggregations