Package org.jgroups.util

Examples of org.jgroups.util.Promise


        super(name);
    }

    public void setUp() throws Exception {
        super.setUp();
        promise=new Promise();
        routerPort=Utilities.startGossipRouter("127.0.0.1");
    }
View Full Code Here


        super(name);
    }

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

     * 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.connect("testgroup");
        PullPushAdapter ppa= new PullPushAdapter(coordinator,
                                                 new PromisedMessageListener(msgPromise));
        ppa.start();

        channel=new JChannel();
        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();
View Full Code Here

     public void testDisconnectConnectSendTwo_TUNNEL() throws Exception {
        try {
            routerPort = Utilities.startGossipRouter();
            String props=getTUNNELProps(routerPort, routerPort);

            final Promise msgPromise=new Promise();
            JChannel coordinator=new JChannel(props);
            coordinator.connect("testgroup");
            PullPushAdapter ppa=
                    new PullPushAdapter(coordinator,
                                        new PromisedMessageListener(msgPromise));
            ppa.start();

            channel=new JChannel(props);
            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();
View Full Code Here

        final boolean[] received=new boolean[count];
        for(int i=0; i < count; i++) {
            received[i]=false;
        }
        final Promise waitingArea=new Promise();
        long start=System.currentTimeMillis();

        new Thread(new Runnable() {
            public void run() {
                for(int i=0; i < count; i++) {
                    Message msg=new Message(null, localAddrOne, new Integer(i));
                    try {
                        stub.send(msg, groupName);
                        if(i % 2000 == 0)
                            System.out.println("--sent " + i);
                    }
                    catch(Exception e) {
                        waitingArea.setResult(e);
                    }
                }
            }
        }, "Sending Thread").start();


        new Thread(new Runnable() {
            public void run() {
                int cnt=0;
                while(cnt < count) {
                    try {
                        Message msg=stub2.receive();
                        int index=((Integer)msg.getObject()).intValue();
                        received[index]=true;
                        cnt++;
                        if(cnt % 2000 == 0)
                            System.out.println("-- [stub2] received " + cnt);
                    }
                    catch(Exception e) {
                        waitingArea.setResult(e);
                    }
                }
                waitingArea.setResult(Boolean.TRUE);
            }
        }, "Receiving Thread stub2").start();


        new Thread(new Runnable() {
            public void run() {
                int cnt=0;
                while(cnt < count) {
                    try {
                        Message msg=stub.receive();
                        int index=((Integer)msg.getObject()).intValue();
                        received[index]=true;
                        cnt++;
                        if(cnt % 2000 == 0)
                            System.out.println("-- [stub] received " + cnt);
                    }
                    catch(Exception e) {
                        waitingArea.setResult(e);
                    }
                }
                waitingArea.setResult(Boolean.TRUE);
            }
        }, "Receiving Thread stub").start();


        // wait here the stress threads to finish
        Object result=waitingArea.getResult((long)timeout * 1000);
        long stop=System.currentTimeMillis();
        stub2.disconnect();

        int messok=0;
        for(int i=0; i < count; i++) {
View Full Code Here

    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

     * 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

     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

     * 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

        super(name);
    }

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

TOP

Related Classes of org.jgroups.util.Promise

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.