Package org.rhq.enterprise.communications.command

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


            throw new IllegalArgumentException(getLog()
                .getMsgString(CommI18NResourceKeys.UNKNOWN_COMMAND_TYPE, command));
        }

        // get the executor instance and hand off the command to it
        CommandResponse retResponse;

        try {
            retResponse = typeExecutor.getExecutor().execute(command, null, null);
        } catch (Throwable t) {
            retResponse = new GenericCommandResponse(command, false, null, t);
View Full Code Here


     * @param args specifies the command to invoke and its parameters
     */
    public static void main(String[] args) {
        try {
            CmdlineClient client = new CmdlineClient();
            CommandResponse response = client.issueCommand(args);

            LOG.debug(CommI18NResourceKeys.CMDLINE_CLIENT_RESPONSE, response);
        } catch (Throwable e) {
            String cmdline = "";
            for (int i = 0; i < args.length; i++) {
View Full Code Here

        InvokerLocator invokerLocator = new InvokerLocator(m_locatorUri);
        JBossRemotingRemoteCommunicator communicator = new JBossRemotingRemoteCommunicator(invokerLocator, m_subsystem, null);
        commandClient.setRemoteCommunicator(communicator);

        // tell the concrete command client instance to invoke the command on the remote server
        CommandResponse response = commandClient.invoke(m_params);

        commandClient.disconnectRemoteCommunicator();

        return response;
    }
View Full Code Here

     * @return the command response string that should be logged
     */
    public static String getCommandResponseString(Object response) {
        String responseString;
        if (response instanceof CommandResponse) {
            CommandResponse cmdResponse = (CommandResponse) response;
            if (cmdResponse.isSuccessful()) {
                if (System.getProperty(SYSPROP_TRACE_COMMAND_RESPONSE_RESULTS) != null) {
                    responseString = "success:" + getCommandResponseResultsString(cmdResponse.getResults());
                } else {
                    responseString = "success";
                }
            } else {
                responseString = "failed:" + ThrowableUtil.getAllMessages(cmdResponse.getException());
            }
        } else if (response instanceof Throwable) {
            responseString = ThrowableUtil.getAllMessages((Throwable) response);
        } else if (response instanceof String) {
            responseString = "STRING:" + response.toString();
View Full Code Here

     * @throws Throwable if failed to send the command
     */
    CommandResponse send(Command command) throws Throwable {
        // Keep this method short and simple - all it should do is blindly send the command, return or throw exceptions.
        // Do not attempt to recover or otherwise persist information - callers will be responsible for error handling.
        CommandResponse response;

        try {
            GenericCommandClient client = new GenericCommandClient(m_remoteCommunicator);

            // Give the pre-send callbacks a chance to execute
            executePreSendCallbacks(command);

            long start = System.currentTimeMillis();
            response = client.invoke(command);
            long elapsed = System.currentTimeMillis() - start;

            // Give the post-send callbacks a chance to execute
            response = executePostSendCallbacks(command, response);

            if ((response != null) && response.isSuccessful()) {
                long num = m_metrics.successfulCommands.incrementAndGet();

                // calculate the running average - num is the current command count
                // this may not be accurate if we execute this code concurrently,
                // but its good enough for our simple monitoring needs
View Full Code Here

    /**
     * @see CommandClient#invoke(Command)
     */
    public CommandResponse invoke(Command command) throws Throwable {
        CommandResponse retResponse;

        // during the validity check, we want to automatically convert invalid values to valid values
        command.checkParameterValidity(true);

        retResponse = getRemoteCommunicator().send(command);
View Full Code Here

                try {
                    // Send a small, simple identify command to the server and if it succeeds, tell the client
                    // sender that it is OK to start sending messages, if it is not already sending
                    IdentifyCommand id_cmd = new IdentifyCommand();
                    m_clientSender.preprocessCommand(id_cmd);
                    CommandResponse response = m_clientSender.send(id_cmd);

                    // let all our listeners know what the results of the poll was
                    for (PollingListener listener : m_pollingListeners) {
                        try {
                            listener.pollResponse(response);
                        } catch (Throwable t) {
                            // should never happen, but I'm paranoid
                        }
                    }

                    // there are special cases when we might get a response back but it should be considered "server down".
                    // 1) when the server replies with a NotProcessedException response
                    // 2) when our failover mechanism runs out of retries and it can't find a server to process our request,
                    //    the comm layer will reply with a failoverable exception.
                    // In both cases, our CommUtils will detect this.
                    if (CommUtils.isExceptionFailoverable(response.getException())) {
                        throw response.getException();
                    }

                    if (m_clientSender.startSending()) {
                        LOG.info(CommI18NResourceKeys.SERVER_POLLING_THREAD_SERVER_ONLINE);
                        m_warnedAboutConnectionFailure = false; // if we detect the server is down again, lets log the exception again
View Full Code Here

     * Performs the sending of the command to the server.
     *
     * @see Callable#call()
     */
    public CommandResponse call() throws Exception {
        CommandResponse response;

        try {
            response = send(m_sender, m_cnc);
        } catch (Exception e) {
            throw e;
View Full Code Here

     * due to the command having its guaranteed delivery flag enabled.
     *
     * @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

        c1.start();

        try {
            JBossRemotingRemoteCommunicator client1 = new JBossRemotingRemoteCommunicator(locatorString1);
            client1.connect();
            CommandResponse results = client1.send(new IdentifyCommand());
            assert "foo".equals(results.getResults()) : "Results were " + results;

            c1.stop();
            c1.destroy();

            Thread.sleep(5000); // I have no idea if this will matter, but maybe this avoids the address-already-in-use error we periodically get

            c1.create();

            c1.addInvocationHandler("test", this);
            c1.start();

            results = client1.send(new IdentifyCommand());
            assert "foo".equals(results.getResults()) : "Results were " + results;
        } finally {
            c1.stop();
            c1.destroy();
        }
    }
View Full Code Here

TOP

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

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.