Search in sources :

Example 1 with QmfEvent

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

the class ConnectionLogger method onEvent.

/**
 * Listener for QMF2 WorkItems
 * <p>
 * This method looks for clientConnect or clientDisconnect Events and uses these as a trigger to log the new
 * connection state when the next Heartbeat occurs.
 * <p>
 * There are a couple of reasons for using this approach rather than just calling logConnectionInformation()
 * as soon as we see the clientConnect or clientDisconnect Event.
 * <p>
 * 1. We could potentially have lots of connection Events and redisplaying all of the connections for each
 *    Event is likely to be confusing.
 * <p>
 * 2. When a clientConnect Event occurs we don't have all of the informatin that we might need, for example this
 *    application checks the Session and Subscription information and also optionally Queue and Binding information.
 *    Creating Sessions/Subscriptions won't generally occur until some (possibly small, but possibly not) time
 *    after the Connection has been made. The approach taken here reduces spurious assertions that a Session is
 *    probably a "producer only" Session. As one of the use-cases for this tool is to attempt to flag up "producer
 *    only" Sessions we want to try and make it as reliable as possible.
 *
 * @param wi a QMF2 WorkItem object
 */
public void onEvent(final WorkItem wi) {
    if (wi instanceof EventReceivedWorkItem) {
        EventReceivedWorkItem item = (EventReceivedWorkItem) wi;
        Agent agent = item.getAgent();
        QmfEvent event = item.getEvent();
        String className = event.getSchemaClassId().getClassName();
        if (className.equals("clientConnect") || className.equals("clientDisconnect")) {
            _stateChanged = true;
        }
    } else if (wi instanceof AgentRestartedWorkItem) {
        _stateChanged = true;
    } else if (wi instanceof AgentHeartbeatWorkItem) {
        AgentHeartbeatWorkItem item = (AgentHeartbeatWorkItem) wi;
        Agent agent = item.getAgent();
        if (_stateChanged && agent.getName().contains("qpidd")) {
            logConnectionInformation();
            _stateChanged = false;
        }
    }
}
Also used : Agent(org.apache.qpid.qmf2.console.Agent) AgentRestartedWorkItem(org.apache.qpid.qmf2.console.AgentRestartedWorkItem) EventReceivedWorkItem(org.apache.qpid.qmf2.console.EventReceivedWorkItem) AgentHeartbeatWorkItem(org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem) QmfEvent(org.apache.qpid.qmf2.common.QmfEvent)

Example 2 with QmfEvent

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

the class ConnectionAudit method onEvent.

/**
 * Handles WorkItems delivered by the Console.
 * <p>
 * If we receive an EventReceivedWorkItem check if it is a subscribe event. If it is we check if the whitelist has
 * changed, and if it has we re-read it. We then extract the queue name, exchange name, binding, connection address
 * and timestamp and validate with the whitelsist.
 * <p>
 * If we receive an AgentRestartedWorkItem we revalidate all subscriptions as it's possible that a client connection
 * could have been made to the broker before ConnectionAudit has successfully re-established its own connections.
 * @param wi a QMF2 WorkItem object
 */
public void onEvent(final WorkItem wi) {
    if (wi instanceof EventReceivedWorkItem) {
        EventReceivedWorkItem item = (EventReceivedWorkItem) wi;
        QmfEvent event = item.getEvent();
        String className = event.getSchemaClassId().getClassName();
        if (className.equals("subscribe")) {
            readWhitelist();
            String queueName = event.getStringValue("qName");
            String address = event.getStringValue("rhost");
            String timestamp = new Date(event.getTimestamp() / 1000000l).toString();
            validateQueue(queueName, address, timestamp);
        }
    } else if (wi instanceof AgentRestartedWorkItem) {
        checkExistingSubscriptions();
    }
}
Also used : AgentRestartedWorkItem(org.apache.qpid.qmf2.console.AgentRestartedWorkItem) EventReceivedWorkItem(org.apache.qpid.qmf2.console.EventReceivedWorkItem) QmfEvent(org.apache.qpid.qmf2.common.QmfEvent) Date(java.util.Date)

Example 3 with QmfEvent

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

the class Connection method createClientConnectEvent.

/**
 * Factory method to create a Client Connect Event Object with timestamp of now.
 * @return the newly created Client Connect Event Object.
 */
public QmfEvent createClientConnectEvent() {
    QmfEvent clientConnect = new QmfEvent(_clientConnectSchema);
    clientConnect.setSeverity("info");
    // TODO Set properties Map - can't really get much info from the org.apache.qpid.server.model.Connection yet.
    clientConnect.setValue("rhost", _connection.getName());
    clientConnect.setValue("user", getStringValue("authIdentity"));
    return clientConnect;
}
Also used : QmfEvent(org.apache.qpid.qmf2.common.QmfEvent)

Example 4 with QmfEvent

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

the class Connection method createClientDisconnectEvent.

/**
 * Factory method to create a Client Disconnect Event Object with timestamp of now.
 * @return the newly created Client Disconnect Event Object.
 */
public QmfEvent createClientDisconnectEvent() {
    QmfEvent clientDisconnect = new QmfEvent(_clientDisconnectSchema);
    clientDisconnect.setSeverity("info");
    // TODO Set properties Map - can't really get much info from the org.apache.qpid.server.model.Connection yet.
    clientDisconnect.setValue("rhost", _connection.getName());
    clientDisconnect.setValue("user", getStringValue("authIdentity"));
    return clientDisconnect;
}
Also used : QmfEvent(org.apache.qpid.qmf2.common.QmfEvent)

Example 5 with QmfEvent

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

the class Subscription method createUnsubscribeEvent.

/**
 * Factory method to create an Unsubscribe Event Object with timestamp of now.
 * @return the newly created Unsubscribe Event Object.
 */
public QmfEvent createUnsubscribeEvent() {
    QmfEvent unsubscribe = new QmfEvent(_unsubscribeSchema);
    unsubscribe.setSeverity("info");
    unsubscribe.setValue("dest", getStringValue("name"));
    // unsubscribe.setValue("user", getStringValue("authIdentity"));
    return unsubscribe;
}
Also used : QmfEvent(org.apache.qpid.qmf2.common.QmfEvent)

Aggregations

QmfEvent (org.apache.qpid.qmf2.common.QmfEvent)20 EventReceivedWorkItem (org.apache.qpid.qmf2.console.EventReceivedWorkItem)7 ObjectId (org.apache.qpid.qmf2.common.ObjectId)5 Agent (org.apache.qpid.qmf2.console.Agent)5 AgentHeartbeatWorkItem (org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem)4 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 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 JMSException (javax.jms.JMSException)2 MethodCallParams (org.apache.qpid.qmf2.agent.MethodCallParams)2 MethodCallWorkItem (org.apache.qpid.qmf2.agent.MethodCallWorkItem)2 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)2 Handle (org.apache.qpid.qmf2.common.Handle)2 QmfData (org.apache.qpid.qmf2.common.QmfData)2 QmfException (org.apache.qpid.qmf2.common.QmfException)2