Package org.jgroups.util

Examples of org.jgroups.util.Responses


        while(!leaving) {
            if(installViewIfValidJoinRsp(join_promise, false))
                return;

            long start=System.currentTimeMillis();
            Responses responses=(Responses)gms.getDownProtocol().down(Event.FIND_INITIAL_MBRS_EVT);

            // Sept 2008 (bela): break if we got a belated JoinRsp (https://jira.jboss.org/jira/browse/JGRP-687)
            if(installViewIfValidJoinRsp(join_promise, false))
                return;

            responses.waitFor(gms.join_timeout);
            responses.done();
            long diff=System.currentTimeMillis() - start;
            if(responses.isEmpty()) {
                log.trace("%s: no members discovered after %d ms: creating cluster as first member", gms.local_addr, diff);
                becomeSingletonMember(mbr);
                return;
            }
            log.trace("%s: discovery took %d ms, members: %s", gms.local_addr, diff, responses);
View Full Code Here


                  .setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
                down_prot.down(new Event(Event.MSG, discovery_req));
                return;
            }

            Responses rsps=(Responses)down_prot.down(Event.FIND_MBRS_EVT);
            rsps.waitFor(discovery_timeout); // return immediately if done
            if(rsps.isEmpty())
                return;

            log.trace("discovery protocol returned %d responses: %s", rsps.size(), rsps);
            for(PingData rsp: rsps) {
                PhysicalAddress addr=rsp.getPhysicalAddr();
                if(addr == null) continue;
                Message discovery_req=new Message(addr).putHeader(id, new MergeHeader(MergeHeader.REQ, null))
                  .setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
View Full Code Here

        }
    }


    public void testAddResponses() throws Exception {
        Responses rsps=new Responses(10, true);
        System.out.println("rsps = " + rsps);
        assert !rsps.isDone();
        for(int i=0; i < 5; i++)
            rsps.addResponse(new PingData(addrs[i], true, names[i], phys_addrs[i]), false);
        System.out.println("rsps = " + rsps);
        assert !rsps.isDone();
        assert !rsps.waitFor(500);

        for(int i=0; i < 5; i++)
            assert rsps.containsResponseFrom(addrs[i]);
        assert !rsps.containsResponseFrom(addrs[5]);

        for(int i=0; i < 5; i++)
            rsps.addResponse(new PingData(addrs[i], true, names[i], phys_addrs[i]), false);
        System.out.println("rsps = " + rsps);
        assert !rsps.isDone() && rsps.size() == 5;

        for(int i=0; i < 5; i++)
            rsps.addResponse(new PingData(addrs[i], true, names[i], phys_addrs[i]), true);
        System.out.println("rsps = " + rsps);
        assert !rsps.isDone() && rsps.size() == 5;

        for(int i=5; i < 10; i++)
            rsps.addResponse(new PingData(addrs[i], true, names[i], phys_addrs[i]), false);
        System.out.println("rsps = " + rsps);
        assert rsps.isDone() && rsps.size() == 10;
        assert rsps.waitFor(60000);
    }
View Full Code Here

        assert rsps.isDone() && rsps.size() == 10;
        assert rsps.waitFor(60000);
    }

    public void testContainsResponse() {
        Responses rsps=new Responses(10, true);
        assert !rsps.isDone();
        for(int i=0; i<5;i++)
            rsps.addResponse(new PingData(addrs[i], true,names[i], phys_addrs[i]), false);
        System.out.println("rsps = "+rsps);
        assert rsps.containsResponseFrom(addrs[3]);
        PingData rsp=rsps.findResponseFrom(addrs[3]);
        assert rsp != null && rsp.getAddress().equals(addrs[3]);
    }
View Full Code Here

        PingData rsp=rsps.findResponseFrom(addrs[3]);
        assert rsp != null && rsp.getAddress().equals(addrs[3]);
    }

    public void testResize() throws Exception {
        Responses rsps=new Responses(5, true, 3);
        for(int i=0; i < 5; i++)
            rsps.addResponse(new PingData(addrs[i], true,names[i],phys_addrs[i]), false);
        assert rsps.size() == 5;
    }
View Full Code Here

            rsps.addResponse(new PingData(addrs[i], true,names[i],phys_addrs[i]), false);
        assert rsps.size() == 5;
    }

    public void testSizeOfOne() {
        Responses rsps=new Responses(1, true, 1);
        rsps.addResponse(new PingData(addrs[0],true,names[0],phys_addrs[0]),false);
        assert rsps.isDone();
    }
View Full Code Here

        rsps.addResponse(new PingData(addrs[0],true,names[0],phys_addrs[0]),false);
        assert rsps.isDone();
    }

    public void testBreakOnCoordRsp() {
        Responses rsps=new Responses(true);
        rsps.addResponse(new PingData(addrs[0],true,names[0],phys_addrs[0]), false);
        assert !rsps.isDone();

        rsps.addResponse(new PingData(addrs[1],true,names[1],phys_addrs[1]).coord(true), false);
        System.out.println("rsps = " + rsps);
        assert rsps.isDone();
    }
View Full Code Here

        System.out.println("rsps = " + rsps);
        assert rsps.isDone();
    }

    public void testClear() {
        Responses rsps=new Responses(10, true);
        System.out.println("rsps = " + rsps);
        for(int i=0; i < 5; i++)
            rsps.addResponse(new PingData(addrs[i], true,names[i],phys_addrs[i]), false);
        System.out.println("rsps = " + rsps);
        assert rsps.size() == 5;
        assert !rsps.isDone();
        rsps.clear();
        System.out.println("rsps = " + rsps);
        assert rsps.isEmpty();
        assert rsps.isDone();
    }
View Full Code Here

        assert rsps.isEmpty();
        assert rsps.isDone();
    }

    public void testWaitFor() throws Exception {
        final Responses rsps=new Responses(5, true);
        boolean done=rsps.waitFor(500);
        assert !done;
        long start=System.currentTimeMillis();
        new Thread() {
            public void run() {
                Util.sleep(500);
                for(int i=5; i < 10; i++)
                    rsps.addResponse(new PingData(addrs[i],true,names[i],phys_addrs[i]), false);
            }
        }.start();

        done=rsps.waitFor(20000);
        long time=System.currentTimeMillis() - start;
        System.out.printf("rsps (in %d ms) = %s\n", time, rsps);
        assert done;
        assert rsps.size() == 5;
    }
View Full Code Here

        assert done;
        assert rsps.size() == 5;
    }

    public void testWaitFor2() throws Exception {
        final Responses rsps=new Responses(5, true);
        boolean done=rsps.waitFor(500);
        assert !done;
        long start=System.currentTimeMillis();
        new Thread() {
            public void run() {
                Util.sleep(500);
                for(int i=0; i < 2; i++)
                    rsps.addResponse(new PingData(addrs[i],true,names[i],phys_addrs[i]), false);
                rsps.addResponse(new PingData(addrs[3], true, names[3], phys_addrs[3]).coord(true), false);
            }
        }.start();

        done=rsps.waitFor(20000);
        long time=System.currentTimeMillis() - start;
        System.out.printf("rsps (in %d ms) = %s\n", time, rsps);
        assert done;
        assert rsps.size() == 3;
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.Responses

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.