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


C++ OperationContext类代码示例

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


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

示例1: lookupNameFromID

int DictionaryDatabase::lookupNameFromID(OperationContext &context,
					 const NameID &id, Name &name) const
{
	int err = 0;
	nameId_t raw = id.raw() - 1; // id space is 1-based, not 0
	if (id == nidName_) {
		name = Name::dbxml_colon_name;
		return 0;
	} else if (id == nidRoot_) {
		name = Name::dbxml_colon_root;
		return 0;
	}
	
	if ((raw < DICTIONARY_RESERVE_SIZE) && usePreloads_) {
		name = preloadNames[raw];
	} else {
		err = lookupFromID(context, context.data(), id);
		if (err == 0) {
			name.setThisFromDbt(context.data());
		} else {
			name.reset();
		}
	}
	return err;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:25,代码来源:DictionaryDatabase.cpp

示例2: display

void StructuralStatsDatabase::display(OperationContext &context, ostream &out, const DictionaryDatabase *ddb) const
{
	Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_WRITE, 0);
	if(myCursor.error() != 0) throw XmlException(myCursor.error());

	NameID id1;
	NameID id2;
	StructuralStats stats;

	int err = 0;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		id1.reset();
		id2.reset();
		unmarshalKey(context.key(), id1, id2);
		stats.reset();
		stats.unmarshal(context.data());

		if(ddb) out << ddb->lookupName(context, id1);
		else out << id1;

		if(id2 != 0) {
			if(ddb) out << " -> " << ddb->lookupName(context, id2);
			else out << " -> " << id2;
		}

		out << ": ";

		stats.display(out);

		out << endl;
	}
}
开发者ID:kanbang,项目名称:Colt,代码行数:32,代码来源:StructuralStatsDatabase.cpp

示例3: getResponseContext

