当前位置: 首页>>代码示例>>C++>>正文


C++ SubscriptionRequest::add_path_list方法代码示例

本文整理汇总了C++中SubscriptionRequest::add_path_list方法的典型用法代码示例。如果您正苦于以下问题:C++ SubscriptionRequest::add_path_list方法的具体用法?C++ SubscriptionRequest::add_path_list怎么用?C++ SubscriptionRequest::add_path_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SubscriptionRequest的用法示例。


在下文中一共展示了SubscriptionRequest::add_path_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST_F(AgentConsolidatorTest, add) {
    AgentConsolidatorHandle *handle;
    SubscriptionRequest request;
    SubscriptionRequest system_accepted_request;
    telemetry::Path *path;

    // Build a request of valid paths
    path = request.add_path_list();
    path->set_path("firewall");
    path = request.add_path_list();
    path->set_path("port");

    // Add it to the consolidator
    handle = cons->addRequest(61, &request, &system_accepted_request);
    EXPECT_TRUE(handle != NULL);
    EXPECT_EQ(2, cons->getSystemRequestCount());
    EXPECT_EQ(1, cons->getAddCount());
    EXPECT_EQ(0, cons->getErrors());
    for (int i = 0; i < request.path_list_size(); i++) {
        EXPECT_STREQ(request.path_list(i).path().c_str(),
                     system_accepted_request.path_list(i).path().c_str());
    }

    // Simple check get call is good
    SubscriptionRequest *test_ptr;
    test_ptr = cons->getRequest(handle, false);
    EXPECT_TRUE(test_ptr != NULL);

    // Remove it now
    cons->removeRequest(handle);
    EXPECT_EQ(0, cons->getSystemRequestCount());
    EXPECT_EQ(1, cons->getRemCount());
    EXPECT_EQ(0, cons->getErrors());
}
开发者ID:M-Vivek,项目名称:jvsim,代码行数:34,代码来源:agent_test_consolidator_ut.cpp

示例2: sleep

void *
AgentConsolidatorTest::create (void *args)
{
    TestArgs *test_args = (TestArgs *) args;
    AgentConsolidator *cons = test_args->cons;
    AgentConsolidatorHandle *handle;
    SubscriptionRequest request;
    SubscriptionRequest system_accepted_request;
    telemetry::Path *path;

    // Build a request
    path = request.add_path_list();
    path->set_path("firewall");
    path = request.add_path_list();
    path->set_path("port");

    // Add it to the consolidator
    id_idx_t subscription_id = test_args->id;
    handle = cons->addRequest(subscription_id, &request,
                              &system_accepted_request);

    // Sleep randomly between 0 to 4 seconds
    sleep(rand()%5);

    // Now remove it
    cons->removeRequest(handle);

    return NULL;
}
开发者ID:M-Vivek,项目名称:jvsim,代码行数:29,代码来源:agent_test_consolidator_ut.cpp

示例3: key_value

void *
Service::proc (void *p_args)
{
    ServiceContext       *contextp = (ServiceContext *) p_args;
    ServiceInterestList  *interests = contextp->_interests;
    Service *service = contextp->_service;
    
    // Create a reader
    SubscriptionRequest request;
    Path *path;
    path = request.add_path_list();
    path->set_path(service->getName());
    path->set_sample_frequency(5000);
    
    ClientContext context;
    std::multimap<grpc::string_ref, grpc::string_ref> server_metadata;
    std::multimap<grpc::string_ref, grpc::string_ref>::iterator metadata_itr;
    std::unique_ptr<ClientReader<OpenConfigData>> reader(service->stub_->telemetrySubscribe(&context, request));
    
    // Get the subscription ID from the response
    // Wait for the initial meta data to come back
    reader->WaitForInitialMetadata();
    server_metadata = context.GetServerInitialMetadata();
    metadata_itr = server_metadata.find("init-response");
    std::string tmp = metadata_itr->second.data();
    
    // Use Textformat Printer APIs to convert to right format
    google::protobuf::TextFormat::Parser parser;
    SubscriptionReply reply;
    SubscriptionResponse *response;
    parser.ParseFromString(tmp, &reply);
    response = reply.mutable_response();
    service->setSubscriptionId(response->subscription_id());
    
    // Create the read channel
    OpenConfigData kv;
    while (reader->Read(&kv)) {
        for (int i = 0; i < kv.kv_size(); i++) {
            const KeyValue &kv_data = kv.kv(i);
            ServiceCallbackKeyValue key_value(kv_data.key(), kv_data.str_value());
            for (ServiceInterestListIterator itr = interests->begin(); itr != interests->end(); itr++) {
                Element *element = (*itr)->_element;
                (*itr)->_cb(element, &key_value);
            }
        }
    }

    // We are done.
    return NULL;
}
开发者ID:nkumar43212,项目名称:e2,代码行数:50,代码来源:Service.cpp


注:本文中的SubscriptionRequest::add_path_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。