Search in sources :

Example 21 with ObjectId

use of org.apache.qpid.qmf2.common.ObjectId in project qpid by apache.

the class Queue method mapEncode.

/**
 * This method maps the org.apache.qpid.server.model.Queue to QMF2 broker properties where possible then
 * serialises into the underlying Map for transmission via AMQP. This method is called by handleQueryRequest()
 * in the org.apache.qpid.qmf2.agent.Agent class implementing the main QMF2 Agent behaviour.
 *
 * @return the underlying map.
 */
@Override
public Map<String, Object> mapEncode() {
    // too late to populate the "altEx" property of the queueDeclareEvent.
    if (_alternateExchange == null) {
        Exchange altEx = _queue.getAlternateExchange();
        if (altEx != null) {
            _alternateExchangeName = _vhostName + altEx.getName();
            _alternateExchange = new ObjectId("", "org.apache.qpid.broker:exchange:" + _alternateExchangeName, 0);
            setRefValue("altExchange", _alternateExchange);
        }
    }
    // Statistics
    setValue("msgTotalEnqueues", _queue.getTotalEnqueuedMessages());
    setValue("msgTotalDequeues", _queue.getTotalDequeuedMessages());
    // msgTxnEnqueues not implemented in Java Broker
    // msgTxnDequeues not implemented in Java Broker
    setValue("msgPersistEnqueues", _queue.getPersistentEnqueuedMessages());
    setValue("msgPersistDequeues", _queue.getPersistentDequeuedMessages());
    setValue("msgDepth", _queue.getQueueDepthMessages());
    setValue("byteDepth", _queue.getQueueDepthBytes());
    setValue("byteTotalEnqueues", _queue.getTotalEnqueuedBytes());
    setValue("byteTotalDequeues", _queue.getTotalDequeuedBytes());
    // byteTxnEnqueues not implemented in Java Broker
    // byteTxnDequeues not implemented in Java Broker
    setValue("bytePersistEnqueues", _queue.getPersistentEnqueuedBytes());
    setValue("bytePersistDequeues", _queue.getPersistentDequeuedBytes());
    // Flow-to-disk Statistics not implemented in Java Broker
    // releases & acquires not implemented in Java Broker
    // discardsTtl (discardsTtlMessages) not implemented in Java Broker
    // discardsRing not implemented in Java Broker
    // discardsLvq not implemented in Java Broker
    // discardsOverflow not implemented in Java Broker
    // discardsSubscriber not implemented in Java Broker
    // discardsPurge not implemented in Java Broker
    // reroutes not implemented in Java Broker
    setValue("consumerCount", _queue.getConsumerCount());
    setValue("bindingCount", _queue.getBindingCount());
    setValue("unackedMessages", _queue.getUnacknowledgedMessages());
    setValue("messageLatency", "Not yet implemented");
    // flowStopped not implemented in Java Broker
    // flowStoppedCount not implemented in Java Broker
    // TODO only update if statistics have actually changed.
    update();
    return super.mapEncode();
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) ObjectId(org.apache.qpid.qmf2.common.ObjectId)

Example 22 with ObjectId

use of org.apache.qpid.qmf2.common.ObjectId in project qpid by apache.

the class AgentExternalTest method evaluateQuery.

/**
 * This method evaluates a QmfQuery over the Agent's data on behalf of a Subscription
 *
 * @param query the QmfQuery that the Subscription wants to be evaluated over the Agent's data
 * @return a List of QmfAgentData objects that match the specified QmfQuery
 */
public List<QmfAgentData> evaluateQuery(QmfQuery query) {
    List<QmfAgentData> results = new ArrayList<QmfAgentData>(_objectIndex.size());
    if (query.getTarget() == QmfQueryTarget.OBJECT) {
        if (query.getObjectId() != null) {
            // Look up a QmfAgentData object by the ObjectId obtained from the query
            ObjectId objectId = query.getObjectId();
            QmfAgentData object = _objectIndex.get(objectId);
            if (object != null && !object.isDeleted()) {
                results.add(object);
            }
        } else {
            // Look up QmfAgentData objects evaluating the query
            for (QmfAgentData object : _objectIndex.values()) {
                if (!object.isDeleted() && query.evaluate(object)) {
                    results.add(object);
                }
            }
        }
    }
    return results;
}
Also used : ObjectId(org.apache.qpid.qmf2.common.ObjectId) ArrayList(java.util.ArrayList) QmfAgentData(org.apache.qpid.qmf2.agent.QmfAgentData)

Example 23 with ObjectId

use of org.apache.qpid.qmf2.common.ObjectId in project qpid by apache.

the class AgentSubscriptionTestConsole method onEvent.

