Package org.rhq.enterprise.communications.command

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


            assert !agent1.getClientCommandSender().isSending() : "we should have been able to turn off the InitializeCallback/connectAgent should therefore not have triggered our listener and started the sender";
            assert agent2.getClientCommandSender().isSending() : "Should have already started the sender";

            // our canary-in-the-mine is the sending mode, the sender goes into sending mode when it detects the server
            IdentifyCommand command = new IdentifyCommand();
            CommandResponse response;

            response = agent2.getClientCommandSender().sendSynch(command);
            assert response.isSuccessful() : "agent2 should have been able to send to agent1: " + response;
            assert agent1.getClientCommandSender().isSending() : "agent2 message should have started agent1 sender";

            // now let's stop the agent1 sender and try again, just to make sure the command listeners work repeatedly
            agent1.getClientCommandSender().stopSending(false);
            assert !agent1.getClientCommandSender().isSending() : "Should not be in sending mode again";
            assert agent2.getClientCommandSender().isSending() : "Should still be started";

            response = agent2.getClientCommandSender().sendSynch(command);
            assert response.isSuccessful() : "agent2 should have been able to send to agent1: " + response;
            assert agent1.getClientCommandSender().isSending() : "agent2 message should have re-started agent1 sender again";

            // now let's entirely shutdown agent1 and try again, just to make sure the command listeners can be rebuilt
            agent1.shutdown();
            assert agent1.getClientCommandSender() == null : "agent1 should be completely shutdown";
            assert agent2.getClientCommandSender().isSending() : "Should still be started";

            agent1.start();
            agent1.getClientCommandSender().getRemoteCommunicator().setInitializeCallback(null);
            assert agent1.getClientCommandSender() != null : "agent1 should be started again";
            assert !agent1.getClientCommandSender().isSending() : "Should still not yet be in sending mode again";
            assert agent2.getClientCommandSender().isSending() : "Should still be started";

            response = agent2.getClientCommandSender().sendSynch(command);
            assert response.isSuccessful() : "agent2 should have been able to send to agent1: " + response;
            assert agent1.getClientCommandSender().isSending() : "agent2 message should have re-started agent1 sender again";
        } finally {
            if (agent1 != null) {
                agent1.shutdown();
            }
View Full Code Here


        response = (IdentifyCommandResponse) agent1.getClientCommandSender().sendSynch(new IdentifyCommand());
        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??";

        CommandResponse generic_response;
        generic_response = agent2.getClientCommandSender().sendSynch(new IdentifyCommand());
        assert !generic_response.isSuccessful() : "Should have failed to send command from agent2 to agent1 since it didn't preprocess the command";
        assert generic_response.getException() != null;

        return;
    }
View Full Code Here

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

        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.2.SP4 doesn't seem to like me doing bi-directional messaging within the same VM
