Search in sources :

Example 1 with SchemaClassId

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

the class QpidQueueStats method createQueueSubscription.

/**
     * Create a Subscription to query for all queue objects
     */
private void createQueueSubscription() {
    try {
        // This QmfQuery simply does an ID query for objects with the className "queue"
        QmfQuery query = new QmfQuery(QmfQueryTarget.OBJECT, new SchemaClassId("queue"));
        SubscribeParams params = _console.createSubscription(_broker, query, "queueStatsHandle");
        _subscriptionId = params.getSubscriptionId();
        // Subtract 10 as we want to refresh before it times out
        _subscriptionDuration = params.getLifetime() - 10;
        _startTime = System.currentTimeMillis();
    } catch (QmfException qmfe) {
    }
}
Also used : SubscribeParams(org.apache.qpid.qmf2.console.SubscribeParams) SchemaClassId(org.apache.qpid.qmf2.common.SchemaClassId) QmfQuery(org.apache.qpid.qmf2.common.QmfQuery) QmfException(org.apache.qpid.qmf2.common.QmfException)

Example 2 with SchemaClassId

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

the class SchemaTest method onEvent.

public void onEvent(WorkItem wi) {
    if (wi instanceof AgentAddedWorkItem) {
        AgentAddedWorkItem item = (AgentAddedWorkItem) wi;
        Agent agent = item.getAgent();
        System.out.println("\nAgent " + agent.getName() + " added ");
        // Retrieve the List of SchemaClassIds from the Agent, these will be used to retrieve the Schema.
        List<SchemaClassId> schemaClassIds = _console.getClasses(agent);
        if (schemaClassIds.size() > 0) {
            // For each retrieved Class retrieve and display the Schema.
            for (SchemaClassId schemaClassId : schemaClassIds) {
                List<SchemaClass> schema = _console.getSchema(schemaClassId, agent);
                if (schema.size() == 1) {
                    schema.get(0).listValues();
                }
            }
        } else {
            System.out.println("No schema information is available for this Agent");
        }
    }
}
Also used : Agent(org.apache.qpid.qmf2.console.Agent) SchemaClass(org.apache.qpid.qmf2.common.SchemaClass) AgentAddedWorkItem(org.apache.qpid.qmf2.console.AgentAddedWorkItem) SchemaClassId(org.apache.qpid.qmf2.common.SchemaClassId)

Example 3 with SchemaClassId

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

the class Test4 method registerObjectClass.

public void registerObjectClass(SchemaObjectClass schema) {
    SchemaClassId classId = schema.getClassId();
    _schemaCache.put(classId, schema);
}
Also used : SchemaClassId(org.apache.qpid.qmf2.common.SchemaClassId)

Example 4 with SchemaClassId

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

the class Test4 method addObject.

public void addObject(QmfAgentData object) throws QmfException {
    SchemaClassId classId = object.getSchemaClassId();
    SchemaClass schema = _schemaCache.get(classId);
    // Try to create an objectName using the set of property names that have been specified as idNames in the schema
    StringBuilder buf = new StringBuilder();
    if (schema != null && schema instanceof SchemaObjectClass) {
        String[] idNames = ((SchemaObjectClass) schema).getIdNames();
        for (String name : idNames) {
            buf.append(object.getStringValue(name));
        }
    }
    String objectName = buf.toString();
    // If the schema hasn't given any help we use a UUID
    if (objectName.length() == 0)
        objectName = UUID.randomUUID().toString();
    // Finish up the name by incorporating package and class names
    objectName = classId.getPackageName() + ":" + classId.getClassName() + ":" + objectName;
    // Now we've got a good name for the object we create it's ObjectId and add that to the object
    ObjectId addr = new ObjectId("test", /*name*/
    objectName, 0);
    object.setObjectId(addr);
    if (_objectIndex.get(addr) != null) {
        throw new QmfException("Duplicate QmfAgentData Address");
    }
    _objectIndex.put(addr, object);
}
Also used : ObjectId(org.apache.qpid.qmf2.common.ObjectId) SchemaClass(org.apache.qpid.qmf2.common.SchemaClass) SchemaObjectClass(org.apache.qpid.qmf2.common.SchemaObjectClass) SchemaClassId(org.apache.qpid.qmf2.common.SchemaClassId) QmfException(org.apache.qpid.qmf2.common.QmfException)

Example 5 with SchemaClassId

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

the class Agent method getSchema.

/**
     * Return the SchemaClass associated with this Agent.
     * @return the list of SchemaClass associated with this Agent.
     * <p>
     * I <i>believe</i> that there should only be one entry in the list returned when looking up a specific chema by classId.
     */
public List<SchemaClass> getSchema(final SchemaClassId classId) {
    SchemaClass schema = _schemaCache.get(classId);
    if (schema == SchemaClass.EMPTY_SCHEMA) {
        return Collections.emptyList();
    }
    List<SchemaClass> results = new ArrayList<SchemaClass>();
    results.add(schema);
    return results;
}
Also used : SchemaClass(org.apache.qpid.qmf2.common.SchemaClass) ArrayList(java.util.ArrayList)

Aggregations

SchemaClassId (org.apache.qpid.qmf2.common.SchemaClassId)14 SchemaClass (org.apache.qpid.qmf2.common.SchemaClass)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 JMSException (javax.jms.JMSException)4 ObjectId (org.apache.qpid.qmf2.common.ObjectId)4 MapMessage (javax.jms.MapMessage)3 Message (javax.jms.Message)3 AMQPMessage (org.apache.qpid.qmf2.common.AMQPMessage)3 QmfException (org.apache.qpid.qmf2.common.QmfException)3 QmfQuery (org.apache.qpid.qmf2.common.QmfQuery)3 SchemaObjectClass (org.apache.qpid.qmf2.common.SchemaObjectClass)3 List (java.util.List)2 Destination (javax.jms.Destination)1 Handle (org.apache.qpid.qmf2.common.Handle)1 QmfEvent (org.apache.qpid.qmf2.common.QmfEvent)1 QmfQueryTarget (org.apache.qpid.qmf2.common.QmfQueryTarget)1 SchemaEventClass (org.apache.qpid.qmf2.common.SchemaEventClass)1