public void onEvent(WorkItem wi) {
    System.out.println("WorkItem type: " + wi.getType());
    if (wi.getType() == AGENT_HEARTBEAT) {
        AgentHeartbeatWorkItem item = (AgentHeartbeatWorkItem) wi;
        Agent agent = item.getAgent();
        System.out.println(agent.getName());
    }
    if (wi.getType() == EVENT_RECEIVED) {
        EventReceivedWorkItem item = (EventReceivedWorkItem) wi;
        Agent agent = item.getAgent();
        QmfEvent event = item.getEvent();
        String className = event.getSchemaClassId().getClassName();
        System.out.println("Event: " + className);
    // event.listValues();
    }
    if (wi.getType() == METHOD_RESPONSE) {
        MethodResponseWorkItem item = (MethodResponseWorkItem) wi;
        MethodResult result = item.getMethodResult();
        String correlationId = item.getHandle().getCorrelationId();
        System.out.println("correlationId = " + correlationId);
        System.out.println(result.getStringValue("message"));
    }
    if (wi.getType() == OBJECT_UPDATE) {
        ObjectUpdateWorkItem item = (ObjectUpdateWorkItem) wi;
        QmfConsoleData object = item.getQmfConsoleData();
        ObjectId objectId = object.getObjectId();
        String correlationId = item.getHandle().getCorrelationId();
        System.out.println("correlationId = " + correlationId);
        System.out.println("objectId = " + objectId);
        System.out.println("MethodCount = " + object.getLongValue("methodCount"));
    }
    if (wi.getType() == SUBSCRIBE_RESPONSE) {
        SubscribeResponseWorkItem item = (SubscribeResponseWorkItem) wi;
        SubscribeParams params = item.getSubscribeParams();
        System.out.println("duration = " + params.getLifetime());
        System.out.println("interval = " + params.getPublishInterval());
        System.out.println("subscriptionId = " + params.getSubscriptionId());
        System.out.println("consoleHandle = " + params.getConsoleHandle());
        String correlationId = item.getHandle().getCorrelationId();
        System.out.println("correlationId = " + correlationId);
    }
    if (wi.getType() == SUBSCRIPTION_INDICATION) {
        SubscriptionIndicationWorkItem item = (SubscriptionIndicationWorkItem) wi;
        SubscribeIndication indication = item.getSubscribeIndication();
        String correlationId = indication.getConsoleHandle();
        System.out.println("correlationId = " + correlationId);
        List<QmfConsoleData> objects = indication.getData();
        for (QmfConsoleData object : objects) {
            if (object.isDeleted()) {
                System.out.println("object has been deleted");
            }
            System.out.println("offset = " + object.getValue("offset"));
        }
    }
}
Also used : Agent(org.apache.qpid.qmf2.console.Agent) SubscriptionIndicationWorkItem(org.apache.qpid.qmf2.console.SubscriptionIndicationWorkItem) ObjectId(org.apache.qpid.qmf2.common.ObjectId) AgentHeartbeatWorkItem(org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem) EventReceivedWorkItem(org.apache.qpid.qmf2.console.EventReceivedWorkItem) QmfEvent(org.apache.qpid.qmf2.common.QmfEvent) MethodResponseWorkItem(org.apache.qpid.qmf2.console.MethodResponseWorkItem) SubscribeIndication(org.apache.qpid.qmf2.console.SubscribeIndication) ObjectUpdateWorkItem(org.apache.qpid.qmf2.console.ObjectUpdateWorkItem) SubscribeParams(org.apache.qpid.qmf2.console.SubscribeParams) SubscribeResponseWorkItem(org.apache.qpid.qmf2.console.SubscribeResponseWorkItem) QmfConsoleData(org.apache.qpid.qmf2.console.QmfConsoleData) MethodResult(org.apache.qpid.qmf2.console.MethodResult)

Example 24 with ObjectId

use of org.apache.qpid.qmf2.common.ObjectId in project qpid by apache.

the class AgentTestConsole method onEvent.

public void onEvent(WorkItem wi) {
    System.out.println("WorkItem type: " + wi.getType());
    if (wi.getType() == AGENT_ADDED) {
        AgentAddedWorkItem item = (AgentAddedWorkItem) wi;
        Agent agent = item.getAgent();
        // If this is the gizmo Agent we notify the main thread so processing can continue.
        if (agent.getProduct().equals("gizmo")) {
            synchronized (this) {
                _gizmo = agent;
                notify();
            }
        }
    }
    if (wi.getType() == AGENT_HEARTBEAT) {
        AgentHeartbeatWorkItem item = (AgentHeartbeatWorkItem) wi;
        Agent agent = item.getAgent();
        System.out.println(agent.getName());
    }
    if (wi.getType() == EVENT_RECEIVED) {
        EventReceivedWorkItem item = (EventReceivedWorkItem) wi;
        Agent agent = item.getAgent();
        QmfEvent event = item.getEvent();
        String className = event.getSchemaClassId().getClassName();
        System.out.println("Event: " + className);
    // event.listValues();
    }
    if (wi.getType() == METHOD_RESPONSE) {
        MethodResponseWorkItem item = (MethodResponseWorkItem) wi;
        MethodResult result = item.getMethodResult();
        String correlationId = item.getHandle().getCorrelationId();
        System.out.println("correlationId = " + correlationId);
        System.out.println(result.getStringValue("message"));
    }
    if (wi.getType() == OBJECT_UPDATE) {
        ObjectUpdateWorkItem item = (ObjectUpdateWorkItem) wi;
        QmfConsoleData object = item.getQmfConsoleData();
        ObjectId objectId = object.getObjectId();
        String correlationId = item.getHandle().getCorrelationId();
        System.out.println("correlationId = " + correlationId);
        System.out.println("objectId = " + objectId);
        System.out.println("MethodCount = " + object.getLongValue("methodCount"));
    }
}
Also used : Agent(org.apache.qpid.qmf2.console.Agent) ObjectUpdateWorkItem(org.apache.qpid.qmf2.console.ObjectUpdateWorkItem) ObjectId(org.apache.qpid.qmf2.common.ObjectId) AgentHeartbeatWorkItem(org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem) EventReceivedWorkItem(org.apache.qpid.qmf2.console.EventReceivedWorkItem) QmfEvent(org.apache.qpid.qmf2.common.QmfEvent) QmfConsoleData(org.apache.qpid.qmf2.console.QmfConsoleData) AgentAddedWorkItem(org.apache.qpid.qmf2.console.AgentAddedWorkItem) MethodResponseWorkItem(org.apache.qpid.qmf2.console.MethodResponseWorkItem) MethodResult(org.apache.qpid.qmf2.console.MethodResult)

