Search in sources :

Example 6 with EventReceivedWorkItem

use of org.apache.qpid.qmf2.console.EventReceivedWorkItem 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 7 with EventReceivedWorkItem

use of org.apache.qpid.qmf2.console.EventReceivedWorkItem 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 8 with EventReceivedWorkItem

use of org.apache.qpid.qmf2.console.EventReceivedWorkItem in project qpid by apache.

the class BrokerSubscriptionTestConsole 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");
            }
            String className = object.getSchemaClassId().getClassName();
            System.out.println("object class = " + className);
            if (className.equals("queue") || className.equals("exchange")) {
                if (object.hasValue("name")) {
                    System.out.println("property update, name = " + object.getStringValue("name"));
                } else {
                    _objectId = object.getObjectId();
                    System.out.println("statistic update, oid = " + _objectId);
                }
            }
        }
    }
}
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)

Aggregations

QmfEvent (org.apache.qpid.qmf2.common.QmfEvent)8 EventReceivedWorkItem (org.apache.qpid.qmf2.console.EventReceivedWorkItem)7 Agent (org.apache.qpid.qmf2.console.Agent)5 AgentHeartbeatWorkItem (org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem)4 ObjectId (org.apache.qpid.qmf2.common.ObjectId)3 MethodResponseWorkItem (org.apache.qpid.qmf2.console.MethodResponseWorkItem)3 MethodResult (org.apache.qpid.qmf2.console.MethodResult)3 ObjectUpdateWorkItem (org.apache.qpid.qmf2.console.ObjectUpdateWorkItem)3 QmfConsoleData (org.apache.qpid.qmf2.console.QmfConsoleData)3 AgentRestartedWorkItem (org.apache.qpid.qmf2.console.AgentRestartedWorkItem)2 SubscribeIndication (org.apache.qpid.qmf2.console.SubscribeIndication)2 SubscribeParams (org.apache.qpid.qmf2.console.SubscribeParams)2 SubscribeResponseWorkItem (org.apache.qpid.qmf2.console.SubscribeResponseWorkItem)2 SubscriptionIndicationWorkItem (org.apache.qpid.qmf2.console.SubscriptionIndicationWorkItem)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1