本文整理汇总了C++中NetworkManager::sendOutMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkManager::sendOutMessage方法的具体用法?C++ NetworkManager::sendOutMessage怎么用?C++ NetworkManager::sendOutMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkManager
的用法示例。
在下文中一共展示了NetworkManager::sendOutMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeQuery
void executeQuery(const std::string& queryString, bool afl, QueryResult& queryResult, void* connection) const
{
const clock_t startClock = clock();
assert(queryResult.queryID>0);
// Executing query string
boost::shared_ptr<Query> query = Query::getQueryByID(queryResult.queryID);
boost::shared_ptr<QueryProcessor> queryProcessor = QueryProcessor::create();
assert(query->getQueryID() == queryResult.queryID);
StatisticsScope sScope(&query->statistics);
if (!query->logicalPlan->getRoot()) {
throw USER_EXCEPTION(SCIDB_SE_QPROC, SCIDB_LE_QUERY_WAS_EXECUTED);
}
std::ostringstream planString;
query->logicalPlan->toString(planString);
queryResult.explainLogical = planString.str();
// Note: Optimization will be performed while execution
boost::shared_ptr<Optimizer> optimizer = Optimizer::create();
bool isDdl = true;
try {
query->start();
while (queryProcessor->optimize(optimizer, query))
{
LOG4CXX_DEBUG(logger, "Query is optimized");
isDdl = query->getCurrentPhysicalPlan()->isDdl();
query->isDDL = isDdl;
LOG4CXX_DEBUG(logger, "The physical plan is detected as " << (isDdl ? "DDL" : "DML") );
if (logger->isDebugEnabled())
{
std::ostringstream planString;
query->getCurrentPhysicalPlan()->toString(planString);
LOG4CXX_DEBUG(logger, "\n" + planString.str());
}
// Execution of single part of physical plan
queryProcessor->preSingleExecute(query);
NetworkManager* networkManager = NetworkManager::getInstance();
size_t instancesCount = query->getInstancesCount();
{
std::ostringstream planString;
query->getCurrentPhysicalPlan()->toString(planString);
query->statistics.explainPhysical += planString.str() + ";";
// Serialize physical plan and sending it out
const string physicalPlan = serializePhysicalPlan(query->getCurrentPhysicalPlan());
LOG4CXX_DEBUG(logger, "Query is serialized: " << planString.str());
boost::shared_ptr<MessageDesc> preparePhysicalPlanMsg = boost::make_shared<MessageDesc>(mtPreparePhysicalPlan);
boost::shared_ptr<scidb_msg::PhysicalPlan> preparePhysicalPlanRecord =
preparePhysicalPlanMsg->getRecord<scidb_msg::PhysicalPlan>();
preparePhysicalPlanMsg->setQueryID(query->getQueryID());
preparePhysicalPlanRecord->set_physical_plan(physicalPlan);
boost::shared_ptr<const InstanceLiveness> queryLiveness(query->getCoordinatorLiveness());
serializeQueryLiveness(queryLiveness, preparePhysicalPlanRecord);
uint32_t redundancy = Config::getInstance()->getOption<int>(CONFIG_REDUNDANCY);
Cluster* cluster = Cluster::getInstance();
assert(cluster);
shared_ptr<const InstanceMembership> membership(cluster->getInstanceMembership());
assert(membership);
if ((membership->getViewId() != queryLiveness->getViewId()) ||
((instancesCount + redundancy) < membership->getInstances().size())) {
throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_NO_QUORUM2);
}
preparePhysicalPlanRecord->set_cluster_uuid(cluster->getUuid());
networkManager->sendOutMessage(preparePhysicalPlanMsg);
LOG4CXX_DEBUG(logger, "Prepare physical plan was sent out");
LOG4CXX_DEBUG(logger, "Waiting confirmation about preparing physical plan in queryID from "
<< instancesCount - 1 << " instances")
}
try {
// Execution of local part of physical plan
queryProcessor->execute(query);
}
catch (const std::bad_alloc& e) {
throw SYSTEM_EXCEPTION(SCIDB_SE_NO_MEMORY, SCIDB_LE_MEMORY_ALLOCATION_ERROR) << e.what();
}
LOG4CXX_DEBUG(logger, "Query is executed locally");
// Wait for results from every instance except itself
Semaphore::ErrorChecker ec = bind(&Query::validate, query);
query->results.enter(instancesCount-1, ec);
LOG4CXX_DEBUG(logger, "The responses are received");
/**
* Check error state
*/
query->validate();
queryProcessor->postSingleExecute(query);
}
query->done();
} catch (const Exception& e) {
query->done(e.copy());
e.raise();
}
//.........这里部分代码省略.........