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