Package org.apache.qpid.qmf2.console

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


            String packageName = "com.profitron.gizmo";

            // Declare a schema for a structured exception that can be used in failed method invocations.
            SchemaObjectClass exception = new SchemaObjectClass(packageName, "exception");

            exception.addProperty(new SchemaProperty("whatHappened", QmfType.TYPE_STRING));
            exception.addProperty(new SchemaProperty("howBad", QmfType.TYPE_INT));
            exception.addProperty(new SchemaProperty("details", QmfType.TYPE_MAP));

            // Declare a control object to test methods against.
            SchemaObjectClass control = new SchemaObjectClass(packageName, "control");
            control.addProperty(new SchemaProperty("state", QmfType.TYPE_STRING));
            control.addProperty(new SchemaProperty("methodCount", QmfType.TYPE_INT));

            SchemaMethod stopMethod = new SchemaMethod("stop", "Stop Agent");
            stopMethod.addArgument(new SchemaProperty("message", QmfType.TYPE_STRING));
            control.addMethod(stopMethod);

            SchemaMethod echoMethod = new SchemaMethod("echo", "Echo Arguments");
            echoMethod.addArgument(new SchemaProperty("sequence", QmfType.TYPE_INT, "{dir:INOUT}"));
            echoMethod.addArgument(new SchemaProperty("map", QmfType.TYPE_MAP, "{dir:INOUT}"));
            control.addMethod(echoMethod);

            SchemaMethod eventMethod = new SchemaMethod("event", "Raise an Event");
            eventMethod.addArgument(new SchemaProperty("text", QmfType.TYPE_STRING, "{dir:IN}"));
            eventMethod.addArgument(new SchemaProperty("severity", QmfType.TYPE_INT, "{dir:IN}"));
            control.addMethod(eventMethod);

            SchemaMethod failMethod = new SchemaMethod("fail", "Expected to Fail");
            failMethod.addArgument(new SchemaProperty("useString", QmfType.TYPE_BOOL, "{dir:IN}"));
            failMethod.addArgument(new SchemaProperty("stringVal", QmfType.TYPE_STRING, "{dir:IN}"));
            failMethod.addArgument(new SchemaProperty("details", QmfType.TYPE_MAP, "{dir:IN}"));
            control.addMethod(failMethod);

            SchemaMethod createMethod = new SchemaMethod("create_child", "Create Child Object");
            createMethod.addArgument(new SchemaProperty("name", QmfType.TYPE_STRING, "{dir:IN}"));
            createMethod.addArgument(new SchemaProperty("childAddr", QmfType.TYPE_MAP, "{dir:OUT}"));
            control.addMethod(createMethod);

            // Declare the child class
            SchemaObjectClass child = new SchemaObjectClass(packageName, "child");
            child.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
   
            // Declare the event class
            SchemaEventClass event = new SchemaEventClass(packageName, "event");
            event.addProperty(new SchemaProperty("text", QmfType.TYPE_STRING));

            System.out.println("Test3 Schema classes initialised OK");

            // Now we create new instance of each class from the map encodings and list the values
            // to check everything looks OK.
View Full Code Here


        // Create and register schema for this agent.
        String packageName = "com.test.bigagent";

        // Declare a control object to test methods against.
        _controlSchema = new SchemaObjectClass(packageName, "control");
        _controlSchema.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
        _controlSchema.setIdNames("name");

        SchemaMethod createMethod = new SchemaMethod("processPayload", "Process a large payload");
        createMethod.addArgument(new SchemaProperty("parameter", QmfType.TYPE_STRING, "{dir:IN}"));
        createMethod.addArgument(new SchemaProperty("return", QmfType.TYPE_STRING, "{dir:OUT}"));
        _controlSchema.addMethod(createMethod);
        System.out.println("BigPayloadAgentTest Schema classes initialised OK");

        _agent.registerObjectClass(_controlSchema);
View Full Code Here

            // Create and register schema for this agent.
            String packageName = "com.fadams.qmf2";

            // Declare a mammal class to test against.
            SchemaObjectClass mammal = new SchemaObjectClass(packageName, "mammal");
            mammal.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
            mammal.addProperty(new SchemaProperty("legs", QmfType.TYPE_INT));
            mammal.setIdNames("name");

            // Declare an insect class to test against.
            SchemaObjectClass insect = new SchemaObjectClass(packageName, "insect");
            insect.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
            insect.addProperty(new SchemaProperty("legs", QmfType.TYPE_INT));
            insect.setIdNames("name");

            // Declare a reptile class to test against.
            SchemaObjectClass reptile = new SchemaObjectClass(packageName, "reptile");
            reptile.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
            reptile.addProperty(new SchemaProperty("legs", QmfType.TYPE_INT));
            reptile.setIdNames("name");

            // Declare a bird class to test against.
            SchemaObjectClass bird = new SchemaObjectClass(packageName, "bird");
            bird.addProperty(new SchemaProperty("name", QmfType.TYPE_STRING));
            bird.addProperty(new SchemaProperty("legs", QmfType.TYPE_INT));
            bird.setIdNames("name");


            registerObjectClass(mammal);
            registerObjectClass(insect);
