use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PushingPublicationTest method setupPureOnChangedQos.
void setupPureOnChangedQos() {
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
qos.setMinIntervalMs(SubscriptionQos.IGNORE_VALUE).setValidityMs(19000).setPublicationTtlMs(1000);
subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, qos);
}
use of joynr.OnChangeSubscriptionQos 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));
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class AbstractBroadcastEnd2EndTest method createDefaultOnChangeSubscriptionQos.
private OnChangeSubscriptionQos createDefaultOnChangeSubscriptionQos() {
OnChangeSubscriptionQos onChangeSubscriptionQos = new OnChangeSubscriptionQos();
onChangeSubscriptionQos.setMinIntervalMs(0).setValidityMs(CONST_DEFAULT_TEST_TIMEOUT).setPublicationTtlMs(CONST_DEFAULT_TEST_TIMEOUT);
return onChangeSubscriptionQos;
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class AbstractBroadcastEnd2EndTest method subscribeToSelectiveBroadcast_FilterFalse.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToSelectiveBroadcast_FilterFalse() throws InterruptedException {
final Semaphore broadcastReceived = new Semaphore(0);
final LocationUpdateSelectiveBroadcastFilterParameters testFilterParameters = new LocationUpdateSelectiveBroadcastFilterParameters();
testFilterParameters.setCountry("Germany");
testFilterParameters.setStartTime("4.00 pm");
testLocationUpdateSelectiveBroadcastFilter filter1 = new testLocationUpdateSelectiveBroadcastFilter() {
@Override
public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
assertEquals(testFilterParameters, filterParameters);
return true;
}
};
testLocationUpdateSelectiveBroadcastFilter filter2 = new testLocationUpdateSelectiveBroadcastFilter() {
@Override
public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
assertEquals(testFilterParameters, filterParameters);
return false;
}
};
getSubscriptionTestsPublisher().addBroadcastFilter(filter1);
getSubscriptionTestsPublisher().addBroadcastFilter(filter2);
OnChangeSubscriptionQos subscriptionQos = createDefaultOnChangeSubscriptionQos();
proxy.subscribeToLocationUpdateSelectiveBroadcast(new testBroadcastInterface.LocationUpdateSelectiveBroadcastAdapter() {
@Override
public void onReceive(GpsLocation location) {
assertEquals(expectedLocation, location);
broadcastReceived.release();
}
}, subscriptionQos, testFilterParameters);
Thread.sleep(300);
provider.fireLocationUpdateSelective(expectedLocation);
assertFalse(broadcastReceived.tryAcquire(500, TimeUnit.MILLISECONDS));
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerImpl method handleSubscriptionRequest.
private void handleSubscriptionRequest(PublicationInformation publicationInformation, SubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
final String subscriptionId = subscriptionRequest.getSubscriptionId();
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
MessagingQos messagingQos = createMessagingQos(subscriptionQos);
try {
Method method = findGetterForAttributeName(providerContainer.getProviderProxy().getClass(), subscriptionRequest.getSubscribedToName());
triggerPublication(publicationInformation, providerContainer, method);
boolean hasSubscriptionHeartBeat = subscriptionQos instanceof HeartbeatSubscriptionInformation;
boolean isOnChangeSubscription = subscriptionQos instanceof OnChangeSubscriptionQos;
if (hasSubscriptionHeartBeat || isOnChangeSubscription) {
// TODO: send error subscription reply is periodMs < MIN_PERIOD_MS or periodMs > MAX_PERIOD_MS?
final PublicationTimer timer = new PublicationTimer(publicationInformation, method, providerContainer, this, attributePollInterpreter);
timer.startTimer();
publicationTimers.put(subscriptionId, timer);
}
if (subscriptionQos instanceof OnChangeSubscriptionQos) {
handleOnChangeSubscription(subscriptionRequest, providerContainer, subscriptionId);
}
dispatcher.sendSubscriptionReply(publicationInformation.providerParticipantId, publicationInformation.proxyParticipantId, new SubscriptionReply(subscriptionId), messagingQos);
} catch (NoSuchMethodException e) {
cancelPublicationCreation(subscriptionId);
logger.error("Error subscribing: {}. The provider does not have the requested attribute", subscriptionRequest);
sendSubscriptionReplyWithError(publicationInformation, subscriptionId, e, messagingQos);
}
}
Aggregations