Examples of QmfData


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

        if (args.length > 2)
        {
            bindingIdentifier = bindingIdentifier + "/" + args[2];
        }

        QmfData arguments = new QmfData();
        arguments.setValue("type", "binding");
        arguments.setValue("name", bindingIdentifier);

        try
        {
            _broker.invokeMethod("delete", arguments);
        }
View Full Code Here

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

                return;
            }

            try
            {
                QmfData arguments = new QmfData();
                arguments.setValue("request", (long)(_purge*msgDepth));
                queue.invokeMethod("purge", arguments);
            }
            catch (QmfException e)
            {
                System.out.println(e.getMessage());
View Full Code Here

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

            List<Agent> agentList = Arrays.asList(new Agent[] {agent});
            List<QmfConsoleData> objects = _console.getObjects(pkg, cls, agentList);

            // 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)
            {
View Full Code Here

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

            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);
                }
                _agent.queryComplete(item.getHandle(), 0);
            }
            else
            {
                // Look up QmfAgentData objects by the SchemaClassId obtained from the query
                // This is implemented by a linear search and allows searches with only the className specified.
                // Linear searches clearly don't scale brilliantly, but the number of QmfAgentData objects managed
                // by an Agent is generally fairly small, so it should be OK. Note that this is the same approach
                // taken by the C++ broker ManagementAgent, so if it's a problem here........
                for (QmfAgentData object : _objectIndex.values())
                {
                    if (!object.isDeleted() && query.evaluate(object))
                    {
                        _agent.queryResponse(item.getHandle(), object);
                    }
                }
                _agent.queryComplete(item.getHandle(), 0);
            }
        }

        if (wi.getType() == SUBSCRIBE_REQUEST)
        {
            SubscribeRequestWorkItem item = (SubscribeRequestWorkItem)wi;
            SubscriptionParams params = item.getSubscriptionParams();
            Handle handle = item.getHandle();

            System.out.println("Subscribe Request User ID = " + params.getUserId());

            try
            {
                Subscription subscription = new Subscription(this, params);
                _subscriptions.put(subscription.getSubscriptionId(), subscription);
                _timer.schedule(subscription, 0, params.getPublishInterval());

                if (subscription == null)
                {
System.out.println("Requested Subscription has already expired or been cancelled");
                    QmfData error = new QmfData();
                    error.setValue("error_text", "Requested Subscription has already expired or been cancelled");
                    _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), null, 0, 0, error);
                }
                else
                {
                    _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), subscription.getSubscriptionId(),
                                               subscription.getDuration(), subscription.getInterval(), null);
                }
            }
            catch (QmfException qmfe)
            {
                _agent.raiseException(handle, "Subscribe Request failed, invalid Query: " + qmfe.getMessage());
            }
        }

        if (wi.getType() == RESUBSCRIBE_REQUEST)
        {
            ResubscribeRequestWorkItem item = (ResubscribeRequestWorkItem)wi;
            ResubscribeParams params = item.getResubscribeParams();
            Handle handle = item.getHandle();

            System.out.println("Resubscribe Request User ID = " + params.getUserId());

            String subscriptionId = params.getSubscriptionId();
            Subscription subscription = _subscriptions.get(subscriptionId);
            if (subscription != null)
            {
                subscription.refresh(params);
                _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), subscription.getSubscriptionId(),
                                           subscription.getDuration(), subscription.getInterval(), null);
            }
            else
            {
System.out.println("Requested Subscription has already expired or been cancelled");
                QmfData error = new QmfData();
                error.setValue("error_text", "Requested Subscription has already expired or been cancelled");
                _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), null, 0, 0, error);
            }
        }

        if (wi.getType() == UNSUBSCRIBE_REQUEST)