Example 25 with ObjectId

use of org.apache.qpid.qmf2.common.ObjectId in project qpid by apache.

the class ConnectionLogger method logConnectionInformation.

/**
 * Logs audit information about each connection made to the broker
 *
 * Obtains connection, session and subscription objects and iterates in turn through these comparing
 * references to find the subscriptions association with sessions and sessions associated with
 * connections. Ultimately it then uses logQueueInformation to display the queues associated with
 * each subscription.
 */
private void logConnectionInformation() {
    System.out.println("\n\n**** ConnectionLogger: Logging current connection information ****");
    List<QmfConsoleData> connections = _console.getObjects("org.apache.qpid.broker", "connection");
    List<QmfConsoleData> sessions = _console.getObjects("org.apache.qpid.broker", "session");
    List<QmfConsoleData> subscriptions = _console.getObjects("org.apache.qpid.broker", "subscription");
    for (QmfConsoleData connection : connections) {
        System.out.printf("\nConnection '%s'\n", connection.getStringValue("address"));
        String[] properties = { "authIdentity", "remoteProcessName", "federationLink" };
        for (String p : properties) {
            System.out.println(p + ": " + connection.getStringValue(p));
        }
        System.out.println("createTimestamp: " + new Date(connection.getCreateTime() / 1000000l));
        ObjectId connectionId = connection.getObjectId();
        for (QmfConsoleData session : sessions) {
            // Iterate through all session objects
            ObjectId connectionRef = session.getRefValue("connectionRef");
            if (connectionRef.equals(connectionId)) {
                // But only select sessions that are associated with the connection under consideration.
                System.out.printf("Session '%s'\n", session.getStringValue("name"));
                int subscriptionCount = 0;
                ObjectId sessionId = session.getObjectId();
                for (QmfConsoleData subscription : subscriptions) {
                    // Iterate through all subscription objects
                    ObjectId sessionRef = subscription.getRefValue("sessionRef");
                    if (sessionRef.equals(sessionId)) {
                        // But only select subscriptions that are associated with the session under consideration.
                        subscriptionCount++;
                        ObjectId queueRef = subscription.getRefValue("queueRef");
                        if (_logQueues) {
                            logQueueInformation(queueRef);
                        }
                    }
                }
                if (subscriptionCount == 0) {
                    System.out.println("    ** No Subscriptions for this Session - probably a producer only Session **");
                }
            }
        }
    }
}
Also used : ObjectId(org.apache.qpid.qmf2.common.ObjectId) QmfConsoleData(org.apache.qpid.qmf2.console.QmfConsoleData) Date(java.util.Date)

Aggregations

ObjectId (org.apache.qpid.qmf2.common.ObjectId)28 QmfConsoleData (org.apache.qpid.qmf2.console.QmfConsoleData)15 Map (java.util.Map)10 HashMap (java.util.HashMap)8 QmfException (org.apache.qpid.qmf2.common.QmfException)7 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)6 QmfData (org.apache.qpid.qmf2.common.QmfData)6 SchemaClassId (org.apache.qpid.qmf2.common.SchemaClassId)6 ArrayList (java.util.ArrayList)5 QmfEvent (org.apache.qpid.qmf2.common.QmfEvent)5 Agent (org.apache.qpid.qmf2.console.Agent)5 MethodCallParams (org.apache.qpid.qmf2.agent.MethodCallParams)4 MethodCallWorkItem (org.apache.qpid.qmf2.agent.MethodCallWorkItem)4 AgentHeartbeatWorkItem (org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem)4 MethodResult (org.apache.qpid.qmf2.console.MethodResult)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 QmfQuery (org.apache.qpid.qmf2.common.QmfQuery)3 SchemaClass (org.apache.qpid.qmf2.common.SchemaClass)3 EventReceivedWorkItem (org.apache.qpid.qmf2.console.EventReceivedWorkItem)3 MethodResponseWorkItem (org.apache.qpid.qmf2.console.MethodResponseWorkItem)3