use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerImpl method validateAndGetSubscriptionEndDelay.
private long validateAndGetSubscriptionEndDelay(SubscriptionRequest subscriptionRequest) {
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
long subscriptionEndDelay = getSubscriptionEndDelay(subscriptionQos);
if (subscriptionEndDelay < 0) {
throw new SubscriptionException(subscriptionRequest.getSubscriptionId(), "Subscription expired.");
}
return subscriptionEndDelay;
}
use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerImpl method handleBroadcastSubscriptionRequest.
private void handleBroadcastSubscriptionRequest(String proxyParticipantId, String providerParticipantId, BroadcastSubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
logger.trace("adding broadcast publication: {}", subscriptionRequest);
BroadcastListener broadcastListener = new BroadcastListenerImpl(subscriptionRequest.getSubscriptionId(), this);
String broadcastName = subscriptionRequest.getSubscribedToName();
providerContainer.getSubscriptionPublisher().registerBroadcastListener(broadcastName, broadcastListener);
unregisterBroadcastListeners.put(subscriptionRequest.getSubscriptionId(), new UnregisterBroadcastListener(providerContainer.getSubscriptionPublisher(), broadcastName, broadcastListener));
final String subscriptionId = subscriptionRequest.getSubscriptionId();
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
MessagingQos messagingQos = createMessagingQos(subscriptionQos);
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId);
dispatcher.sendSubscriptionReply(providerParticipantId, proxyParticipantId, subscriptionReply, messagingQos);
}
use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class SubscriptionQosTest method createPeriodicSubscriptionQosWithValidity.
@Test
public void createPeriodicSubscriptionQosWithValidity() throws Exception {
long validityMs = 1000;
long lowerBound = System.currentTimeMillis() + validityMs;
SubscriptionQos periodicSubscriptionQos = new PeriodicSubscriptionQos().setValidityMs(validityMs);
long upperBound = System.currentTimeMillis() + validityMs;
assertTrue(periodicSubscriptionQos.getExpiryDateMs() >= lowerBound);
assertTrue(periodicSubscriptionQos.getExpiryDateMs() <= upperBound);
}
use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class ConnectorTest method subscribeToAttributeCallCallsSubscriptionManagerWithCorrectArguments.
@Test
public void subscribeToAttributeCallCallsSubscriptionManagerWithCorrectArguments() {
AttributeSubscriptionListener<String> listener = new AttributeSubscriptionAdapter<>();
SubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
ConnectorInvocationHandler connector = createConnector();
assertNotNull(connector);
try {
Method method = TestSubscriptionInterface.class.getDeclaredMethod("subscribeToTestAttribute", AttributeSubscriptionListener.class, SubscriptionQos.class);
AttributeSubscribeInvocation invocation = new AttributeSubscribeInvocation(method, new Object[] { listener, subscriptionQos }, null);
connector.executeSubscriptionMethod(invocation);
verify(subscriptionManager, times(1)).registerAttributeSubscription(fromParticipantId, toDiscoveryEntries, invocation);
} catch (Exception e) {
fail("Unexpected exception from attribute subscribe call: " + e);
}
}
use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class ProxyInvocationHandlerTest method testPartitionsPassedToMulticastSubscription.
@Test
public void testPartitionsPassedToMulticastSubscription() throws NoSuchMethodException, ApplicationException {
ConnectorInvocationHandler connectorInvocationHandler = mock(ConnectorInvocationHandler.class);
when(connectorFactory.create(Mockito.anyString(), Mockito.<ArbitrationResult>any(), Mockito.eq(messagingQos))).thenReturn(connectorInvocationHandler);
MyBroadcastSubscriptionListener broadcastSubscriptionListener = mock(MyBroadcastSubscriptionListener.class);
SubscriptionQos subscriptionQos = mock(SubscriptionQos.class);
Method subscribeMethod = MyBroadcastInterface.class.getMethod("subscribeToMyMulticast", MyBroadcastSubscriptionListener.class, SubscriptionQos.class, String[].class);
Object[] args = new Object[] { broadcastSubscriptionListener, subscriptionQos, new String[] { "one", "two", "three" } };
ArbitrationResult arbitrationResult = new ArbitrationResult();
DiscoveryEntryWithMetaInfo discoveryEntry = new DiscoveryEntryWithMetaInfo();
discoveryEntry.setParticipantId("participantId");
arbitrationResult.setDiscoveryEntries(Sets.newHashSet(discoveryEntry));
proxyInvocationHandler.createConnector(arbitrationResult);
proxyInvocationHandler.invoke(subscribeMethod, args);
ArgumentCaptor<MulticastSubscribeInvocation> captor = ArgumentCaptor.forClass(MulticastSubscribeInvocation.class);
verify(connectorInvocationHandler).executeSubscriptionMethod(captor.capture());
MulticastSubscribeInvocation multicastSubscribeInvocation = captor.getValue();
assertNotNull(multicastSubscribeInvocation);
assertArrayEquals(new String[] { "one", "two", "three" }, multicastSubscribeInvocation.getPartitions());
}
Aggregations