View Full Code Here

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

            throw new QmfException("QmfCallback listener must be either a Notifier or QmfEventListener");
        }

        if (options != null)
        { // We wrap the Map in a QmfData object to avoid potential class cast issues with the parsed options
            QmfData optMap = new QmfData(new AddressParser(options).map());
            if (optMap.hasValue("replyTimeout"))
            {
                _replyTimeout = (int)optMap.getLongValue("replyTimeout");
            }

            if (optMap.hasValue("agentTimeout"))
            {
                _agentTimeout = (int)optMap.getLongValue("agentTimeout");
            }

            if (optMap.hasValue("subscriptionDuration"))
            {
                _subscriptionDuration = (int)optMap.getLongValue("subscriptionDuration");
            }
        }
    }
View Full Code Here

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

        long timeout = _replyTimeout;
        String replyHandle = null;

        if (options != null)
        { // We wrap the Map in a QmfData object to avoid potential class cast issues with the parsed options
            QmfData optMap = new QmfData(new AddressParser(options).map());
            if (optMap.hasValue("lifetime"))
            {
                lifetime = optMap.getLongValue("lifetime");
            }

            if (optMap.hasValue("publishInterval"))
            { // Multiply publishInterval by 1000 because the QMF2 protocol spec says interval is
              // "The request time (in milliseconds) between periodic updates of data in this subscription"
                publishInterval = 1000*optMap.getLongValue("publishInterval");
            }

            if (optMap.hasValue("timeout"))
            {
                timeout = optMap.getLongValue("timeout");
            }

            if (optMap.hasValue("replyHandle"))
            {
                replyHandle = optMap.getStringValue("replyHandle");
            }
        }

        try
        {
View Full Code Here

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

        long timeout = _replyTimeout;
        String replyHandle = null;

        if (options != null)
        { // We wrap the Map in a QmfData object to avoid potential class cast issues with the parsed options
            QmfData optMap = new QmfData(new AddressParser(options).map());
            if (optMap.hasValue("lifetime"))
            {
                lifetime = optMap.getLongValue("lifetime");
            }

            if (optMap.hasValue("timeout"))
            {
                timeout = optMap.getLongValue("timeout");
            }

            if (optMap.hasValue("replyHandle"))
            {
                replyHandle = optMap.getStringValue("replyHandle");
            }
        }

        try
        {
View Full Code Here

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

            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
            {
                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);
                        _agent.addObject(child);
                        QmfData outArgs = new QmfData();
                        outArgs.setRefValue("childAddr", child.getObjectId(), "reference"); // Set subtype just to test
                        _agent.methodResponse(methodName, item.getHandle(), outArgs, null);
                    }
                }
            }
            catch (QmfException qmfe)
            {
                System.err.println("QmfException " + qmfe.getMessage() + " caught: AgentTest failed");
                QmfData error = new QmfData();
                error.setValue("error_text", qmfe.getMessage());
                _agent.methodResponse(methodName, item.getHandle(), null, error);
            }
        }
    }
View Full Code Here

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

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


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


                // ********** Invoke echo nethod asynchronously **********
                System.out.println("Testing asynchronous call of invokeMethod(echo, args) ");
                inArgs = new QmfData();
                inArgs.setValue("message", "This message should be echoed by the Agent");
                control.invokeMethod("echo", inArgs, "echoMethodCorrelationId");


                // Asynchronous update and display state of control object. The state here should be the same as
                // the last time it was called as this is an asynchronous refresh. The ObjectUpdateWorkItem in
                // the event handler contains the new state
                control.refresh("echoMethodCorrelationId");
                System.out.println("MethodCount = " + control.getLongValue("methodCount") + " (should be same as last value)");



                // ********** Invoke stop nethod, this will stop the Agent **********
                System.out.println("Testing invokeMethod(stop, args) ");
                inArgs = new QmfData();
                inArgs.setValue("message", "Ladies and gentlemen Elvis has just left the building");
                control.invokeMethod("stop", inArgs);


            }
View Full Code Here

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

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

            QmfConsoleData broker = brokers.get(0);
            QmfData arguments = new QmfData();

            while (true)
            {
                try
                {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.