Package org.apache.qpid.qmf2.console

Examples of org.apache.qpid.qmf2.console.MethodResult


            // Parse the args String
            QmfData inArgs = (args == null) ? new QmfData() : new QmfData(new AddressParser(args).map());

            // Find the required QmfConsoleData object and invoke the specified command
            MethodResult results = null;
            for (QmfConsoleData object : objects)
            {
                String objectName = object.getObjectId().getObjectName();
                if (command.equals("listObjects"))
                {
                    System.out.println(objectName);
                }
                else
                {
                    if (objectName.contains(id))
                    { // Use contains as ObjectNames may comprise other identifiers tha make using equals impractical
                        if (command.equals("listValues"))
                        {
                            object.listValues();
                            System.exit(1);
                        }
                        else
                        {
                            results = object.invokeMethod(command, inArgs);
                        }
                        break;
                    }
                }
            }

            if (results == null)
            {
                if (objects.size() == 0)
                {
                    System.out.println("getObjects(" + pkg + ", " + cls + ", " + agentName + ") returned no objects.");
                }
                else
                {
                    System.out.println("Id " + id + " not found in " + pkg + ":" + cls);
                }
            }
            else
            {
                if (results.succeeded())
                {
                    results.listValues();
                }
                else
                {
                    System.err.println ("QmfException " + results.getQmfException().getMessage() +
                                        " returned from " + command + " method");
                }
            }
        }
        catch (QmfException qmfe)
View Full Code Here


                }

                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"));


                // Update and display state of control object
                control.refresh();
                System.out.println("MethodCount = " + control.getLongValue("methodCount"));


                // ********** Invoke event nethod **********
                System.out.println("Testing invokeMethod(event, args) ");
                inArgs = new QmfData();
                inArgs.setValue("text", "Attention Will Robinson!! Aliens have just invaded");
                inArgs.setValue("severity", 0);
                control.invokeMethod("event", inArgs);


                // Update and display state of control object
                control.refresh();
                System.out.println("MethodCount = " + control.getLongValue("methodCount"));


                // ********** Invoke fail nethod **********
                System.out.println("Testing invokeMethod(fail, args) ");
                QmfData details = new QmfData();
                details.setValue("detail1", "something bad");
                details.setValue("detail2", "something even badder");
                inArgs = new QmfData();
                inArgs.setValue("details", details.mapEncode());
                results = control.invokeMethod("fail", inArgs);
                System.out.println("whatHappened: " + results.getStringValue("whatHappened"));
                System.out.println("howBad: " + results.getLongValue("howBad"));

                // Update and display state of control object
                control.refresh();
                System.out.println("MethodCount = " + control.getLongValue("methodCount"));

View Full Code Here

        }

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

        }

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

        }

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

            while (true)
            {
                try
                {
                    MethodResult results = broker.invokeMethod("getLogLevel", arguments);
//System.out.println(results.getStringValue("level"));
                }
                catch (QmfException e)
                { // This may be throw if we've already added the queues, we just catch and ignore for this test.
                    //System.out.println(e.getMessage());
View Full Code Here

            // Parse the args String
            QmfData inArgs = (args == null) ? new QmfData() : new QmfData(new AddressParser(args).map());

            // Find the required QmfConsoleData object and invoke the specified command
            MethodResult results = null;
            for (QmfConsoleData object : objects)
            {
                String objectName = object.getObjectId().getObjectName();
                if (command.equals("listObjects"))
                {
                    System.out.println(objectName);
                }
                else
                {
                    if (objectName.contains(id))
                    { // Use contains as ObjectNames may comprise other identifiers tha make using equals impractical
                        if (command.equals("listValues"))
                        {
                            object.listValues();
                            System.exit(1);
                        }
                        else
                        {
                            results = object.invokeMethod(command, inArgs);
                        }
                        break;
                    }
                }
            }

            if (results == null)
            {
                if (objects.size() == 0)
                {
                    System.out.println("getObjects(" + pkg + ", " + cls + ", " + agentName + ") returned no objects.");
                }
                else
                {
                    System.out.println("Id " + id + " not found in " + pkg + ":" + cls);
                }
            }
            else
            {
                if (results.succeeded())
                {
                    results.listValues();
                }
                else
                {
                    System.err.println ("QmfException " + results.getQmfException().getMessage() +
                                        " returned from " + command + " method");
                }
            }
        }
        catch (QmfException qmfe)
View Full Code Here

                                // Parse the args if present into a QmfData (needed by invokeMethod).
                                QmfData inArgs = (args == null) ? new QmfData() : new QmfData(args);

                                // Invoke the specified method on the QmfConsoleData we've created.
                                MethodResult results = null;

                                _log.info("invokeMethod: {}", request);
                                results = object.invokeMethod(method, inArgs);
                                tx.sendResponse(HTTP_OK, "application/json", JSON.fromObject(results));
                            }
View Full Code Here

            {
                System.out.println("No broker QmfConsoleData returned");
                System.exit(1);
            }

            QmfConsoleData broker = brokers.get(0);
            QmfData arguments = new QmfData();
            arguments.setValue("type", "queue");

            for (int i = 0; i < 300; i++)
            {
                arguments.setValue("name", "test " + i);

                try
                {
                    broker.invokeMethod("create", arguments);
                }
                catch (QmfException e)
                { // This may be throw if we've already added the queues, we just catch and ignore for this test.
                    //System.out.println(e.getMessage());
                }
View Full Code Here

                                }
                            }

                            if (_filter.isEmpty() || matches)
                            { // If there's no filter enabled or the filter matches the queue name we display statistics.
                                QmfConsoleData lastSample = stats.getData();
                                stats.setData(record);
   
                                float deltaTime = record.getUpdateTime() - lastSample.getUpdateTime();
                                if (deltaTime > 1000000000.0f)
                                {
                                    float deltaEnqueues = record.getLongValue("msgTotalEnqueues") -
                                                          lastSample.getLongValue("msgTotalEnqueues");
                                    float deltaDequeues = record.getLongValue("msgTotalDequeues") -
                                                          lastSample.getLongValue("msgTotalDequeues");
                                    long msgDepth = record.getLongValue("msgDepth");
                                    float enqueueRate = deltaEnqueues/(deltaTime/1000000000.0f);
                                    float dequeueRate = deltaDequeues/(deltaTime/1000000000.0f);

                                    System.out.printf("%-46s%10.2f%11d%13.2f%13.2f\n",
View Full Code Here

TOP

Related Classes of org.apache.qpid.qmf2.console.MethodResult

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.