Package org.rhq.enterprise.communications.command

Examples of org.rhq.enterprise.communications.command.Command


            String[] remoteCmdArgs = new String[args.length - 1];
            System.arraycopy(args, 1, remoteCmdArgs, 0, remoteCmdArgs.length);

            // use the command line client utility to build the command, but send the command via the agent's client sender
            CmdlineClient client = new CmdlineClient();
            Command command = client.buildCommand(remoteCmdArgs);

            int blast_count = getTestBlastCount(agent);

            for (int i = 0; i < blast_count; i++) {
                agent.getClientCommandSender().sendAsynch(command, new Callback(agent));
View Full Code Here


            String[] remoteCmdArgs = new String[args.length - 1];
            System.arraycopy(args, 1, remoteCmdArgs, 0, remoteCmdArgs.length);

            // use the command line client utility to build the command, but send the command via the agent's client sender
            CmdlineClient client = new CmdlineClient();
            Command command = client.buildCommand(remoteCmdArgs);

            agent.getOut().println(MSG.getMsg(AgentI18NResourceKeys.SERVER_SENDING));

            CommandResponse response = agent.getClientCommandSender().sendSynch(command);
View Full Code Here

    /**
     * @see AgentPromptCommand#execute(AgentMain, String[])
     */
    public boolean execute(AgentMain agent, String[] args) {
        Command command = new IdentifyCommand();
        PrintWriter out = agent.getOut();

        try {
            ClientCommandSender sender = agent.getClientCommandSender();

View Full Code Here

                && (System.currentTimeMillis() - m_lastSentConnectAgent.timestamp) < 30000L) {
                LOG.info(AgentI18NResourceKeys.NOT_SENDING_DUP_CONNECT, m_lastSentConnectAgent);
                return;
            }

            Command connectCommand = createConnectAgentCommand();
            getClientCommandSender().preprocessCommand(connectCommand); // important that we are already registered by now!
            CommandResponse connectResponse;

            if (attemptFailover) {
                connectResponse = comm.sendWithoutInitializeCallback(connectCommand);
View Full Code Here

            config.commandSpoolFilePurgePercentage, false);

        // sent 500 guaranteed and 500 volatile commands, ensure we send all of them
        try {
            for (int i = 0; i < 1000; i++) {
                Command cmd_to_send = createGenericCommand();
                cmd_to_send.setParameterValue("num", String.valueOf(i));

                if ((i % 2) == 0) {
                    sender.sendAsynchGuaranteed(cmd_to_send, null);
                } else {
                    sender.sendAsynch(cmd_to_send, null);
View Full Code Here

     *
     * @throws Exception
     */
    public void testOptionalIterator() throws Exception {
        OptionalParameterDefinitionIterator iter;
        Command cmd;
        ParameterDefinition[] defs;

        iter = new OptionalParameterDefinitionIterator((Collection<ParameterDefinition>) null);

        assertFalse(iter.hasNext());
        try {
            iter.next();
            fail("Should have thrown NoSuchElementException");
        } catch (NoSuchElementException nsee) {
        }

        defs = null;
        iter = new OptionalParameterDefinitionIterator(defs);

        assertFalse(iter.hasNext());
        try {
            iter.next();
            fail("Should have thrown NoSuchElementException");
        } catch (NoSuchElementException nsee) {
        }

        // there are four definitions but only 3 are optional
        cmd = new ParamsTestCommand();
        defs = cmd.getParameterDefinitions();

        iter = new OptionalParameterDefinitionIterator(defs);
        for (int i = 0; i < 3; i++) {
            assertNotNull(iter.next());
            if ((i + 1) < 3) {
                assertTrue(iter.hasNext());
            }
        }

        assertFalse(iter.hasNext());

        // there are no definitions
        cmd = new NoParamTestCommand();
        defs = cmd.getParameterDefinitions();

        iter = new OptionalParameterDefinitionIterator(defs);
        assertFalse(iter.hasNext());
    }
View Full Code Here

     *
     * @throws Exception
     */
    public void testRequiredIterator() throws Exception {
        RequiredParameterDefinitionIterator iter;
        Command cmd;
        ParameterDefinition[] defs;

        iter = new RequiredParameterDefinitionIterator((Collection<ParameterDefinition>) null);

        assertFalse(iter.hasNext());
        try {
            iter.next();
            fail("Should have thrown NoSuchElementException");
        } catch (NoSuchElementException nsee) {
        }

        defs = null;
        iter = new RequiredParameterDefinitionIterator(defs);

        assertFalse(iter.hasNext());
        try {
            iter.next();
            fail("Should have thrown NoSuchElementException");
        } catch (NoSuchElementException nsee) {
        }

        // there are four definitions but only 1 is required
        cmd = new ParamsTestCommand();
        defs = cmd.getParameterDefinitions();

        iter = new RequiredParameterDefinitionIterator(defs);
        assertTrue(iter.hasNext());
        assertNotNull(iter.next());
        assertFalse(iter.hasNext());

        // there are no definitions
        cmd = new NoParamTestCommand();
        defs = cmd.getParameterDefinitions();

        iter = new RequiredParameterDefinitionIterator(defs);
        assertFalse(iter.hasNext());
    }
View Full Code Here

                    LinkedList<Runnable> remaining_tasks = new LinkedList<Runnable>();
                    m_queue.drainTo(remaining_tasks);

                    while (remaining_tasks.size() > 0) {
                        ClientCommandSenderTask next_task = getTaskFromRunnable(remaining_tasks.removeFirst());
                        Command task_command = next_task.getCommandAndCallback().getCommand();

                        if (isDeliveryGuaranteed(task_command)) {
                            spoolCommandAndCallback(next_task.getCommandAndCallback());
                            commands_persisted++;
                        } else {
View Full Code Here

    /**
     * @see CommandClient#invoke(Map)
     */
    public CommandResponse invoke(Map<String, Object> params) throws Throwable {
        Command command = createNewCommand(params);

        // have the command sent back to us so the client receiving the response can also see the command issued
        command.setCommandInResponse(true);

        return invoke(command);
    }
View Full Code Here

     *
     * @see java.lang.Runnable#run()
     */
    public void run() {
        CommandResponse response;
        Command command = m_cnc.getCommand();
        boolean notify_callback = (m_cnc.getCallback() != null); // only notify the callback if we actually have one

        try {
            m_sender.waitForSendThrottle(command);

View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.Command

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.