Package org.rhq.enterprise.communications.command

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


            CmdlineClient client = new CmdlineClient();
            Command command = client.buildCommand(remoteCmdArgs);

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

            CommandResponse response = agent.getClientCommandSender().sendSynch(command);

            agent.getOut().println(response);
        } catch (Exception e) {
            throw new RuntimeException(MSG.getMsg(AgentI18NResourceKeys.SERVER_FAILURE), e);
        }
View Full Code Here


            System.arraycopy(args, 1, remoteCmdArgs, 0, remoteCmdArgs.length);

            // use the command line client utility to issue the command
            CmdlineClient client = new CmdlineClient();
            agent.getOut().println(MSG.getMsg(AgentI18NResourceKeys.REMOTE_ISSUING));
            CommandResponse response = client.issueCommand(remoteCmdArgs);
            agent.getOut().println(response);
        } catch (Throwable e) {
            throw new RuntimeException(MSG.getMsg(AgentI18NResourceKeys.REMOTE_FAILURE), e);
        }
View Full Code Here

    private boolean ping(RemoteCommunicator comm) {
        boolean ok = true; // assume we can ping; on error, we'll set this to false
        IdentifyCommand id_cmd = new IdentifyCommand();
        this.agent.getClientCommandSender().preprocessCommand(id_cmd);
        try {
            CommandResponse response = comm.sendWithoutCallbacks(id_cmd);
            // there is a special case when we might get a response back but it should be considered "server down".
            // that is: when the server replies with a NotProcessedException response
            if (response.getException() instanceof NotProcessedException) {
                ok = false;
            }
        } catch (Throwable e) {
            ok = false;
        }
View Full Code Here

            if (!agent.isStarted() || sender == null) {
                out.println(MSG.getMsg(AgentI18NResourceKeys.IDENTIFY_NOT_SENDING));
            } else if (args.length <= 1) {
                // the user didn't specify a locator URI, by default, we'll send the command to our configured server
                out.println(MSG.getMsg(AgentI18NResourceKeys.IDENTIFY_ASK_SERVER_FOR_ID));
                CommandResponse response = sender.sendSynch(command);
                out.println(response);

                // let the server know about the time of the server
                if (response instanceof IdentifyCommandResponse && response.isSuccessful()) {
                    long serverTime = ((IdentifyCommandResponse) response).getIdentification().getTimestamp();
                    agent.serverClockNotification(serverTime);
                }
            } else if (args.length > 2) {
                out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
            } else {
                ServerEndpoint serverEndpoint = AgentUtils.getServerEndpoint(agent.getConfiguration(), args[1]);

                // use the generic client utility to issue the command
                RemoteCommunicator rc = agent.createServerRemoteCommunicator(serverEndpoint.transport,
                    serverEndpoint.namePort.address, serverEndpoint.namePort.port, serverEndpoint.transportParams);
                GenericCommandClient client = new GenericCommandClient(rc);

                out.println(MSG.getMsg(AgentI18NResourceKeys.IDENTIFY_ASK_REMOTE_SERVER_FOR_ID, args[1]));
                sender.preprocessCommand(command);
                CommandResponse response = client.invoke(command);

                client.disconnectRemoteCommunicator();

                out.println(response);
            }
View Full Code Here

                return;
            }

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

            if (attemptFailover) {
                connectResponse = comm.sendWithoutInitializeCallback(connectCommand);
            } else {
                connectResponse = comm.sendWithoutCallbacks(connectCommand);
            }

            if (!connectResponse.isSuccessful()) {
                Throwable exception = connectResponse.getException();
                if (exception != null) {
                    if (exception.getCause() instanceof AgentNotSupportedException) {
                        exception = exception.getCause(); // this happens if we got InvocationTargetException
                    }
                    throw exception;
                } else {
                    throw new Exception("FAILED: " + connectCommand);
                }
            }

            m_lastSentConnectAgent.timestamp = System.currentTimeMillis();
            m_lastSentConnectAgent.serverEndpoint = comm.getRemoteEndpoint();

            try {
                ConnectAgentResults results = (ConnectAgentResults) connectResponse.getResults();

                // BZ 1124614 - We know here the agent version is compatible with the server.  But it may not
                // be the same version.  If the agent is configured to auto-update itself, and it is not the same
                // version as the latest agent version as told to us by the server, then this agent should update now.
                // Notice we will only check the build number (hash), the version may be the same but the
View Full Code Here

        assert !agent1.getConfiguration().isClientSenderSecurityServerAuthMode();
        assert agent2.getConfiguration().isClientSenderSecurityServerAuthMode();

        IdentifyCommand command = new IdentifyCommand();
        CommandResponse cmdresponse;

        cmdresponse = agent1.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Should have been able to send - agent1 does not need to auth the server: "
            + cmdresponse;

        cmdresponse = agent2.getClientCommandSender().sendSynch(command);
        assert !cmdresponse.isSuccessful() : "Should not have been able to send - agent2 don't have a truststore to authenticate the server";

        return;
    }
