Esempio n. 1
0
void LocalNodeInfo::addAddFiltersToConsolidateList (const char *pszGroupName)
{
    _m.lock (328);
    // Get all the client subscribing the group
    DArray<uint16> *pSubClients = NULL;//getSubscribingClients (pszGroupName);
    Subscription *pSCons = _consolidatedSubscriptions.getSubscription (pszGroupName);
    if ((pSubClients == NULL) ||  (!((pSCons != NULL) && (pSCons->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION)))) {
        _m.unlock (328);
        return;
    }
    GroupSubscription *pGSCons = (GroupSubscription *) pSCons;

    // Look for the first subscribing client which subscribes by a GROUP_SUBSCRIPTION
    uint16 ui16ClientId;
    Subscription *pS = NULL;
    for (int i = 0; i <= pSubClients->getHighestIndex(); i++) {
        ui16ClientId = (*pSubClients)[i];
        SubscriptionList *pSL = NULL;
        if (((pSL = _localSubscriptions.get(ui16ClientId)) != NULL) && ((pS = pSL->getSubscription(pszGroupName)) != NULL)) {
            if (pS->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION) {
                break;
            }
            if (pS->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
                // I want every tag - remove them and return
                pGSCons->removeAllFilters();
                _m.unlock (328);
                return;
            }
        }
    }

    // match every filter against every other subscribing client's tag list.
    // Add it iff:
    // 1) Every other GROUP_SUBSCRIPTION has the same filter
    // 2) No one of the other GROUP_TAG_SUBSCRIPTION subscribe the tag
    // 3) There is not any GROUP_PREDICATE_SUBSCRIPTION for the group
    GroupSubscription *pGS = (GroupSubscription*) pS;
    DArray<uint16> *pTags = pGS->getAllFilters();

    for (int i = 0; i <= pTags->getHighestIndex(); i++) {
        bool bAddFilter = true;
        int16 ui16Tag = (*pTags)[i];
        for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
            Subscription *pS = NULL;
            if (pS->matches(ui16Tag)) {
                bAddFilter = false;
                break;
            }
        }
        if (bAddFilter) {
            pGSCons->addFilter((*pTags)[i]);
        }
    }
    _m.unlock (328);
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
bool RemoteNodeInfo::isNodeInterested (DisServiceDataMsg *pDSDMsg)
{
    // Returns true if the node is interested in pDSDMsg
    bool bFound = false;
    const char * pszMsgGroupName = pDSDMsg->getMessageHeader()->getGroupName();
    if (_pRemoteSubscriptions) {
        for (StringHashtable<Subscription>::Iterator i = _pRemoteSubscriptions->getIterator(); !i.end(); i.nextElement()) {
            const char *pszSubGroupName = i.getKey();
            if (0 == stricmp (pszSubGroupName, pszMsgGroupName)) {
                Subscription *pSub = i.getValue();
                if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pDSDMsg->getMessage())) {
                    bFound = true;
                }
            }
        }
    }
    return bFound;
}