Examples of Promise


Examples of org.jgroups.util.Promise

     * pbcast.NAKACK bug, which used to leave pbcast.NAKACK in a broken state
     * after DISCONNECT. Because of this problem, the channel couldn't be used
     * to multicast messages.
     **/
    public void testDisconnectConnectSendTwo_Default() throws Exception {
        final Promise msgPromise=new Promise();
        JChannel coordinator=new JChannel();
        coordinator.setReceiver(new PromisedMessageListener(msgPromise));
        coordinator.connect("testgroup");

        channel=new JChannel();
        channel.connect("testgroup1");
        channel.disconnect();
        channel.connect("testgroup");

        channel.send(new Message(null, null, "payload"));

        Message msg=(Message)msgPromise.getResult(20000);
        assertNotNull(msg);
        assertEquals("payload", msg.getObject());

        coordinator.close();
    }
View Full Code Here

Examples of org.jgroups.util.Promise

     public void testDisconnectConnectSendTwo_TUNNEL() throws Exception {
        GossipRouter router=null;
        try {
            router=new GossipRouter();
            router.start();
            final Promise msgPromise=new Promise();
            JChannel coordinator=createChannel();
            setProps(coordinator);
            coordinator.setReceiver(new PromisedMessageListener(msgPromise));
            coordinator.connect("testgroup");

            channel=createChannel();
            setProps(channel);
            channel.connect("testgroup1");
            channel.disconnect();
            channel.connect("testgroup");

            channel.send(new Message(null, null, "payload"));

            Message msg=(Message)msgPromise.getResult(20000);
            assertNotNull(msg);
            assertEquals("payload", msg.getObject());
            channel.close();
            coordinator.close();
        }
View Full Code Here

Examples of org.jgroups.util.Promise

     * bug, which used to leave pbcast.NAKACK in a broken state after
     * DISCONNECT. Because of this problem, the channel couldn't be used to
     * multicast messages.
     **/
    public void testDisconnectConnectSendTwo() throws Exception {
        final Promise msgPromise=new Promise();
        Channel coordinator=createChannel("A");
        coordinator.connect("testgroup");
        PullPushAdapter ppa=
                new PullPushAdapter(coordinator,
                                    new PromisedMessageListener(msgPromise));
        ppa.start();

        channel=createChannel("A");
        channel.connect("testgroup1");
        channel.disconnect();
        channel.connect("testgroup");
        channel.send(new Message(null, null, "payload"));
        Message msg=(Message)msgPromise.getResult(20000);
        assertTrue(msg != null);
        assertEquals("payload", msg.getObject());
        ppa.stop();
        coordinator.close();
        channel.close();
View Full Code Here

Examples of org.jgroups.util.Promise

        super(name);
    }

    public void setUp() throws Exception {
        super.setUp();
        promise=new Promise();
        router=new GossipRouter();
        router.start();
    }
View Full Code Here

Examples of org.jgroups.util.Promise

        super(name);
    }

    public void setUp() throws Exception {
        super.setUp();
        p=new Promise();
    }
View Full Code Here

Examples of org.jgroups.util.Promise

        assertTrue(future.isDone());
    }


    public void testImmediateExecution() {
        Promise p=new Promise();
        ImmediateTask task=new ImmediateTask(p);
        timer.execute(task);
        try {
            long start=System.currentTimeMillis(), stop;
            p.getResultWithTimeout(5);
            stop=System.currentTimeMillis();
            System.out.println("task took " + (stop-start) + "ms");
        }
        catch(TimeoutException e) {
            fail("ran into timeout - task should have executed immediately");
View Full Code Here

Examples of org.jgroups.util.Promise

        if(stopped == false) return;



        if(start_promise == null)
            start_promise=new Promise();
        else
            start_promise.reset();

        down(new Event(Event.START));
        start_result=start_promise.getResult(0);
View Full Code Here

Examples of org.jgroups.util.Promise

     */
    public void stopStack() {
        if(stopped) return;

        if(stop_promise == null)
            stop_promise=new Promise();
        else
            stop_promise.reset();

        down(new Event(Event.STOP));
        stop_promise.getResult(5000);
View Full Code Here

Examples of org.jgroups.util.Promise

    public boolean setProperties(Properties props) {
        super.setProperties(props);

        use_flush=Util.parseBoolean(props, "use_flush", false);       
        flush_promise=new Promise();
       
        flush_timeout = Util.parseLong(props, "flush_timeout", flush_timeout);      
        if(props.size() > 0) {
            log.error("the following properties are not recognized: " + props);
            return false;
View Full Code Here

Examples of org.jgroups.util.Promise

        p.setResult(22);
        assert p.getResult() == 22;
    }

    public static void testGetResultNoTimeout() {
        final Promise p=new Promise();
        Object result;
        new ResultSetter(p, 500).start();
        result=p.getResult(0);
        Assert.assertEquals(Boolean.TRUE, result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.