本文整理汇总了C++中DiscoveryQos::setDiscoveryTimeout方法的典型用法代码示例。如果您正苦于以下问题:C++ DiscoveryQos::setDiscoveryTimeout方法的具体用法?C++ DiscoveryQos::setDiscoveryTimeout怎么用?C++ DiscoveryQos::setDiscoveryTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscoveryQos
的用法示例。
在下文中一共展示了DiscoveryQos::setDiscoveryTimeout方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mockProvider
// leadsm to assert failure in GpsInProcessConnector line 185: not yet implemented in connector
TEST_F(End2EndRPCTest, call_rpc_method_and_get_expected_result)
{
std::shared_ptr<MockGpsProvider> mockProvider(new MockGpsProvider());
types::Localisation::GpsLocation gpsLocation1(1.1, 2.2, 3.3, types::Localisation::GpsFixEnum::MODE2D, 0.0, 0.0, 0.0, 0.0, 444, 444, 4);
runtime->registerProvider<vehicle::GpsProvider>(domain, mockProvider);
QThreadSleep::msleep(550);
ProxyBuilder<vehicle::GpsProxy>* gpsProxyBuilder = runtime->createProxyBuilder<vehicle::GpsProxy>(domain);
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeout(1000);
qlonglong qosRoundTripTTL = 40000;
QSharedPointer<vehicle::GpsProxy> gpsProxy(gpsProxyBuilder
->setMessagingQos(MessagingQos(qosRoundTripTTL))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build());
std::shared_ptr<Future<int> >gpsFuture (gpsProxy->calculateAvailableSatellitesAsync());
gpsFuture->waitForFinished();
int expectedValue = 42; //as defined in MockGpsProvider
int actualValue;
gpsFuture->getValues(actualValue);
EXPECT_EQ(expectedValue, actualValue);
//TODO CA: shared pointer for proxy builder?
delete gpsProxyBuilder;
// This is not yet implemented in CapabilitiesClient
// runtime->unregisterProvider("Fake_ParticipantId_vehicle/gpsDummyProvider");
}
示例2: mockProvider
TEST_F(End2EndSSLTest, call_rpc_method_and_get_expected_result)
{
// Create a provider
std::shared_ptr<MockGpsProvider> mockProvider(new MockGpsProvider());
runtime->registerProvider<vehicle::GpsProvider>(domain, mockProvider);
std::this_thread::sleep_for(std::chrono::milliseconds(550));
// Build a proxy
ProxyBuilder<vehicle::GpsProxy>* gpsProxyBuilder = runtime->createProxyBuilder<vehicle::GpsProxy>(domain);
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeout(1000);
qlonglong qosRoundTripTTL = 40000;
std::shared_ptr<vehicle::GpsProxy> gpsProxy(gpsProxyBuilder
->setMessagingQos(MessagingQos(qosRoundTripTTL))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build());
// Call the provider and wait for a result
std::shared_ptr<Future<int> >gpsFuture (gpsProxy->calculateAvailableSatellitesAsync());
gpsFuture->wait();
int expectedValue = 42; //as defined in MockGpsProvider
int actualValue;
gpsFuture->get(actualValue);
EXPECT_EQ(expectedValue, actualValue);
delete gpsProxyBuilder;
}
示例3: status
TEST_F(End2EndRPCTest, call_void_operation)
{
std::shared_ptr<MockTestProvider> mockProvider(new MockTestProvider(types::ProviderQos(
std::vector<types::CustomParameter>(),
1,
1,
types::ProviderScope::GLOBAL,
false
)));
runtime->registerProvider<tests::testProvider>(domain, mockProvider);
QThreadSleep::msleep(550);
ProxyBuilder<tests::testProxy>* testProxyBuilder = runtime->createProxyBuilder<tests::testProxy>(domain);
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeout(1000);
qlonglong qosRoundTripTTL = 40000;
tests::testProxy* testProxy = testProxyBuilder
->setMessagingQos(MessagingQos(qosRoundTripTTL))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build();
RequestStatus status(testProxy->voidOperation());
// EXPECT_EQ(expectedValue, gpsFuture->getValue());
//TODO CA: shared pointer for proxy builder?
delete testProxy;
delete testProxyBuilder;
// This is not yet implemented in CapabilitiesClient
// runtime->unregisterProvider("Fake_ParticipantId_vehicle/gpsDummyProvider");
}
示例4: systemSettings
SystemServicesRoutingTest() :
settingsFilename("test-resources/SystemServicesRoutingTest.settings"),
settings(new QSettings(settingsFilename, QSettings::IniFormat)),
routingDomain(),
routingProviderParticipantId(),
runtime(NULL),
mockMessageReceiver(new MockMessageReceiver()),
mockMessageSender(new MockMessageSender()),
discoveryQos(),
routingProxyBuilder(NULL),
routingProxy(NULL)
{
SystemServicesSettings systemSettings(*settings);
systemSettings.printSettings();
routingDomain = TypeUtil::toStd(systemSettings.getDomain());
routingProviderParticipantId = systemSettings.getCcRoutingProviderParticipantId();
discoveryQos.setCacheMaxAge(1000);
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
discoveryQos.addCustomParameter("fixedParticipantId", TypeUtil::toStd(routingProviderParticipantId));
discoveryQos.setDiscoveryTimeout(50);
QString channelId("SystemServicesRoutingTest.ChannelId");
EXPECT_CALL(*(dynamic_cast<MockMessageReceiver*>(mockMessageReceiver)), getReceiveChannelId())
.WillRepeatedly(::testing::ReturnRefOfCopy(channelId));
//runtime can only be created, after MockMessageReceiver has been told to return
//a channelId for getReceiveChannelId.
runtime = new JoynrClusterControllerRuntime(NULL, settings, mockMessageReceiver, mockMessageSender);
// routing provider is normally registered in JoynrClusterControllerRuntime::create
runtime->registerRoutingProvider();
}
示例5: SetUp
void SetUp() {
// start libjoynr runtime
runtime = new LibJoynrDbusRuntime(
new Settings(temporarylibjoynrSettingsFilename)
);
SystemServicesSettings systemSettings(settings);
systemSettings.printSettings();
std::string systemServicesDomain(systemSettings.getDomain());
// setup routing proxy
std::string routingProviderParticipantId(systemSettings.getCcRoutingProviderParticipantId());
routingProxyBuilder = runtime
->createProxyBuilder<joynr::system::RoutingProxy>(systemServicesDomain);
DiscoveryQos discoveryQos;
discoveryQos.setCacheMaxAge(1000);
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
discoveryQos.addCustomParameter("fixedParticipantId", routingProviderParticipantId);
discoveryQos.setDiscoveryTimeout(50);
routingProxy = routingProxyBuilder
->setMessagingQos(MessagingQos(5000))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build();
EXPECT_TRUE(routingProxy != NULL);
// setup discovery proxy
std::string discoveryProviderParticipantId(systemSettings.getCcDiscoveryProviderParticipantId());
discoveryProxyBuilder = runtime
->createProxyBuilder<joynr::system::DiscoveryProxy>(systemServicesDomain);
discoveryQos = DiscoveryQos();
discoveryQos.setCacheMaxAge(1000);
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT);
discoveryQos.addCustomParameter("fixedParticipantId", discoveryProviderParticipantId);
discoveryQos.setDiscoveryTimeout(50);
discoveryProxy = discoveryProxyBuilder
->setMessagingQos(MessagingQos(5000))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build();
EXPECT_TRUE(discoveryProxy != NULL);
mockTestProvider = std::make_shared<MockTestProvider>(mockTestProviderQos);
}
示例6: getCapabilitiesForParticipantId
TEST_F(LocalCapabilitiesDirectoryTest, registerCapabilityAddsToCache) {
EXPECT_CALL(*capabilitiesClient, getCapabilitiesForParticipantId(dummyParticipantId1,_)).Times(0);
EXPECT_CALL(*capabilitiesClient, registerCapabilities(_)).Times(1);
localCapabilitiesDirectory->registerCapability(DOMAIN_1_NAME ,INTERFACE_1_NAME, types::ProviderQos(), dummyParticipantId1);
DiscoveryQos qos;
qos.setCacheMaxAge(LocalCapabilitiesDirectory::NO_CACHE_FRESHNESS_REQ());
qos.setDiscoveryTimeout(ICapabilities::NO_TIMEOUT());
localCapabilitiesDirectory->getCapabilities(dummyParticipantId1, callback, discoveryQos);
EXPECT_EQ(1, callback->getResults(TIMEOUT).size());
}
示例7: copyDbusDiscoveryQosToJoynr
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));
}
}
示例8: testOneShotAttributeSubscription
void testOneShotAttributeSubscription(const T& expectedValue,
SubscribeTo subscribeTo,
ChangeAttribute setAttribute,
const std::string& attributeName) {
MockSubscriptionListenerOneType<T>* mockListener =
new MockSubscriptionListenerOneType<T>();
// Use a semaphore to count and wait on calls to the mock listener
ON_CALL(*mockListener, onReceive(Eq(expectedValue)))
.WillByDefault(ReleaseSemaphore(&semaphore));
std::shared_ptr<ISubscriptionListener<T>> subscriptionListener(
mockListener);
std::shared_ptr<tests::DefaulttestProvider> testProvider(new tests::DefaulttestProvider());
runtime1->registerProvider<tests::testProvider>(domainName, testProvider);
//This wait is necessary, because registerProvider is async, and a lookup could occur
// before the register has finished.
std::this_thread::sleep_for(std::chrono::milliseconds(registerProviderWait));
(*testProvider.*setAttribute)(expectedValue, [](){}, [](const joynr::exceptions::ProviderRuntimeException&) {});
ProxyBuilder<tests::testProxy>* testProxyBuilder
= runtime2->createProxyBuilder<tests::testProxy>(domainName);
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeout(1000);
discoveryQos.setRetryInterval(250);
std::int64_t qosRoundTripTTL = 500;
// Send a message and expect to get a result
tests::testProxy* testProxy = testProxyBuilder
->setMessagingQos(MessagingQos(qosRoundTripTTL))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build();
std::int64_t minInterval_ms = 50;
OnChangeSubscriptionQos subscriptionQos(
500000, // validity_ms
minInterval_ms); // minInterval_ms
subscribeTo(testProxy, subscriptionListener, subscriptionQos);
waitForAttributeSubscriptionArrivedAtProvider(testProvider, attributeName);
// Wait for a subscription message to arrive
ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(3)));
delete testProxyBuilder;
delete testProxy;
}
示例9: subscriptionQos
TEST_F(End2EndBroadcastTest, subscribeToBroadcastWithEnumOutput) {
tests::testTypes::TestEnum::Enum expectedTestEnum = tests::testTypes::TestEnum::TWO;
MockSubscriptionListenerOneType<tests::testTypes::TestEnum::Enum>* mockListener =
new MockSubscriptionListenerOneType<tests::testTypes::TestEnum::Enum>();
// Use a semaphore to count and wait on calls to the mock listener
ON_CALL(*mockListener, onReceive(Eq(expectedTestEnum)))
.WillByDefault(ReleaseSemaphore(&semaphore));
std::shared_ptr<ISubscriptionListener<tests::testTypes::TestEnum::Enum>> subscriptionListener(
mockListener);
std::shared_ptr<MyTestProvider> testProvider(new MyTestProvider());
runtime1->registerProvider<tests::testProvider>(domainName, testProvider);
//This wait is necessary, because registerProvider is async, and a lookup could occur
// before the register has finished.
QThreadSleep::msleep(registerProviderWait);
ProxyBuilder<tests::testProxy>* testProxyBuilder
= runtime2->createProxyBuilder<tests::testProxy>(domainName);
DiscoveryQos discoveryQos;
discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY);
discoveryQos.setDiscoveryTimeout(1000);
discoveryQos.setRetryInterval(250);
qlonglong qosRoundTripTTL = 500;
// Send a message and expect to get a result
tests::testProxy* testProxy = testProxyBuilder
->setMessagingQos(MessagingQos(qosRoundTripTTL))
->setCached(false)
->setDiscoveryQos(discoveryQos)
->build();
int64_t minInterval_ms = 50;
OnChangeSubscriptionQos subscriptionQos(
500000, // validity_ms
minInterval_ms); // minInterval_ms
testProxy->subscribeToBroadcastWithEnumOutputBroadcast(subscriptionListener, subscriptionQos);
waitForBroadcastSubscriptionArrivedAtProvider(testProvider, "broadcastWithEnumOutput");
testProvider->fireBroadcastWithEnumOutput(expectedTestEnum);
// Wait for a subscription message to arrive
ASSERT_TRUE(semaphore.tryAcquire(1, 3000));
delete testProxyBuilder;
delete testProxy;
}