OperationContext ClientCIMOMHandleRep::getResponseContext()
{
    OperationContext ctx;

    Thread* curThrd = Thread::getCurrent();
    if (curThrd == NULL)
    {
        ctx.insert(ContentLanguageListContainer(ContentLanguageList()));
    }
    else
    {
        ContentLanguageList* contentLangs = (ContentLanguageList*)
            curThrd->reference_tsd(TSD_CIMOM_HANDLE_CONTENT_LANGUAGES);
        curThrd->dereference_tsd();

        if (contentLangs == NULL)
        {
            ctx.insert(ContentLanguageListContainer(ContentLanguageList()));
        }
        else
        {
            ctx.insert(ContentLanguageListContainer(*contentLangs));
            // delete the old tsd to free the memory
            curThrd->delete_tsd(TSD_CIMOM_HANDLE_CONTENT_LANGUAGES);
        }
    }

    return ctx;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:29,代码来源:ClientCIMOMHandleRep.cpp

示例4: killSessionsLocalKillOps

SessionKiller::Result killSessionsLocalKillOps(OperationContext* opCtx,
                                               const SessionKiller::Matcher& matcher) {
    for (ServiceContext::LockedClientsCursor cursor(opCtx->getClient()->getServiceContext());
         Client* client = cursor.next();) {
        invariant(client);
        stdx::unique_lock<Client> lk(*client);

        OperationContext* opCtxToKill = client->getOperationContext();
        if (opCtxToKill) {
            const auto& lsid = opCtxToKill->getLogicalSessionId();

            if (lsid) {
                if (const KillAllSessionsByPattern* pattern = matcher.match(*lsid)) {
                    ScopedKillAllSessionsByPatternImpersonator impersonator(opCtx, *pattern);

                    log() << "killing op: " << opCtxToKill->getOpID()
                          << " as part of killing session: " << lsid->toBSON();

                    opCtx->getServiceContext()->killOperation(opCtxToKill);
                }
            }
        }
    }

    return {std::vector<HostAndPort>{}};
}
开发者ID:DINKIN,项目名称:mongo,代码行数:26,代码来源:kill_sessions_common.cpp

示例5: getMetaData

int DocumentDatabase::getMetaData(OperationContext &context,
	DictionaryDatabase *dictionary, const Name &name,
	const DocID &did, XmlValue::Type &type, DbXmlDbt *metadata,
	u_int32_t flags) const
{
	NameID nid;
	int err = dictionary->lookupIDFromName(context, name,
					       nid, /*define=*/false);
	if(err == 0) {
		Cursor cursor(const_cast<SecondaryDatabase&>(secondary_),
			context.txn(), CURSOR_READ, "DocumentMetaData", flags);
		u_int32_t origFlags = DB_CURSOR_GET_MASK(const_cast<SecondaryDatabase&>(secondary_),flags);
		MetaDatum::setKeyDbt(did, nid, XmlValue::NONE, context.key());
		DbtIn none;
		none.set_flags(DB_DBT_PARTIAL); // Don't pull back the data.
		err = cursor.get(context.key(), none,
				 (flags | DB_SET_RANGE) & ~DB_RMW);
		if (err == 0) {
			DocID db_did;
			NameID db_nid;
			MetaDatum::decodeKeyDbt(context.key(), db_did,
						db_nid, type);
			if(db_did == did && db_nid == nid) {
				err = cursor.get(context.key(), *metadata,
						 origFlags|DB_CURRENT);
			} else {
				return DB_NOTFOUND;
			}
		}
	}

	return err;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:33,代码来源:DocumentDatabase.cpp

示例6: getStats

int StructuralStatsDatabase::getStats(OperationContext &context, StructuralStats &stats) const
{
	Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_READ, 0);
	if(myCursor.error() != 0) return myCursor.error();

	StructuralStats current;

	// Loop over every node and every node's descendant information
	int err;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		current.reset();
		current.unmarshal(context.data());
		stats.add(current);
	}

	if(err != DB_NOTFOUND && err != 0) return err;

	if(stats.sumSize_ == 0 && stats.numberOfNodes_ != 0) {
		// Fill in an estimate for the missing size values that you get with DLS
		stats.sumSize_ = NODE_SIZE * stats.numberOfNodes_;
		stats.sumChildSize_ = NODE_SIZE * stats.sumNumberOfChildren_;
		stats.sumDescendantSize_ = NODE_SIZE * stats.sumNumberOfDescendants_;
	}

	return 0;
}
开发者ID:kanbang,项目名称:Colt,代码行数:26,代码来源:StructuralStatsDatabase.cpp

示例7: display

void DictionaryDatabase::display(OperationContext &context, ostream &out) const
{
	{
	Cursor myCursor(const_cast<PrimaryDatabase&>(*primary_.get()), getTxn(context), CURSOR_READ, 0);
	if(myCursor.error() != 0) throw XmlException(myCursor.error());

	int err = 0;
	NameID id;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		id.setThisFromDbtAsId(context.key());
		Buffer val(context.data().data, context.data().size, true);
		out << id << " -> " << val.asString(true) << endl;
	}
	}
	{
	Cursor myCursor(const_cast<SecondaryDatabase&>(*secondary_.get()), getTxn(context), CURSOR_READ, 0);
	if(myCursor.error() != 0) throw XmlException(myCursor.error());

	int err = 0;
	NameID id;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		Buffer val(context.key().data, context.key().size, true);
		id.setThisFromDbt(context.data());
		out << val.asString(true) << " -> " << id << endl;
	}
	}
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:27,代码来源:DictionaryDatabase.cpp

示例8: subtractStats

int StructuralStatsDatabase::subtractStats(OperationContext &context, const NameID &id1, const NameID &id2,
	const StructuralStats &stats)
{
	DBXML_ASSERT(id1 != 0 || id2 == 0);

	Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_WRITE, 0);
	if(myCursor.error() != 0) return myCursor.error();

	marshalKey(id1, id2, context.key());
	int err = myCursor.get(context.key(), context.data(), DB_SET);
	if(err != DB_NOTFOUND && err != 0) return err;

	StructuralStats current;

	if(err == DB_NOTFOUND) {
		current.subtract(stats);

		current.marshal(context.data(), id2 == 0);
		err = myCursor.put(context.key(), context.data(), DB_KEYLAST);
	} else {
		current.unmarshal(context.data());
		current.subtract(stats);

		current.marshal(context.data(), id2 == 0);
		err = myCursor.put(context.key(), context.data(), DB_CURRENT);
	}

	return err;
}
开发者ID:kanbang,项目名称:Colt,代码行数:29,代码来源:StructuralStatsDatabase.cpp

