예제 #1
0
void DbusCapabilitiesUtil::copyDbusDiscoveryQosToJoynr(const joynr::messaging::types::Types::DiscoveryQos& dbusDiscoveryQos, DiscoveryQos& joynrDiscoveryQos) {
    // copy arbitration strategy
    switch (dbusDiscoveryQos.arbitrationStrategy) {
    case joynr::messaging::types::Types::ArbitrationStrategy::FIXED_CHANNEL:
        joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
        break;
    case joynr::messaging::types::Types::ArbitrationStrategy::HIGHEST_PRIORITY:
        joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
        break;
    case joynr::messaging::types::Types::ArbitrationStrategy::KEYWORD:
        joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::KEYWORD);
        break;
    case joynr::messaging::types::Types::ArbitrationStrategy::LOCAL_ONLY:
        joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::LOCAL_ONLY);
        break;
    case joynr::messaging::types::Types::ArbitrationStrategy::NOT_SET:
        joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::NOT_SET);
        break;
    default:
        assert(false);
    }

    switch(dbusDiscoveryQos.discoveryScope) {
    case joynr::messaging::types::Types::DiscoveryScope::GLOBAL_ONLY:
        joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::GLOBAL_ONLY);
        break;
    case joynr::messaging::types::Types::DiscoveryScope::LOCAL_ONLY:
        joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_ONLY);
        break;
    case joynr::messaging::types::Types::DiscoveryScope::LOCAL_THEN_GLOBAL:
        joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_THEN_GLOBAL);
        break;
    case joynr::messaging::types::Types::DiscoveryScope::LOCAL_AND_GLOBAL:
        joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_AND_GLOBAL);
        break;
    default:
        assert(false);
    }

    joynrDiscoveryQos.setCacheMaxAge(dbusDiscoveryQos.cacheMaxAge);
    joynrDiscoveryQos.setDiscoveryTimeout(dbusDiscoveryQos.discoveryTimeout);
    joynrDiscoveryQos.setProviderMustSupportOnChange(dbusDiscoveryQos.providerMustSupportOnChange);
    joynrDiscoveryQos.setRetryInterval(dbusDiscoveryQos.retryInterval);

    // copy the custom parameters
    auto parameterMap = dbusDiscoveryQos.customParameters;
    for(auto it = parameterMap.begin(); it != parameterMap.end(); it++) {
        joynr::messaging::types::Types::CustomParameter parameter = it->second;
        // initialize the joynr parameter
        joynrDiscoveryQos.addCustomParameter(QString::fromStdString(parameter.name),
                        QString::fromStdString(parameter.value));
    }
}
예제 #2
0
    void init(const std::string& settings)
    {
        ccRuntime =
                JoynrClusterControllerRuntime::create(std::make_unique<joynr::Settings>(settings));

        types::ProviderQos providerQos;
        providerQos.setScope(joynr::types::ProviderScope::LOCAL);

        testProvider = std::make_shared<MockTestProvider>();
        providerParticipantId =
                ccRuntime->registerProvider<tests::testProvider>(domain, testProvider, providerQos);

        // Create a proxy
        auto testProxyBuilder = ccRuntime->createProxyBuilder<tests::testProxy>(domain);
        DiscoveryQos discoveryQos;
        discoveryQos.setDiscoveryScope(types::DiscoveryScope::LOCAL_ONLY);
        discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
        discoveryQos.setDiscoveryTimeoutMs(1000);

        testProxy = testProxyBuilder->setMessagingQos(MessagingQos(MESSAGINGQOS_TTL))
                            ->setDiscoveryQos(discoveryQos)
                            ->build();
    }
예제 #3
0
TEST_F(MessageNotificationTest, messageToDisconnectedProviderCausesBroadcast)
{

    // 1. register provider
    auto testProvider = std::make_shared<tests::DefaulttestProvider>();
    joynr::types::ProviderQos providerQos;
    providerQos.setScope(joynr::types::ProviderScope::LOCAL);
    std::string providerParticipantId =
            libjoynrProviderRuntime->registerProvider<tests::testProvider>(
                    testDomain, testProvider, providerQos);

    // 2. create proxy
    DiscoveryQos discoveryQos;
    discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::LAST_SEEN);
    discoveryQos.setDiscoveryScope(joynr::types::DiscoveryScope::LOCAL_ONLY);
    MessagingQos messagingQos;
    messagingQos.setTtl(5000);

    auto testProxyBuilder = libjoynrProxyRuntime->createProxyBuilder<tests::testProxy>(testDomain);

    auto testProxy =
            testProxyBuilder->setMessagingQos(messagingQos)->setDiscoveryQos(discoveryQos)->build();

    Settings settings(settingsPath);
    SystemServicesSettings systemSettings(settings);
    auto messageNotificationProxyBuilder =
            libjoynrProxyRuntime->createProxyBuilder<joynr::system::MessageNotificationProxy>(
                    systemSettings.getDomain());

    DiscoveryQos messagingNotificationDiscoveryQos;
    messagingNotificationDiscoveryQos.setArbitrationStrategy(
            DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
    messagingNotificationDiscoveryQos.addCustomParameter(
            "fixedParticipantId", systemSettings.getCcMessageNotificationProviderParticipantId());
    messagingNotificationDiscoveryQos.setDiscoveryScope(joynr::types::DiscoveryScope::LOCAL_ONLY);

    auto messageNotificationProxy = messageNotificationProxyBuilder->setMessagingQos(messagingQos)
                                            ->setDiscoveryQos(messagingNotificationDiscoveryQos)
                                            ->build();

    // 3. subscribe to message notification broadcast
    auto mockListener = std::make_shared<MockSubscriptionListener>();
    EXPECT_CALL(*mockListener, onSubscribed(_)).Times(1);
    EXPECT_CALL(*mockListener, onError(_)).Times(0);

    joynr::system::MessageNotificationMessageQueuedForDeliveryBroadcastFilterParameters
            filterParameters;
    filterParameters.setParticipantId(providerParticipantId);

    auto future = messageNotificationProxy->subscribeToMessageQueuedForDeliveryBroadcast(
            filterParameters, mockListener, std::make_shared<OnChangeSubscriptionQos>());
    std::string subscriptionId;
    future->get(subscriptionId);

    // 4. disconnect provider runtime
    libjoynrProviderRuntime->shutdown();
    libjoynrProviderRuntime.reset();

    // 5. execute call on proxy while provider is not connected to cluster-controller

    auto onSuccess = [](const std::int32_t&) { FAIL(); };

    auto onError = [](const joynr::exceptions::JoynrRuntimeException&) {};

    EXPECT_CALL(*mockListener, onReceive(Eq(providerParticipantId), _))
            .WillOnce(ReleaseSemaphore(&semaphore));

    testProxy->addNumbersAsync(1, 2, 3, onSuccess, onError);

    // 6. wait for a broadcast message to arrive
    ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(3)));
    messageNotificationProxy->unsubscribeFromMessageQueuedForDeliveryBroadcast(subscriptionId);
}