Package org.rhq.enterprise.communications.command.client

Examples of org.rhq.enterprise.communications.command.client.ClientCommandSenderMetrics


    public long getNumberTotalCommandsSent() {
        ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            ClientCommandSenderMetrics metrics = getClientSideMetrics();
            return metrics.getNumberSuccessfulCommandsSent() + metrics.getNumberFailedCommandsSent();
        } finally {
            Thread.currentThread().setContextClassLoader(originalCL);
        }
    }
View Full Code Here


    public boolean isSending() {
        ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            ClientCommandSenderMetrics metrics = getClientSideMetrics();
            return metrics.isSending();
        } finally {
            Thread.currentThread().setContextClassLoader(originalCL);
        }
    }
View Full Code Here

     *
     * @return client side metrics
     */
    private ClientCommandSenderMetrics getClientSideMetrics() {
        ClientCommandSender sender = m_agent.getClientCommandSender();
        ClientCommandSenderMetrics metrics;

        if (sender != null) {
            metrics = sender.getMetrics();
        } else {
            metrics = new ClientCommandSenderMetrics(); // simulate an empty and idle sender (all metrics are zeroed out)
        }

        return metrics;
    }
View Full Code Here

                        sender.startSending();
                    } else if (subcommand.equals(MSG.getMsg(AgentI18NResourceKeys.SENDER_STOP))) {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.SENDER_STOPPING));
                        sender.stopSending(true);
                    } else if (subcommand.equals(MSG.getMsg(AgentI18NResourceKeys.SENDER_METRICS))) {
                        ClientCommandSenderMetrics metrics = sender.getMetrics();

                        out.println(MSG.getMsg(AgentI18NResourceKeys.SENDER_METRICS_OUTPUT, metrics));
                    } else if (!subcommand.equals(MSG.getMsg(AgentI18NResourceKeys.SENDER_STATUS))) {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
                    }
View Full Code Here

        Thread.sleep(2000); // let's wait for the senders to start and send the connectAgent messages (which will fail)

        ServiceContainerMetricsMBean server_metrics1 = m_agent1Test.getServerMetrics();
        ServiceContainerMetricsMBean server_metrics2 = m_agent2Test.getServerMetrics();
        ClientCommandSenderMetrics client_metrics1 = m_agent1Test.getClientMetrics();
        ClientCommandSenderMetrics client_metrics2 = m_agent2Test.getClientMetrics();

        assert client_metrics1.getNumberSuccessfulCommandsSent() == 0;
        assert client_metrics1.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getNumberSuccessfulCommandsSent() == 0;
        assert client_metrics2.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getAverageExecutionTimeSent() == 0;
        assert server_metrics1.getNumberSuccessfulCommandsReceived() == 0;
        assert server_metrics1.getNumberFailedCommandsReceived() == 0;
        assert server_metrics1.getNumberTotalCommandsReceived() == 0;
        assert server_metrics2.getNumberSuccessfulCommandsReceived() == 0;
        assert server_metrics2.getNumberFailedCommandsReceived() == 0;
        assert server_metrics2.getNumberTotalCommandsReceived() == 0;
        assert server_metrics2.getAverageExecutionTimeReceived() == 0;

        IdentifyCommand command = new IdentifyCommand();
        IdentifyCommandResponse response;

        response = (IdentifyCommandResponse) agent1.getClientCommandSender().sendSynch(command);
        assert response.isSuccessful() : "Failed to send command from agent1 to agent2";
        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??";

        assert client_metrics1.getNumberSuccessfulCommandsSent() == 1;
        assert client_metrics1.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getNumberSuccessfulCommandsSent() == 0;
        assert client_metrics2.getNumberFailedCommandsSent() == 0;
        assert server_metrics1.getNumberSuccessfulCommandsReceived() == 0;
        assert server_metrics1.getNumberFailedCommandsReceived() == 0;
        assert server_metrics1.getNumberTotalCommandsReceived() == 0;
        assert server_metrics2.getNumberSuccessfulCommandsReceived() == 1;
        assert server_metrics2.getNumberFailedCommandsReceived() == 0;
        assert server_metrics2.getNumberTotalCommandsReceived() == 1;

        response = (IdentifyCommandResponse) agent1.getClientCommandSender().sendSynch(command);
        assert response.isSuccessful() : "Failed to send command from agent1 to agent2";

        assert client_metrics1.getNumberSuccessfulCommandsSent() == 2;
        assert client_metrics1.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getNumberSuccessfulCommandsSent() == 0;
        assert client_metrics2.getNumberFailedCommandsSent() == 0;
        assert server_metrics1.getNumberSuccessfulCommandsReceived() == 0;
        assert server_metrics1.getNumberFailedCommandsReceived() == 0;
        assert server_metrics1.getNumberTotalCommandsReceived() == 0;
        assert server_metrics2.getNumberSuccessfulCommandsReceived() == 2;
        assert server_metrics2.getNumberFailedCommandsReceived() == 0;
        assert server_metrics2.getNumberTotalCommandsReceived() == 2;

        response = (IdentifyCommandResponse) agent2.getClientCommandSender().sendSynch(command);
        assert response.isSuccessful() : "Failed to send command from agent2 to agent1";
        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??";

        assert client_metrics1.getNumberSuccessfulCommandsSent() == 2;
        assert client_metrics1.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getNumberSuccessfulCommandsSent() == 1;
        assert client_metrics2.getNumberFailedCommandsSent() == 0;
        assert server_metrics1.getNumberSuccessfulCommandsReceived() == 1;
        assert server_metrics1.getNumberFailedCommandsReceived() == 0;
        assert server_metrics1.getNumberTotalCommandsReceived() == 1;
        assert server_metrics2.getNumberSuccessfulCommandsReceived() == 2;
        assert server_metrics2.getNumberFailedCommandsReceived() == 0;
        assert server_metrics2.getNumberTotalCommandsReceived() == 2;

        response = (IdentifyCommandResponse) agent2.getClientCommandSender().sendSynch(command);
        assert response.isSuccessful() : "Failed to send command from agent2 to agent1";

        assert client_metrics1.getNumberSuccessfulCommandsSent() == 2;
        assert client_metrics1.getNumberFailedCommandsSent() == 0;
        assert client_metrics2.getNumberSuccessfulCommandsSent() == 2;
        assert client_metrics2.getNumberFailedCommandsSent() == 0;
        assert server_metrics1.getNumberSuccessfulCommandsReceived() == 2;
        assert server_metrics1.getNumberFailedCommandsReceived() == 0;
        assert server_metrics1.getNumberTotalCommandsReceived() == 2;
        assert server_metrics2.getNumberSuccessfulCommandsReceived() == 2;
        assert server_metrics2.getNumberFailedCommandsReceived() == 0;
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.client.ClientCommandSenderMetrics

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.