示例9: addMetaData

int DocumentDatabase::addMetaData(OperationContext &oc,
				  DictionaryDatabase *dictionary,
				  Document &document)
{
	int err = 0;
	MetaData::const_iterator end = document.metaDataEnd();
	MetaData::const_iterator i;
	for (i = document.metaDataBegin(); err == 0 && i != end; ++i) {
		NameID nid;
		err = dictionary->lookupIDFromName(oc,
						   (*i)->getName(),
						   nid, /*define=*/true);
		if(err == 0) {
			DbtIn value;
			MetaDatum::setKeyDbt(document.getID(),
					     nid, (*i)->getType(),
					     oc.key());
			(*i)->setValueDbtFromThis(value);
			// could throw on error
			err = secondary_.put(oc.txn(), &oc.key(),
					     &value, 0);
		}
	}
	if(err == 0)
		for(i = document.metaDataBegin(); i != end; ++i)
			(*i)->setModified(false);
	return err;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:28,代码来源:DocumentDatabase.cpp

示例10: removeIndexEntries

int SyntaxDatabase::removeIndexEntries(OperationContext &context, DbWrapper &db,
				       void *buf, u_int32_t bufsize)
{
	unsigned char keybuf[10];
	// assert bufsize < 10;
	memcpy(keybuf, buf, bufsize);
	DbtIn key(keybuf, bufsize);
	key.ulen = (bufsize);
	key.dlen = (bufsize);
	key.doff = (0);
	key.set_flags(DB_DBT_PARTIAL);
	DbtIn data(0,0);
	data.set_flags(DB_DBT_PARTIAL);
	data.dlen = (0);
		
	u_int32_t flags = (context.txn() ? DB_RMW : 0);
	int err;

	// remove from index database
	Cursor cursor(db, context.txn(), CURSOR_WRITE);
	err = cursor.get(key, data, flags|DB_SET_RANGE);
	while ((err == 0) && (memcmp(key.data, buf, bufsize) == 0)) {
		cursor.del(0);
		err = cursor.get(key, data, flags|DB_NEXT);
		if (err == DB_NOTFOUND)
			break;
	}
	if (err == DB_NOTFOUND)
		err = 0;
	return err;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:31,代码来源:SyntaxDatabase.cpp

示例11: invariant

    bool PlanYieldPolicy::yield(RecordFetcher* fetcher) {
        invariant(_planYielding);

        OperationContext* opCtx = _planYielding->getOpCtx();
        invariant(opCtx);

        // All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers that it's
        // time to yield. Whether or not we will actually yield (doc-level locking systems won't),
        // we need to check if this operation has been interrupted. Throws if the interrupt flag is
        // set.
        opCtx->checkForInterrupt();

        if (supportsDocLocking()) {
            // Doc-level locking is supported, so no need to release locks.
            return true;
        }

        // No need to yield if the collection is NULL.
        if (NULL == _planYielding->collection()) {
            return true;
        }

        _planYielding->saveState();

        // Release and reacquire locks.
        QueryYield::yieldAllLocks(opCtx, fetcher);

        _elapsedTracker.resetLastTime();

        return _planYielding->restoreState(opCtx);
    }
开发者ID:JsonRuby,项目名称:mongo,代码行数:31,代码来源:plan_yield_policy.cpp

示例12: addStats

int StructuralStatsDatabase::addStats(OperationContext &context, const StructuralStatsWriteCache &cache)
{
	Cursor myCursor(db_, getTxn(context), CURSOR_WRITE, 0);
	if(myCursor.error() != 0) return myCursor.error();

	int err = 0;
	StructuralStats current;

	StructuralStatsWriteCache::Map::const_iterator it = cache.cache_.begin();
	for(; err == 0 && it != cache.cache_.end(); ++it) {

		StructuralStatsWriteCache::InnerMap::const_iterator it2 = it->second.begin();
		for(; it2 != it->second.end(); ++it2) {

			marshalKey(it->first, it2->first, context.key());

			err = myCursor.get(context.key(), context.data(), DB_SET);
			if(err == DB_NOTFOUND) {
				it2->second.marshal(context.data(), it2->first == 0);
				err = myCursor.put(context.key(), context.data(), DB_KEYLAST);
			} else if(err == 0) {
				current.unmarshal(context.data());
				current.add(it2->second);
				current.marshal(context.data(), it2->first == 0);
				err = myCursor.put(context.key(), context.data(), DB_CURRENT);
			} else break;
		}
	}

	if(err != DB_NOTFOUND) return err;

	return 0;
}
开发者ID:kanbang,项目名称:Colt,代码行数:33,代码来源:StructuralStatsDatabase.cpp

示例13: reindex

int DocumentDatabase::reindex(const Document &document, OperationContext &oc,
		bool updateStats, bool forDelete)
{
        XmlManager mgr = document.getManager();
        ScopedContainer sc(mgr, document.getContainerID(), true);
        Container *cont = sc.getContainer();
        UpdateContext uc(mgr);
        Indexer &indexer = uc.getIndexer();
        IndexSpecification is;
        cont->getIndexSpecification(oc.txn(), is);
        indexer.resetContext(cont, &oc);
        KeyStash &ks = uc.getKeyStash();
        ks.reset();
        if (forDelete) is.set(Index::INDEXER_DELETE);
        // Index the document
	indexer.indexMetaData(is, document, ks, /*checkModified*/false);
	ScopedPtr<NsPushEventSource> source(document.
		getContentAsEventSource(oc.txn(), /*needsValidation*/false,
					indexer.getContainer()->nodesIndexed()));
	if (source.get()) {
		indexer.initIndexContent(is, document.getID(), source.get(),
			ks, updateStats, false, /*isDelete*/forDelete);
		source.get()->start();
	}
        ks.updateIndex(oc, cont);
        return 0;
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:27,代码来源:DocumentDatabase.cpp

示例14: lk

void MobileSessionPool::shutDown() {
    stdx::unique_lock<stdx::mutex> lk(_mutex);
    _shuttingDown = true;

    // Retrieve the operation context from the thread's client if the client exists.
    if (haveClient()) {
        OperationContext* opCtx = cc().getOperationContext();

        // Locks if the operation context still exists.
        if (opCtx) {
            opCtx->waitForConditionOrInterrupt(
                _releasedSessionNotifier, lk, [&] { return _sessions.size() == _curPoolSize; });
        }
    } else {
        _releasedSessionNotifier.wait(lk, [&] { return _sessions.size() == _curPoolSize; });
    }

    // Retry all the drops that have been queued on failure.
    // Create a new sqlite session to do so, all other sessions might have been closed already.
    if (!failedDropsQueue.isEmpty()) {
        sqlite3* session;

        int status = sqlite3_open(_path.c_str(), &session);
        embedded::checkStatus(status, SQLITE_OK, "sqlite3_open");
        std::unique_ptr<MobileSession> mobSession = stdx::make_unique<MobileSession>(session, this);
        LOG(MOBILE_LOG_LEVEL_LOW) << "MobileSE: Executing queued drops at shutdown";
        failedDropsQueue.execAndDequeueAllOps(mobSession.get());
        sqlite3_close(session);
    }

    for (auto&& session : _sessions) {
        sqlite3_close(session);
    }
}
开发者ID:acmorrow,项目名称:mongo,代码行数:34,代码来源:mobile_session_pool.cpp

示例15: testStringData

void OperationContextTestCases::testStringData()
{
	OperationContext context;
	context.setStringData("key", "value");
	String val;
	unitAssertNoThrow(val = context.getStringData("key"));
	unitAssert(val == "value");
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:8,代码来源:OperationContextTestCases.cpp


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