View Full Code Here

            while (true)
            {
                notifier.waitForWorkItem();
                System.out.println("WorkItem available, WorkItem count = " + _console.getWorkitemCount());

                WorkItem wi;
                while ((wi = _console.getNextWorkitem(0)) != null)
                {
                    System.out.println("WorkItem type: " + wi.getType());
                    if (wi.getType() == AGENT_HEARTBEAT || wi.getType() == AGENT_ADDED ||
                        wi.getType() == AGENT_DELETED || wi.getType() == AGENT_RESTARTED ||
                        wi.getType() == EVENT_RECEIVED)
                    {
                        Map<String, Object> p = wi.<Map<String, Object>>getParams();
                        Agent agent = (Agent)p.get("agent");
                        System.out.println(agent.getName());
                    }
                }
View Full Code Here

                    if (wi.getType() == AGENT_HEARTBEAT || wi.getType() == AGENT_ADDED ||
                        wi.getType() == AGENT_DELETED || wi.getType() == AGENT_RESTARTED ||
                        wi.getType() == EVENT_RECEIVED)
                    {
                        Map<String, Object> p = wi.<Map<String, Object>>getParams();
                        Agent agent = (Agent)p.get("agent");
                        System.out.println(agent.getName());
                    }
                }

                count++;
                if (count == 10)
View Full Code Here

            {
                agent.listValues();
            }

            System.out.println("*** Test1 testing _console.getAgent(\"broker\"): ***");
            Agent agent = _console.getAgent("broker");
            agent.listValues();

            System.out.println("*** Test1 testing _console.findAgent(\"broker\"): ***");
            agent = _console.findAgent("broker");
            if (agent == null)
            {
                System.out.println("*** Test1 _console.findAgent(\"broker\") returned null : Test1 failed ***");
                System.exit(1);
            }
            else
            {
                agent.listValues();
            }


            System.out.println("*** Test1 testing _console.findAgent(\"monkey\"): ***");
            agent = _console.findAgent("monkey");
            if (agent == null)
            {
                System.out.println("*** Test1 _console.findAgent(\"monkey\") correctly returned null ***");
            }
            else
            {
                agent.listValues();
            }


            System.out.println("*** Test1 testing _console.getObjects(\"broker\"): ***");
            List<QmfConsoleData> brokers = _console.getObjects("broker");
View Full Code Here

    public void onEvent(final WorkItem wi)
    {
        if (wi instanceof EventReceivedWorkItem)
        {
            EventReceivedWorkItem item = (EventReceivedWorkItem)wi;
            Agent agent = item.getAgent();
            QmfEvent event = item.getEvent();

            String className = event.getSchemaClassId().getClassName();
            if (className.equals("clientConnect") ||
                className.equals("clientDisconnect"))
            {
                _stateChanged = true;
            }
        }
        else if (wi instanceof AgentRestartedWorkItem)
        {
            _stateChanged = true;
        }
        else if (wi instanceof AgentHeartbeatWorkItem)
        {
            AgentHeartbeatWorkItem item = (AgentHeartbeatWorkItem)wi;
            Agent agent = item.getAgent();

            if (_stateChanged && agent.getName().contains("qpidd"))
            {
                logConnectionInformation();
                _stateChanged = false;
            }
        }
View Full Code Here

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

    public void onEvent(final WorkItem wi)
    {
        if (wi instanceof EventReceivedWorkItem)
        {
            EventReceivedWorkItem item = (EventReceivedWorkItem)wi;
            Agent agent = item.getAgent();
            QmfEvent event = item.getEvent();
            String className = event.getSchemaClassId().getClassName();

            if (className.equals("queueDeclare"))
            {
View Full Code Here

            Connection connection = ConnectionHelper.createConnection(url, connectionOptions);       
            _console = new Console();
            _console.addConnection(connection);

            // Find the specified Agent
            Agent agent = _console.findAgent(agentName);
            if (agent == null)
            {
                System.out.println("Agent " + agentName + " not found");
                System.exit(1);
            }
View Full Code Here

TOP

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

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.