View Full Code Here

            SSLSocketBuilder.CLIENT_AUTH_MODE_NEED);
        assert agent2.getServiceContainer().getConfiguration().getConnectorSecurityClientAuthMode().equals(
            SSLSocketBuilder.CLIENT_AUTH_MODE_WANT);

        IdentifyCommand command = new IdentifyCommand();
        CommandResponse cmdresponse;

        cmdresponse = agent1.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Should have been able to send - agent2 only 'wants' to auth clients, but is not required to: "
            + cmdresponse;

        cmdresponse = agent2.getClientCommandSender().sendSynch(command);
        assert !cmdresponse.isSuccessful() : "Should not have been able to send - agent1 'needs' client auth but it doesn't have a truststore to authenticate clients";

        return;
    }
View Full Code Here

        assert agent1.getConfiguration().getClientSenderSecuritySocketProtocol().equals("SSL");
        assert agent2.getConfiguration().getClientSenderSecuritySocketProtocol().equals("SSL");

        IdentifyCommand command = new IdentifyCommand();
        CommandResponse cmdresponse;
        IdentifyCommandResponse response;

        cmdresponse = agent1.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Failed to send command from agent1 to agent2: " + cmdresponse;
        response = (IdentifyCommandResponse) cmdresponse;
        assert new InvokerLocator(response.getIdentification().getInvokerLocator()).getPort() == agent2
            .getServiceContainer().getConfiguration().getConnectorBindPort() : "Didn't get the identify of agent2 - what remoting server did we just communicate with??";

        cmdresponse = agent2.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Failed to send command from agent2 to agent1: " + cmdresponse;
        response = (IdentifyCommandResponse) cmdresponse;
        assert new InvokerLocator(response.getIdentification().getInvokerLocator()).getPort() == agent1
            .getServiceContainer().getConfiguration().getConnectorBindPort() : "Didn't get the identity of agent1 - what remoting server did we just communicate with??";

        return;
View Full Code Here

        assert agent1.getConfiguration().getClientSenderSecuritySocketProtocol().equals("TLS");
        assert agent2.getConfiguration().getClientSenderSecuritySocketProtocol().equals("SSL");

        IdentifyCommand command = new IdentifyCommand();
        CommandResponse cmdresponse;
        IdentifyCommandResponse response;

        cmdresponse = agent1.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Failed to send command from agent1 to agent2: " + cmdresponse;
        response = (IdentifyCommandResponse) cmdresponse;
        assert new InvokerLocator(response.getIdentification().getInvokerLocator()).getPort() == agent2
            .getServiceContainer().getConfiguration().getConnectorBindPort() : "Didn't get the identify of agent2 - what remoting server did we just communicate with??";

        cmdresponse = agent2.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Failed to send command from agent2 to agent1: " + cmdresponse;
        response = (IdentifyCommandResponse) cmdresponse;
        assert new InvokerLocator(response.getIdentification().getInvokerLocator()).getPort() == agent1
            .getServiceContainer().getConfiguration().getConnectorBindPort() : "Didn't get the identity of agent1 - what remoting server did we just communicate with??";

        return;
View Full Code Here

            SSLSocketBuilder.CLIENT_AUTH_MODE_NEED);
        assert agent2.getServiceContainer().getConfiguration().getConnectorSecurityClientAuthMode().equals(
            SSLSocketBuilder.CLIENT_AUTH_MODE_NEED);

        IdentifyCommand command = new IdentifyCommand();
        CommandResponse cmdresponse;
        IdentifyCommandResponse response;

        cmdresponse = agent1.getClientCommandSender().sendSynch(command);
        assert cmdresponse.isSuccessful() : "Failed to send command from agent1 to agent2: " + cmdresponse;
        response = (IdentifyCommandResponse) cmdresponse;
        assert new InvokerLocator(response.getIdentification().getInvokerLocator()).getPort() == agent2
            .getServiceContainer().getConfiguration().getConnectorBindPort() : "Didn't get the identify of agent2 - what remoting server did we just communicate with??";

        // JBoss Remoting 2 doesn't seem to like me doing bi-directional messaging within the same VM
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.