Example #1
0
uint32_t encodedSize(const Variant::List& values)
{
    uint32_t size = 4/*size field*/ + 4/*count field*/;
    for(Variant::List::const_iterator i = values.begin(); i != values.end(); ++i) {
        size += 1/*typecode*/ + encodedSize(*i);
    }
    return size;
}
Example #2
0
void PnData::write(const Variant::List& list)
{
    pn_data_put_list(data);
    pn_data_enter(data);
    for (Variant::List::const_iterator i = list.begin(); i != list.end(); ++i) {
        write(*i);
    }
    pn_data_exit(data);
}
Example #3
0
void encode(const Variant::List& list, uint32_t len, qpid::framing::Buffer& buffer)
{
    uint32_t s = buffer.getPosition();
    buffer.putLong(len - 4);//exclusive of the size field itself
    buffer.putLong(list.size());
    for (Variant::List::const_iterator i = list.begin(); i != list.end(); ++i) {
    	encode(*i, buffer);
    }
    (void) s; assert(s + len == buffer.getPosition());
}
Example #4
0
void AgentImpl::handleDataIndication(const Variant::List& list, const Message& msg)
{
    Variant::Map::const_iterator aIter;
    const Variant::Map& props(msg.getProperties());
    boost::shared_ptr<SyncContext> context;

    aIter = props.find("qmf.content");
    if (aIter == props.end())
        return;

    string content_type(aIter->second.asString());
    if (content_type != "_event")
        return;

    for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
        const Variant::Map& eventMap(lIter->asMap());
        Data data(new DataImpl(eventMap, this));
        int severity(SEV_NOTICE);
        uint64_t timestamp(0);

        aIter = eventMap.find("_severity");
        if (aIter != eventMap.end())
            severity = int(aIter->second.asInt8());

        aIter = eventMap.find("_timestamp");
        if (aIter != eventMap.end())
            timestamp = aIter->second.asUint64();

        auto_ptr<ConsoleEventImpl> eventImpl(new ConsoleEventImpl(CONSOLE_EVENT));
        eventImpl->setAgent(this);
        eventImpl->addData(data);
        eventImpl->setSeverity(severity);
        eventImpl->setTimestamp(timestamp);
        if (data.hasSchema())
            learnSchemaId(data.getSchemaId());
        session.enqueueEvent(eventImpl.release());
    }
}
Example #5
0
void AgentImpl::handleQueryResponse(const Variant::List& list, const Message& msg)
{
    const string& cid(msg.getCorrelationId());
    Variant::Map::const_iterator aIter;
    const Variant::Map& props(msg.getProperties());
    uint32_t correlator;
    bool final(false);
    boost::shared_ptr<SyncContext> context;

    aIter = props.find("partial");
    if (aIter == props.end())
        final = true;

    aIter = props.find("qmf.content");
    if (aIter == props.end())
        return;

    string content_type(aIter->second.asString());
    if (content_type != "_schema" && content_type != "_schema_id" && content_type != "_data")
        return;

    try { correlator = boost::lexical_cast<uint32_t>(cid); }
    catch(const boost::bad_lexical_cast&) { correlator = 0; }

    {
        qpid::sys::Mutex::ScopedLock l(lock);
        map<uint32_t, boost::shared_ptr<SyncContext> >::iterator iter = contextMap.find(correlator);
        if (iter != contextMap.end())
            context = iter->second;
    }

    if (context.get() != 0) {
        //
        // This response is associated with a synchronous request.
        //
        qpid::sys::Mutex::ScopedLock cl(context->lock);
        if (!context->response.isValid())
            context->response = ConsoleEvent(new ConsoleEventImpl(CONSOLE_QUERY_RESPONSE));

        if (content_type == "_data")
            for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
                Data data(new DataImpl(lIter->asMap(), this));
                ConsoleEventImplAccess::get(context->response).addData(data);
                if (data.hasSchema())
                    learnSchemaId(data.getSchemaId());
            }
        else if (content_type == "_schema_id")
            for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
                SchemaId schemaId(new SchemaIdImpl(lIter->asMap()));
                ConsoleEventImplAccess::get(context->response).addSchemaId(schemaId);
                learnSchemaId(schemaId);
            }
        else if (content_type == "_schema")
            for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
                Schema schema(new SchemaImpl(lIter->asMap()));
                schemaCache->declareSchema(schema);
            }

        if (final) {
            ConsoleEventImplAccess::get(context->response).setFinal();
            ConsoleEventImplAccess::get(context->response).setAgent(this);
            context->cond.notify();
        }
    } else {