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

Examples of org.rhq.enterprise.communications.command.client.ClientRemotePojoFactory$RemotePojoProxyHandler


            //make the service container understand the requests for plugin container lifecycle events.
            getServiceContainer().addRemotePojo(new PluginContainerLifecycleListener(this),
                PluginContainerLifecycle.class);

            // Get remote pojo's for server access and make them accessible in the configuration object
            ClientRemotePojoFactory factory = m_clientSender.getClientRemotePojoFactory();
            CoreServerService coreServerService = factory.getRemotePojo(CoreServerService.class);
            DiscoveryServerService discoveryServerService = factory.getRemotePojo(DiscoveryServerService.class);
            MeasurementServerService measurementServerService = factory.getRemotePojo(MeasurementServerService.class);
            OperationServerService operationServerService = factory.getRemotePojo(OperationServerService.class);
            ConfigurationServerService configurationServerService = factory
                .getRemotePojo(ConfigurationServerService.class);
            ResourceFactoryServerService resourceFactoryServerSerfice = factory
                .getRemotePojo(ResourceFactoryServerService.class);
            ContentServerService contentServerService = factory.getRemotePojo(ContentServerService.class);
            EventServerService eventServerService = factory.getRemotePojo(EventServerService.class);
            BundleServerService bundleServerService = factory.getRemotePojo(BundleServerService.class);
            DriftServerService driftServerService = factory.getRemotePojo(DriftServerService.class);

            ServerServices serverServices = new ServerServices();
            serverServices.setCoreServerService(coreServerService);
            serverServices.setDiscoveryServerService(discoveryServerService);
            serverServices.setMeasurementServerService(measurementServerService);
View Full Code Here


            if (sender.isSending()) {
                LOG.debug(AgentI18NResourceKeys.NOTIFYING_SERVER_OF_SHUTDOWN);

                String agent_name = getConfiguration().getAgentName();
                ClientRemotePojoFactory pojo_factory = sender.getClientRemotePojoFactory();
                pojo_factory.setSendThrottled(false); // send it immediately, avoid any throttling
                pojo_factory.setTimeout(10000L); // try to be quick about it, if it can't send immediately, fail fast
                CoreServerService remote_pojo = pojo_factory.getRemotePojo(CoreServerService.class);

                remote_pojo.agentIsShuttingDown(agent_name);
            } else {
                LOG.debug(AgentI18NResourceKeys.NOT_NOTIFYING_SERVER_OF_SHUTDOWN);
            }
View Full Code Here

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

        RemotePojoInvocationFuture future = new RemotePojoInvocationFuture();
        ClientRemotePojoFactory factory = agent1.getClientCommandSender().getClientRemotePojoFactory();
        factory.setAsynch(false, future); // false should still honor annotations - we'll make sure that's true in this test
        ITestAnnotatedPojo pojo = factory.getRemotePojo(ITestAnnotatedPojo.class);

        pojo.volatileMethod("first test");
        assert "first test".equals(future.get());
        assert future.isDone();

        long stopwatch = System.currentTimeMillis();
        assert "first test".equals(future.get(10, TimeUnit.SECONDS)); // make sure its still there
        long test_duration = System.currentTimeMillis() - stopwatch;
        assert test_duration < 750L : "get should have returned immediately: " + test_duration;

        assert future.isDone();
        future.reset();
        assert !future.isDone();

        stopwatch = System.currentTimeMillis();
        try {
            future.get(2, TimeUnit.SECONDS);
            assert false : "The get should have timed out";
        } catch (TimeoutException toe) {
        }

        test_duration = System.currentTimeMillis() - stopwatch;
        assert (test_duration > 1900L) && (test_duration < 2500L) : "Should have timed out after 2 seconds: "
            + test_duration;

        // we want to call throwThrowable asynchronously but it isn't annotated that way, so force async
        // calling this isn't enough - all existing proxies remain as-is - this call only affects newly created remote pojo proxies
        factory.setAsynch(true, future);
        factory.setIgnoreAnnotations(true);

        // test throwing an Error
        Error err = new Error("bogus error for testing");

        // side-test - show that the proxy isn't forcing all methods to be async.
        try {
            pojo.throwThrowable(err);
            assert false : "Should have called this synchronously which should have thrown Error";
        } catch (Error error) {
            // to be expected, the remote pojo proxy is still configured to call throwThrowable synchronously
        }

        // now let's get a new remote pojo proxy that is forced to call everything asynchronously
        pojo = factory.getRemotePojo(ITestAnnotatedPojo.class);
        pojo.throwThrowable(err);

        try {
            future.get();
            assert false : "Should have thrown an exception";
View Full Code Here

        test_duration = System.currentTimeMillis() - stopwatch;
        assert test_duration < 7000L : "Send throttling was off - should have returned very fast: " + test_duration;

        // let's ignore annotations and try that one that wanted to explicitly turn off send throttling
        // since we are ignoring the annotations, our invocation will be send throttled
        ClientRemotePojoFactory factory = agent1.getClientCommandSender().getClientRemotePojoFactory();
        factory.setIgnoreAnnotations(true);
        pojo = factory.getRemotePojo(ITestAnnotatedPojo.class);

        stopwatch = System.currentTimeMillis();
        for (int i = 1; i <= 6; i++) {
            assert i == pojo.notSendThrottled(i);
        }
View Full Code Here

            exception_was_thrown = true;
        }

        assert exception_was_thrown : "The method should have timed out and thrown an exception";

        ClientRemotePojoFactory factory = agent1.getClientCommandSender().getClientRemotePojoFactory();
        factory.setIgnoreAnnotations(true);
        pojo = factory.getRemotePojo(ITestAnnotatedPojo.class);

        // since we are ignoring the annotations, our default timeout should be enough for us to succeed
        assert "second".equals(pojo.shortAnnotatedTimeout("second"));

        return;
View Full Code Here

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

        final String[] results = new String[] { null };
        final Throwable[] throwable = new Throwable[] { null };
        final Boolean[] success = new Boolean[] { null };
        ClientRemotePojoFactory factory = agent1.getClientCommandSender().getClientRemotePojoFactory();
        factory.setAsynch(false, new CommandResponseCallback() {
            private static final long serialVersionUID = 1L;

            public void commandSent(CommandResponse response) {
                success[0] = Boolean.valueOf(response.isSuccessful());
                results[0] = (String) response.getResults();
                throwable[0] = response.getException();
                synchronized (success) {
                    success.notify();
                }
            }
        });

        ITestAnnotatedPojo pojo = factory.getRemotePojo(ITestAnnotatedPojo.class);

        // see that the volatile method failed because we haven't started our second server agent
        pojo.volatileMethod("call 1");
        synchronized (success) {
            success.wait(30000L); // this will get notified immediately when our volatile method callback is called with the failure
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.client.ClientRemotePojoFactory$RemotePojoProxyHandler

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.