Ejemplo n.º 1
0
bool DiscreteHistory::isInHistory (Message *pMsg, uint32)
{
    MessageInfo *pMI = pMsg->getMessageInfo();
    uint32 ui32 = pMI->getMsgSeqId();
    if (SequentialArithmetic::greaterThanOrEqual (ui32, _ui32From) &&
        SequentialArithmetic::lessThanOrEqual(ui32, _ui32To)) {
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
void PositionUpdater::doMetadataArrived (StringHashtable<MsgIdList > *pMsgToNotifyByQueryId)
{
    if (pMsgToNotifyByQueryId == nullptr) {
        return;
    }
    const char *pszMethodName = "PositionUpdater::doMetadataArrived";

    String msgId;
    StringHashtable<LList<String> >::Iterator iter = pMsgToNotifyByQueryId->getAllElements();
    for (; !iter.end(); iter.nextElement()) {
        const char *pszQueryId = iter.getKey();
        LList<String> *pMsgToNotify = iter.getValue();

        for (int rc = pMsgToNotify->getFirst (msgId); rc == 1; rc = pMsgToNotify->getNext (msgId)) {

            MessageHeaders::MsgType type;
            Message *pMessage = getCompleteMessageAndRemoveDSProMetadata (_pDSPro->_pDataStore, msgId.c_str(), type);
            if (pMessage == nullptr || (type != MessageHeaders::Data && type != MessageHeaders::Metadata)) {
                // The message to be notified to the application was not found at
                // this time. Re-add it to the list of messages to notify so it can
                // be tried again later.
                static const char * messageIds[2];
                messageIds[0] = msgId.c_str();
                messageIds[1] = nullptr;
                addMetadataToNotify (pszQueryId, messageIds);
            }
            else {
                MessageInfo *pMI = pMessage->getMessageInfo();
                char *pszId = convertFieldToKey (pMI->getGroupName(), pMI->getPublisherNodeId(), pMI->getMsgSeqId());
                const String currMsgId (pszId);
                if (pszId == nullptr) {
                    checkAndLogMsg (pszMethodName, memoryExhausted);
                }
                else {
                    free (pszId);
                    pszId = nullptr;
                }
                String sGrpName (MessageIdGenerator::extractSubgroupFromMsgGroup (pMI->getGroupName()));
                if (sGrpName.length() <= 0) {
                    checkAndLogMsg (pszMethodName, Logger::L_MildError, "could not extract group message id\n");
                    sGrpName = pMI->getGroupName();
                }

                if (type == MessageHeaders::Metadata) {
                    MetaData *pMetadata = toMetadata (pMessage->getData(), pMI->getTotalMessageLength());
                    if (pMetadata != nullptr) {
                        String sReferredObjectId, sReferredInstanceId, sRefersTo;
                        getReferredObjectAndInstanceIds (pMetadata, sReferredObjectId, sReferredInstanceId, sRefersTo);
                        int rc = _pDSPro->metadataArrived (currMsgId, sGrpName, sReferredObjectId,
                                                           sReferredInstanceId, pMetadata, sRefersTo,
                                                           pszQueryId);
                        checkAndLogMsg (pszMethodName, Logger::L_Info, "notified clients "
                                        "with message %s matching query request %s\n/",
                                        currMsgId.c_str(), pszQueryId);
                        delete pMetadata;
                        pMetadata = nullptr;
                        if (rc != 0) {
                            checkAndLogMsg (pszMethodName, Logger::L_Warning, "Can not notify message "
                                            "with id = <%s> failed. Returned %d\n", currMsgId.c_str(), rc);
                        }
                        else {
                            checkAndLogMsg (pszMethodName, Logger::L_Info, "client applications "
                                            "notified message with id: <%s>.\n", currMsgId.c_str());
                        }
                    }
                }
                else {
                    // Data or chunked data
                    uint8 ui8ChunkIndex = pMI->getTotalNumberOfChunks() == 0 ? (uint8) 0 : 1; // HACK: For the general case I need to figure out the current number of chunks from the database
                    rc = _pDSPro->dataArrived (currMsgId, sGrpName, pMI->getObjectId(), pMI->getInstanceId(),
                                               pMI->getAnnotates(), pMI->getMimeType(), pMessage->getData(),
                                               pMI->getTotalMessageLength(), ui8ChunkIndex, pMI->getTotalNumberOfChunks(),
                                               pszQueryId);
                }

                free ((void*) pMessage->getData());
                delete pMessage->getMessageHeader();
                delete pMessage;
            }
        }
    }
}