本文整理汇总了C++中PtrLList::getFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ PtrLList::getFirst方法的具体用法?C++ PtrLList::getFirst怎么用?C++ PtrLList::getFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PtrLList
的用法示例。
在下文中一共展示了PtrLList::getFirst方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printAllSubscribedGroups
void LocalNodeInfo::printAllSubscribedGroups (void)
{
PtrLList<String> *pGroupNames = getAllSubscribedGroups();
if (pGroupNames && pGroupNames->getFirst()) {
for (String *pGroupName = pGroupNames->getFirst(); pGroupName; pGroupName = pGroupNames->getNext()) {
checkAndLogMsg ("LocalNodeInfo::printAllSubscribedGroups", Logger::L_Info, " Subscribed group: %s\n", pGroupName->c_str());
}
}
}
示例2: newIncomingMessage
void AckController::newIncomingMessage (const void *, uint16, DisServiceMsg *pDisServiceMsg, uint32, const char *)
{
switch (pDisServiceMsg->getType()) {
case DisServiceMsg::DSMT_DataReq: {
DisServiceDataReqMsg *pReqMsg = (DisServiceDataReqMsg*) pDisServiceMsg;
PtrLList<DisServiceDataReqMsg::FragmentRequest> *pRequests = pReqMsg->getRequests();
DisServiceDataReqMsg::FragmentRequest *pRequest;
DisServiceDataReqMsg::FragmentRequest *pRequestTmp = pRequests->getFirst();
// Call messageRequested() for each requested message
while ((pRequest = pRequestTmp) != NULL) {
pRequestTmp = pRequests->getNext();
messageRequested (pRequest->pMsgHeader->getMsgId(),
pDisServiceMsg->getSenderNodeId());
}
break;
}
case DisServiceMsg::DSMT_AcknowledgmentMessage: {
DisServiceAcknowledgmentMessage *pAckMsg = (DisServiceAcknowledgmentMessage*) pDisServiceMsg;
messageAcknowledged (pAckMsg->getAckedMsgId(), pDisServiceMsg->getSenderNodeId());
break;
}
default:
break;
}
}
示例3:
DArray<uint16> * LocalNodeInfo::getSubscribingClients (Message *pMsg)
{
DArray<uint16> *pSubscribingClients = NULL;
uint16 j = 0;
_m.lock (314);
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
PtrLList<Subscription> *pSubscriptions = i.getValue()->getSubscriptionWild (pMsg->getMessageHeader()->getGroupName());
// Get every subscribed group that matches with the message's group
if (pSubscriptions != NULL) {
for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pMsg)) {
if (pSubscribingClients == NULL) {
pSubscribingClients = new DArray<uint16>();
}
bool bFound = false;
for (unsigned int k = 0; k < pSubscribingClients->size(); k++) {
if ((*pSubscribingClients)[k] == i.getKey()) {
bFound = true;
break;
}
}
if (!bFound) {
(*pSubscribingClients)[j] = i.getKey();
j++;
}
}
}
delete pSubscriptions;
pSubscriptions = NULL;
}
}
_m.unlock (314);
return pSubscribingClients;
}
示例4: getInterestedRemoteNodes
PtrLList<String> * TopologyWorldState::getTargetNodes (DisServiceDataMsg *pDSDMsg)
{
// Returns a list with the target nodes for pDSDMsg
_m.lock (145);
PtrLList<String> *pInterestedNodes = getInterestedRemoteNodes (pDSDMsg);
PtrLList<String> *pTargetNodes = NULL;
if (pInterestedNodes) {
for (String *pSubNode = pInterestedNodes->getFirst(); pSubNode; pSubNode = pInterestedNodes->getNext()) {
bool bActiveTarget = isActiveNeighbor (pSubNode->c_str());
const char *pszBestGW = NULL;
if (bActiveTarget) {
pszBestGW = pSubNode->c_str();
} else {
pszBestGW = getBestGateway (pSubNode->c_str());
}
if (pszBestGW) {
if (pTargetNodes == NULL) {
pTargetNodes = new PtrLList<String>();
}
if (pTargetNodes->search (new String (pszBestGW)) == NULL) {
pTargetNodes->insert (new String (pszBestGW));
}
}
}
}
_m.unlock (145);
return pTargetNodes;
}
示例5: recomputeConsolidateSubsciptionList
void LocalNodeInfo::recomputeConsolidateSubsciptionList (void)
{
// TODO CHECK: I don't think the includes applies anymore, so I commented it
// In fact, even if the includes returns true,
// I still need to merge subscriptions in terms of priority, reliability, sequenced, etc
CRC * pCRC = new CRC();
pCRC->init();
for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
pCRC->update ((const char *)iterator.getKey());
pCRC->update32 (iterator.getValue());
}
uint16 oldCRC = pCRC->getChecksum();
// Delete the current Consolidate Subscription List and compute a new one
_consolidatedSubscriptions.clear();
// For each client
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
SubscriptionList *pSL = i.getValue();
if (pSL != NULL) {
// Get all its subscriptions
PtrLList<String> *pSubgroups = pSL->getAllSubscribedGroups();
for (String *pSubGroupName = pSubgroups->getFirst(); pSubGroupName != NULL; pSubGroupName = pSubgroups->getNext()) {
// For each group, get the subscription the client has
const char *pszGroupName = pSubGroupName->c_str();
Subscription *pClientSub = pSL->getSubscription (pszGroupName);
// And the subscription in the consolidate subscription list if any
Subscription *pSubInConsolidateList = _consolidatedSubscriptions.getSubscription (pszGroupName);
if (pSubInConsolidateList == NULL) {
_consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
}
else {
/*if (pClientSub->includes (pSubInConsolidateList)) {
_consolidatedSubscriptions.removeGroup (pszGroupName);
_consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
}
else {*/
pClientSub->merge (pSubInConsolidateList);
/*}*/
}
}
}
}
pCRC->reset();
for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
pCRC->update ((const char *) iterator.getKey());
pCRC->update32 (iterator.getValue());
}
uint16 newCRC = pCRC->getChecksum();
if (oldCRC != newCRC) {
ui32SubscriptionStateSeqID++;
GroupSubscription *pSubscription = new GroupSubscription(); // Void subscription to respect method interface
_notifier.modifiedSubscriptionForPeer (_pszId, pSubscription);
}
}
示例6: sendWaypointMessage
void DSProImpl::sendWaypointMessage (const void *pBuf, uint32 ui32BufLen)
{
if (pBuf == NULL || ui32BufLen == 0) {
return;
}
PtrLList<String> *pNeighborList = _pTopology->getNeighbors();
if (pNeighborList == NULL) {
return;
}
if (pNeighborList->getFirst () == NULL) {
delete pNeighborList;
return;
}
NodeIdSet nodeIdSet;
PreviousMessageIds previousMessageIds;
String *pszNextPeerId = pNeighborList->getFirst ();
for (String *pszCurrPeerId; (pszCurrPeerId = pszNextPeerId) != NULL;) {
pszNextPeerId = pNeighborList->getNext ();
previousMessageIds.add (pszCurrPeerId->c_str (), _pScheduler->getLatestMessageReplicatedToPeer (pszCurrPeerId->c_str ()));
nodeIdSet.add (pszCurrPeerId->c_str ());
delete pNeighborList->remove (pszCurrPeerId);
}
delete pNeighborList;
uint32 ui32TotalLen = 0;
void *pData = WaypointMessageHelper::writeWaypointMessageForTarget (previousMessageIds, pBuf, ui32BufLen, ui32TotalLen);
Targets **ppTargets = _pTopology->getNextHopsAsTarget (nodeIdSet);
if ((ppTargets != NULL) && (ppTargets[0] != NULL)) {
// Send the waypoint message on each available interface that reaches the recipients
int rc = _adaptMgr.sendWaypointMessage (pData, ui32TotalLen, _nodeId, ppTargets);
String sLatestMsgs (previousMessageIds);
String sPeers (nodeIdSet);
checkAndLogMsg ("DSPro::sendWaypointMessage", Logger::L_Info, "sending waypoint message "
"to %s (%s); last message pushed to this node was %s.\n", sPeers.c_str (),
(rc == 0 ? "succeeded" : "failed"), sLatestMsgs.c_str ());
}
Targets::deallocateTargets (ppTargets);
free (pData);
}
示例7: requireSequentiality
bool LocalNodeInfo::requireSequentiality (const char *pszGroupName, uint16 ui16Tag)
{
_m.lock (321);
PtrLList<Subscription> *pSubscriptions = _consolidatedSubscriptions.getSubscriptionWild(pszGroupName);
if (pSubscriptions != NULL) {
for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
if (pSub->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION) {
GroupSubscription *pGS = (GroupSubscription *) pSub;
if (pGS->isSequenced()) {
delete pSubscriptions;
pSubscriptions = NULL;
_m.unlock (321);
return true;
}
}
else if (pSub->getSubscriptionType() == Subscription::GROUP_TAG_SUBSCRIPTION) {
GroupTagSubscription *pGTS = (GroupTagSubscription *) pSub;
if (pGTS->isSequenced(ui16Tag)) {
delete pSubscriptions;
pSubscriptions = NULL;
_m.unlock (321);
return true;
}
}
else if (pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
GroupPredicateSubscription *pGPS = (GroupPredicateSubscription *) pSub;
if (pGPS->isSequenced()) {
delete pSubscriptions;
pSubscriptions = NULL;
_m.unlock (321);
return true;
}
}
}
delete pSubscriptions;
pSubscriptions = NULL;
}
_m.unlock (321);
return false;
}
示例8: doSQLQueryOnMetadata
int DSProQueryController::doSQLQueryOnMetadata (const char *pszGroupName, const void *pQuery, unsigned int uiQueryLen,
const char *, InformationStore *pInfoStore,
PtrLList<const char> *pResultsList)
{
const char *pszMethodName = "DSProQueryController::doSQLQueryOnMetadata";
String query ((char *) pQuery, uiQueryLen);
/*const char *pszSqlConstraints = nullptr;
char *pszTemp = nullptr;
char *pszToken = nullptr;
pszToken = strtok_mt (query.c_str(), "WHERE ", &pszTemp);
if (pszToken == nullptr) {
checkAndLogMsg (pszMethodName, Logger::L_Warning, "Error in parsing the char * containing the sql query\n");
return -1;
}
pszSqlConstraints = strtok_mt (nullptr, "WHERE ", &pszTemp);
if (pszSqlConstraints == nullptr) {
checkAndLogMsg (pszMethodName, Logger::L_Warning, "No where conditions\n");
return -2;
}*/
PtrLList<const char> *ptmp = pInfoStore->getMessageIDs (pszGroupName, query);
if (ptmp == nullptr) {
checkAndLogMsg (pszMethodName, Logger::L_Warning, "Error in retrieving the messageIds\n");
return -3;
}
if (pResultsList != nullptr) {
const char *pszId = ptmp->getFirst();
for (; pszId != nullptr; pszId = ptmp->getNext()) {
pResultsList->prepend (pszId);
}
ptmp->removeAll (false);
delete ptmp;
}
return 0;
}
示例9: rsrm
/*
send ReplicationStartReqMsg
if send error delete self
wait for ReplicationStartReplyMsg as follows
loop until reply is received
on receive error or peerNode dies, delete self
get filtered list of messages to replicate
for all messages to send, loop
if clear to send
send next message
if send error, delete self
else wait for clear to send (watch out for deadPeer?)
all done delete self
note: deleting self signals thread's parent to terminate this thread
go through the list of successfully send and ack'd?
and possibly queue up another session?
*/
void TargetBasedReplicationController::ReplicationSessionThread::run (void)
{
int rc;
const char *pszMethod = "TargetBasedReplicationController::ReplicationSessionThread::run";
// First - send the ReplicationStartReqMsg
ReplicationStartReqMsg rsrm (_localNodeID, _targetNodeID, TargetBasedReplicationController::CONTROLLER_TYPE, TargetBasedReplicationController::CONTROLLER_VERSION, _bCheckTargetForMsgs, _bRequireAcks);
if (_pTBRepCtlr->transmitCtrlToCtrlMessage (&rsrm, "TargetBasedReplicationController: sending ReplicationStartReqMsg") != 0) {
checkAndLogMsg (pszMethod, Logger::L_MildError,
"transmission of ReplicationStartReqMsg failed - terminating replication session\n");
_pTBRepCtlr->addTerminatingReplicator (this);
setTerminatingResultCode (-1);
terminating();
return;
}
else {
checkAndLogMsg (pszMethod, Logger::L_Info,
"transmitted ReplicationStartReqMsg to target node %s\n",
(const char*) _targetNodeID);
}
// Wait for the ReplicationStartReplyMsg
_m.lock();
while (!_bReplicating) {
if (terminationRequested()) {
_pTBRepCtlr->addTerminatingReplicator (this);
setTerminatingResultCode (-2);
terminating();
_m.unlock();
return;
}
else if (_bTargetDead) {
checkAndLogMsg (pszMethod, Logger::L_Warning,
"target node %s died while waiting for the ReplicationStartReplyMsg\n",
(const char*) _targetNodeID);
_pTBRepCtlr->addTerminatingReplicator (this);
setTerminatingResultCode (-3);
terminating();
_m.unlock();
return;
}
_cv.wait (1000);
}
_m.unlock();
// Ready to replicate messages at this point
if ((_pMsgsToExclude != NULL) && (_pMsgsToExclude->getCount() > 0)) {
checkAndLogMsg (pszMethod, Logger::L_Info,
"adding constraint to exclude messages previously received by node %s\n", (const char*) _targetNodeID);
}
int64 i64QueryStartTime = getTimeInMilliseconds();
PtrLList<MessageId> *pMsgIds = _pTBRepCtlr->_pDataCacheInterface->getNotReplicatedMsgList (_targetNodeID, 0, _pMsgsToExclude);
if (pMsgIds != NULL) {
checkAndLogMsg (pszMethod, Logger::L_Info,
"identified %lu messages to replicate to node %s - query time %lu ms\n",
(uint32) pMsgIds->getCount(), (const char*) _targetNodeID, (uint32) (getTimeInMilliseconds() - i64QueryStartTime));
for (MessageId *pMIdTemp = pMsgIds->getFirst(); pMIdTemp; pMIdTemp = pMsgIds->getNext()) {
// Check for termination
if (terminationRequested()) {
setTerminatingResultCode (-4);
break;
}
// Check Flow Control and target peer death
int64 i64PauseStartTime = 0;
while ((!_bTargetDead) && (!_pTBRepCtlr->clearToSendOnAllInterfaces())) {
if (i64PauseStartTime == 0) {
i64PauseStartTime = getTimeInMilliseconds();
}
sleepForMilliseconds (100);
}
if (_bTargetDead) {
checkAndLogMsg (pszMethod, Logger::L_Warning,
"target %s died while replicating messages\n",
(const char*) _targetNodeID);
setTerminatingResultCode (-5);
break;
}
if (i64PauseStartTime != 0) {
//.........这里部分代码省略.........