View Full Code Here

     * @return server's invoker locator or <code>null</code> if server could not be identified
     */
    private InvokerLocator attemptToIdentifyServer() {
        try {
            GenericCommandClient client = new GenericCommandClient(m_remoteCommunicator);
            CommandResponse genericResponse = client.invoke(new IdentifyCommand());
            IdentifyCommandResponse identifyResponse = new IdentifyCommandResponse(genericResponse);

            if (identifyResponse.getException() != null) {
                throw identifyResponse.getException();
            }
View Full Code Here

        assert agent2.isStarted() : "agent2 should have been started";

        String stream_data = "Stream this string...";
        InputStream in = new ByteArrayInputStream(stream_data.getBytes());
        GenericCommand test_command = new GenericCommand(SimpleTestStreamService.COMMAND_TYPE, null);
        CommandResponse results = null;
        Long stream_id = null;

        try {
            stream_id = agent1.getServiceContainer().addRemoteInputStream(in);
            test_command.setParameterValue(SimpleTestStreamService.INPUT_STREAM_PARAM, new RemoteInputStream(stream_id,
                agent1.getServiceContainer()));

            results = agent1.getClientCommandSender().sendSynch(test_command);
        } catch (Throwable t) {
            throw new Exception(t);
        }

        assert stream_data.equals(results.getResults()) : "The test should have sent the stream data back in the response";

        // let's wait for the idle timer task to run and make sure it removes the stream now that we have closed it
        Thread.sleep(5250L);
        assert !agent1.getServiceContainer().removeRemoteInputStream(stream_id) : "This should be false because the stream should have been removed by the task already";
View Full Code Here

        assert agent2.isStarted() : "agent2 should have been started";

        String stream_data = "Streaming this string should fail";
        InputStream in = new ByteArrayInputStream(stream_data.getBytes());
        GenericCommand test_command = new GenericCommand(SimpleTestStreamService.COMMAND_TYPE, null);
        CommandResponse results = null;

        try {
            test_command.setParameterValue(SimpleTestStreamService.INPUT_STREAM_PARAM, new RemoteInputStream(in, agent1
                .getServiceContainer()));
            Thread.sleep(5500L); // the timer only runs the task every 5 secs even though our timeout is 1 sec
            results = agent1.getClientCommandSender().sendSynch(test_command);
        } catch (Throwable t) {
            throw new Exception(t);
        }

        assert !results.isSuccessful() : "The test should not have sent the stream data back in the response - the stream service should have timed out";

        return;
    }
View Full Code Here

        assert agent2.isStarted() : "agent2 should have been started";

        String stream_data = "Stream this string...";
        InputStream in = new ByteArrayInputStream(stream_data.getBytes());
        GenericCommand test_command = new GenericCommand(SimpleTestStreamService.COMMAND_TYPE, null);
        CommandResponse results = null;
        Long stream_id = null;

        try {
            stream_id = agent1.getServiceContainer().addRemoteInputStream(in);
            test_command.setParameterValue(SimpleTestStreamService.INPUT_STREAM_PARAM, new RemoteInputStream(stream_id,
                agent1.getServiceContainer()));

            results = agent1.getClientCommandSender().sendSynch(test_command);
        } catch (Throwable t) {
            throw new Exception(t);
        }

        assert stream_data.equals(results.getResults()) : "The test should have sent the stream data back in the response";

        // let's wait for the idle timer task to run and make sure it removes the stream now that we have closed it
        Thread.sleep(5250L);
        assert !agent1.getServiceContainer().removeRemoteInputStream(stream_id) : "This should be false because the stream should have been removed by the task already";
View Full Code Here

        assert agent1.isStarted() : "agent1 should have been started";
        assert agent2.isStarted() : "agent2 should have been started";

        InputStream in = new ByteArrayInputStream(LARGE_STRING_BYTES);
        GenericCommand test_command = new GenericCommand(SimpleTestStreamService.COMMAND_TYPE, null);
        CommandResponse results = null;
        Long stream_id = null;

        try {
            test_command.setParameterValue(SimpleTestStreamService.INPUT_STREAM_PARAM, new RemoteInputStream(in, agent1
                .getServiceContainer()));

            results = agent1.getClientCommandSender().sendSynch(test_command);
        } catch (Throwable t) {
            throw new Exception(ThrowableUtil.getAllMessages(t), t);
        }

        assert LARGE_STRING.equals(results.getResults()) : "The test should have sent the stream data back in the response";

        // let's wait for the idle timer task to run and make sure it removes the stream now that we have closed it
        Thread.sleep(5250L);
        assert !agent1.getServiceContainer().removeRemoteInputStream(stream_id) : "This should be false because the stream should have been removed by the task already";
View Full Code Here

        assert agent1.isStarted() : "agent1 should have been started";
        assert agent2.isStarted() : "agent2 should have been started";

        InputStream in = new FileInputStream(createVeryLargeFile()); // creates a large file in tmp directory
        GenericCommand test_command = new GenericCommand(SimpleTestStreamService.COMMAND_TYPE, null);
        CommandResponse results = null;
        Long stream_id = null;

        try {
            test_command.setParameterValue(SimpleTestStreamService.RETURN_COUNT_ONLY_PARAM, "");
            test_command.setParameterValue(SimpleTestStreamService.INPUT_STREAM_PARAM, new RemoteInputStream(in, agent1
                .getServiceContainer()));

            results = agent1.getClientCommandSender().sendSynch(test_command);
        } catch (Throwable t) {
            throw new Exception(ThrowableUtil.getAllMessages(t), t);
        }

        long response_count = ((Long) results.getResults()).longValue();
        long true_count = m_veryLargeFile.length();
        assert response_count == true_count : "The test should have sent the correct size of the large file ("
            + true_count + "); instead it returned (" + response_count + ")";

        // let's wait for the idle timer task to run and make sure it removes the stream now that we have closed it
View Full Code Here

                        m_clientCommandSender.sendAsynchGuaranteed(cmd, m_proxyHandlerAsyncCallback);
                    } else {
                        m_clientCommandSender.sendAsynch(cmd, m_proxyHandlerAsyncCallback);
                    }
                } else {
                    CommandResponse sendsync_response = m_clientCommandSender.sendSynch(cmd);
                    response = new RemotePojoInvocationCommandResponse(sendsync_response);

                    // throw the exception if one occurred
                    if (response.getException() != null) {
                        throw response.getException();
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.