Package org.apache.qpid.qmf2.common

Examples of org.apache.qpid.qmf2.common.ObjectId


     * @param objectName the name of the QmfAgentData being managed.
     * @return a new ObjectId based on the objectName passed as a parameter.
     */
    public ObjectId allocObjectId(final String objectName)
    {
        return new ObjectId(getName(), objectName, getEpoch());
    }
View Full Code Here


            _control.incValue("methodCount", 1);

            MethodCallWorkItem item = (MethodCallWorkItem)wi;
            MethodCallParams methodCallParams = item.getMethodCallParams();
            String methodName = methodCallParams.getName();
            ObjectId objectId = methodCallParams.getObjectId();
            String userId = methodCallParams.getUserId();
            QmfData inArgs = methodCallParams.getArgs();
            ObjectId controlAddress = _control.getObjectId();

            System.out.println("Method Call User ID = " + userId);

            try
            {
                if (objectId == null)
                {
                    // Method invoked directly on Agent
                    if (methodName.equals("toString"))
                    {
                        QmfData outArgs = new QmfData();
                        outArgs.setValue("string", _agent.toString());
                        _agent.methodResponse(methodName, item.getHandle(), outArgs, null);
                    }
                }
                else if (objectId.equals(controlAddress))
                {
                    if (methodName.equals("stop"))
                    {
                        System.out.println("Invoked stop method");
                        String message = inArgs.getStringValue("message");
                        System.out.println("Stopping: message = " + message);
                        _agent.methodResponse(methodName, item.getHandle(), null, null);
                        _agent.destroy();
                        System.exit(1);
                    }
                    else if (methodName.equals("echo"))
                    {
                        System.out.println("Invoked echo method");
                        _agent.methodResponse(methodName, item.getHandle(), inArgs, null);
                    }
                    else if (methodName.equals("event"))
                    {
                        System.out.println("Invoked event method");
                        QmfEvent event = new QmfEvent(_eventSchema);
                        event.setSeverity((int)inArgs.getLongValue("severity"));
                        event.setValue("text", inArgs.getStringValue("text"));
                        _agent.raiseEvent(event);
                        _agent.methodResponse(methodName, item.getHandle(), null, null);
                    }
                    else if (methodName.equals("fail"))
                    {
                        System.out.println("Invoked fail method");
                        QmfData error = new QmfData();
                        if (inArgs.getBooleanValue("useString"))
                        {
                            error.setValue("error_text", inArgs.getStringValue("stringVal"));
                        }
                        else
                        {
                            error.setValue("whatHappened", "It Failed");
                            error.setValue("howBad", 75);
                            error.setValue("details", inArgs.getValue("details"));
                        }
                        _agent.methodResponse(methodName, item.getHandle(), null, error);
                    }
                    else if (methodName.equals("create_child"))
                    {
                        System.out.println("Invoked create_child method");
                        String childName = inArgs.getStringValue("name");
                        System.out.println("childName = " + childName);
                        QmfAgentData child = new QmfAgentData(_childSchema);
                        child.setValue("name", childName);
                        addObject(child);
                        QmfData outArgs = new QmfData();
                        outArgs.setRefValue("childAddr", child.getObjectId(), "reference"); // Set suptype just to test
                        _agent.methodResponse(methodName, item.getHandle(), outArgs, null);
                    }
                }
            }
            catch (QmfException qmfe)
            {
                System.err.println("QmfException " + qmfe.getMessage() + " caught: AgentExternalTest failed");
                QmfData error = new QmfData();
                error.setValue("error_text", qmfe.getMessage());
                _agent.methodResponse(methodName, item.getHandle(), null, error);
            }
        }

        if (wi.getType() == QUERY)
        {
            QueryWorkItem item = (QueryWorkItem)wi;
            QmfQuery query = item.getQmfQuery();

            System.out.println("Query User ID = " + item.getUserId());

            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())
                {
                    _agent.queryResponse(item.getHandle(), object);
                }
View Full Code Here

        System.out.println("AgentExternalTest Schema control object added OK");
    }

    public void addObject(QmfAgentData object) throws QmfException
    {
        ObjectId addr = _agent.allocObjectId(UUID.randomUUID().toString());
        object.setObjectId(addr);
        _objectIndex.put(addr, object);

        // Does the new object match any Subscriptions? If so add a reference to the matching Subscription and publish.
        for (Subscription subscription : _subscriptions.values())
View Full Code Here

        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);
                }
View Full Code Here

        if (wi.getType() == METHOD_CALL)
        {
            MethodCallWorkItem item = (MethodCallWorkItem)wi;
            MethodCallParams methodCallParams = item.getMethodCallParams();
            String methodName = methodCallParams.getName();
            ObjectId objectId = methodCallParams.getObjectId();
            String userId = methodCallParams.getUserId();
            userId = userId.equals("") ? "anonymous" : userId;
            QmfData inArgs = methodCallParams.getArgs();
            ObjectId controlAddress = _control.getObjectId();

            System.out.println("Method Call User ID = " + userId);

            try
            {
View Full Code Here

            {
                System.out.println("control object found");
                QmfConsoleData control = controls.get(0);
                //control.listValues();

                ObjectId oid = control.getObjectId();
                //System.out.println("Agent Name = " + oid.getAgentName());
                //System.out.println("Agent Epoch = " + oid.getAgentEpoch());
                //System.out.println("Object Name = " + oid.getObjectName());

                System.out.println("Testing lookup of object by ObjectId");
                controls = _console.getObjects(oid);

                if (controls.size() == 0)
                {
                    System.out.println("No objects returned from ObjectId lookup: AgentTestConsole failed");
                    System.exit(1);
                }

                System.out.println("MethodCount = " + control.getLongValue("methodCount"));
                QmfData inArgs;
                QmfData outArgs;
                MethodResult results;

/*
                System.out.println("Testing invokeMethod(toString, args) - method called directly on Agent");
                results = _gizmo.invokeMethod("toString", null);
                System.out.println("gizmo.toString() = " + results.getArguments().getStringValue("string"));
*/

                // ********** Invoke create_child nethod **********
                System.out.println("Testing invokeMethod(create_child, args)");
                inArgs = new QmfData();
                inArgs.setValue("name", "child 1");

                results = control.invokeMethod("create_child", inArgs);
                if (!results.succeeded())
                {
                    System.out.println("create_child returned an exception object");
                    System.exit(1);
                }

                if (!results.hasValue("childAddr"))
                {
                    System.out.println("create_child returned an unexpected value");
                    System.exit(1);
                }

                ObjectId childId = results.getRefValue("childAddr");       
                System.out.println("childId = " + childId);
                System.out.println("childAddr subtype = " + results.getSubtype("childAddr"));
                QmfConsoleData child1 = _console.getObjects(childId).get(0);
                System.out.println("child1 name = " + child1.getStringValue("name"));

View Full Code Here

        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"));
        }
View Full Code Here

        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"));
        }
View Full Code Here

        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"));
        }
View Full Code Here

        // ObjectId needs to be set here in Exchange because the QMF2 version of qpid-config uses a hardcoded
        // _object_name as below in the _object_id that it sets in the getExchange() call and in exchangeRef.
        // It *shouldn't* do this and should really use the _object_id of the exchange object returned by
        // getObjects("exchange"), but it does. The following line causes the Agent to use the explicit
        // ObjectId below rather than constructing its own, which fixes the qpid-config issue.
        setObjectId(new ObjectId("", "org.apache.qpid.broker:exchange:" + _name, 0));
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.qmf2.common.ObjectId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.