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;
}
}
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations