Search in sources :

Example 1 with MulticastSubscriptionRequest

use of joynr.MulticastSubscriptionRequest 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 2 with MulticastSubscriptionRequest

use of joynr.MulticastSubscriptionRequest 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)

Example 3 with MulticastSubscriptionRequest

use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.

the class DispatcherImplTest method testReceiveMulticastSubscription.

@Test
public void testReceiveMulticastSubscription() throws Exception {
    String from = "from";
    String to = "to";
    MulticastSubscriptionRequest subscriptionRequest = new MulticastSubscriptionRequest("multicastId", "subscriptionId", "multicastName", new OnChangeSubscriptionQos());
    MutableMessage joynrMessage = messageFactory.createSubscriptionRequest(from, to, subscriptionRequest, new MessagingQos(1000L));
    MutableMessageFactory messageFactoryMock = mock(MutableMessageFactory.class);
    ObjectMapper objectMapperMock = mock(ObjectMapper.class);
    when(objectMapperMock.readValue(anyString(), eq(SubscriptionRequest.class))).thenReturn(subscriptionRequest);
    fixture = new DispatcherImpl(requestReplyManagerMock, subscriptionManagerMock, publicationManagerMock, messageRouterMock, messageSenderMock, messageFactoryMock, objectMapperMock);
    fixture.messageArrived(joynrMessage.getImmutableMessage());
    verify(publicationManagerMock).addSubscriptionRequest(eq(from), eq(to), eq(subscriptionRequest));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionRequest(joynr.SubscriptionRequest) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) MutableMessage(joynr.MutableMessage) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) Matchers.anyString(org.mockito.Matchers.anyString) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with MulticastSubscriptionRequest

use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.

the class MutableMessageFactory method createSubscriptionRequest.

public MutableMessage createSubscriptionRequest(String fromParticipantId, String toParticipantId, SubscriptionRequest subscriptionRequest, MessagingQos messagingQos) {
    String messageType;
    if (subscriptionRequest instanceof BroadcastSubscriptionRequest) {
        messageType = Message.VALUE_MESSAGE_TYPE_BROADCAST_SUBSCRIPTION_REQUEST;
    } else if (subscriptionRequest instanceof MulticastSubscriptionRequest) {
        messageType = Message.VALUE_MESSAGE_TYPE_MULTICAST_SUBSCRIPTION_REQUEST;
    } else {
        messageType = Message.VALUE_MESSAGE_TYPE_SUBSCRIPTION_REQUEST;
    }
    MutableMessage msg = createMessage(messageType, fromParticipantId, toParticipantId, subscriptionRequest, messagingQos);
    addRequestReplyIdCustomHeader(msg, subscriptionRequest.getSubscriptionId());
    return msg;
}
Also used : MutableMessage(joynr.MutableMessage) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest)

Example 5 with MulticastSubscriptionRequest

use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.

the class MutableMessageFactoryTest method testCreateMulticastSubscriptionRequest.

@Test
public void testCreateMulticastSubscriptionRequest() {
    String multicastId = "multicastId";
    String subscriptionId = "subscriptionId";
    String multicastName = "multicastName";
    SubscriptionQos subscriptionQos = mock(SubscriptionQos.class);
    MulticastSubscriptionRequest multicastSubscriptionRequest = new MulticastSubscriptionRequest(multicastId, subscriptionId, multicastName, subscriptionQos);
    MutableMessage result = mutableMessageFactory.createSubscriptionRequest(fromParticipantId, toParticipantId, multicastSubscriptionRequest, messagingQos);
    assertNotNull(result);
    assertEquals(Message.VALUE_MESSAGE_TYPE_MULTICAST_SUBSCRIPTION_REQUEST, result.getType());
    assertExpiryDateEquals(expiryDate.getValue(), result);
}
Also used : MutableMessage(joynr.MutableMessage) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) Test(org.junit.Test)

Aggregations

MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 MutableMessage (joynr.MutableMessage)4 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)2 SubscriptionRequest (joynr.SubscriptionRequest)2 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MessagingQos (io.joynr.messaging.MessagingQos)1 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)1 Pattern (java.util.regex.Pattern)1 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)1 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)1 Matchers.anyString (org.mockito.Matchers.anyString)1