Ejemplo 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);
}
Ejemplo n.º 2
0
bool GroupSubscription::merge (Subscription *pSubscription)
{
    bool bRet = false;
    switch (pSubscription->getSubscriptionType()) {
        case GROUP_SUBSCRIPTION:
        {
            GroupSubscription *pGS = (GroupSubscription *) pSubscription;
            DArray<uint16> *pFiltersInSubscription = pGS->getAllFilters();
            if (pFiltersInSubscription != NULL) {
                for (unsigned int i = 0; i < pFiltersInSubscription->size(); i++) {
                    uint16 ui16 = (*pFiltersInSubscription)[i];
                    if (_ui32HashFilteredTags.contains (ui16)) {
                        pGS->removeFilter (ui16);
                        bRet = true;
                    }
                }
            }
            if (getPriority() > pGS->getPriority()) {
                pGS->setPriority (getPriority());
                bRet = true;
            }
            if (isGroupReliable() > pGS->isGroupReliable()) {
                pGS->setGroupReliable (isGroupReliable());
                bRet = true;
            }
            if (isMsgReliable() > pGS->isMsgReliable()) {
                pGS->setMsgReliable (isMsgReliable());
                bRet = true;
            }
            if (isSequenced() > pGS->isSequenced()) {
                pGS->setSequenced (isSequenced());
                bRet = true;
            }
            break;
        }
        case GROUP_PREDICATE_SUBSCRIPTION:
        {
            //TODO
            break;
        }
        case GROUP_TAG_SUBSCRIPTION:
        {
            //TODO
            break;
        }
    }
    return bRet;
}