Package org.jgroups.protocols

Examples of org.jgroups.protocols.PingRsp


                // so the member to become singleton member (and thus coord) is the first of all clients
                Set clients=new TreeSet(); // sorted
                clients.add(mbr); // add myself again (was removed by findInitialMembers())
                for(int i=0; i < initial_mbrs.size(); i++) {
                    PingRsp pingRsp=(PingRsp)initial_mbrs.elementAt(i);
                    Address client_addr=pingRsp.getAddress();
                    if(client_addr != null)
                        clients.add(client_addr);
                }
                if(trace)
                    log.trace("clients to choose new coord from are: " + clients);
View Full Code Here


    /**
     * Pings initial members. Removes self before returning vector of initial members.
     * Uses IP multicast or gossiping, depending on parameters.
     */
    void findInitialMembers() {
        PingRsp ping_rsp;

        synchronized(initial_mbrs) {
            initial_mbrs.removeAllElements();
            initial_mbrs_received=false;
            gms.passDown(new Event(Event.FIND_INITIAL_MBRS));
View Full Code Here

    /**
     The coordinator is determined by a majority vote. If there are an equal number of votes for
     more than 1 candidate, we determine the winner randomly.
     */
    private Address determineCoord(Vector mbrs) {
        PingRsp mbr;
        Hashtable votes;
        int count, most_votes;
        Address winner=null, tmp;

        if(mbrs == null || mbrs.size() < 1)
View Full Code Here

    public void testHeaders() throws Exception {
        Address dest, src;
        dest=new IpAddress("228.1.2.3", 5555);
        src=new IpAddress("127.0.0.1", 6666);
        Message msg=new Message(dest, src, "Hello world".getBytes());
        PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ, new PingRsp(src, src, true));
        msg.putHeader("ping-header", hdr);
        UdpHeader udp_hdr=new UdpHeader("bla");
        msg.putHeader("udp-header", udp_hdr);
        stream(msg);
    }
View Full Code Here

        dest=new IpAddress("228.1.2.3", 5555);
        dest.setAdditionalData("foo".getBytes());
        src=new IpAddress("127.0.0.1", 6666);
        src.setAdditionalData("foobar".getBytes());
        Message msg=new Message(dest, src, "Hello world".getBytes());
        PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ, new PingRsp(src, src, false));
        msg.putHeader("ping-header", hdr);
        UdpHeader udp_hdr=new UdpHeader("bla");
        msg.putHeader("udp-header", udp_hdr);
        stream(msg);
    }
View Full Code Here

    public void testDifferentAddress() throws Exception {
        Address dest, src;
        dest=new WanPipeAddress("foo");
        src=new WanPipeAddress("foobar");
        Message msg=new Message(dest, src, "Hello world".getBytes());
        PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ, new PingRsp(src, src, false));
        msg.putHeader("ping-header", hdr);
        UdpHeader udp_hdr=new UdpHeader("bla");
        msg.putHeader("udp-header", udp_hdr);
        stream(msg);
    }
View Full Code Here


    /** UpHandler interface */
    public void up(Event evt) {
        Vector v;
        PingRsp rsp;

        if(evt.getType() == Event.FIND_INITIAL_MBRS_OK) {
            v=(Vector)evt.getArg();

            System.out.println("Found " + v.size() + " members");
View Full Code Here

    }


    static void verifyCoordinator(Vector rsps) {
        Hashtable votes=new Hashtable()// coord address, list of members who voted for this guy
        PingRsp rsp;
        Vector v;
        Address coord, mbr;

        for(int i=0; i < rsps.size(); i++) {
            rsp=(PingRsp)rsps.elementAt(i);
            coord=rsp.getCoordAddress();
            mbr=rsp.getAddress();
            v=(Vector)votes.get(coord);
            if(v == null) {
                v=new Vector();
                votes.put(coord, v);
            }
View Full Code Here

        try {
            channel.connect(groupname);
            List<PingRsp> responses = (List<PingRsp>) channel.downcall(new Event(Event.FIND_INITIAL_MBRS));
            for(int i=0; i < responses.size(); i++) {
              PingRsp rsp=responses.get(i);
                System.out.println("Rsp #" + (i + 1) + ": " + rsp);
            }

            if(!responses.isEmpty())
                verifyCoordinator(responses);
View Full Code Here

        }
    }

    static void verifyCoordinator(List<PingRsp> rsps) {
        Hashtable votes=new Hashtable()// coord address, list of members who voted for this guy
        PingRsp rsp;
        Vector v;
        Address coord, mbr;

        for(int i=0; i < rsps.size(); i++) {
            rsp=rsps.get(i);
            coord=rsp.getCoordAddress();
            mbr=rsp.getAddress();
            v=(Vector)votes.get(coord);
            if(v == null) {
                v=new Vector();
                votes.put(coord, v);
            }
View Full Code Here

TOP

Related Classes of org.jgroups.protocols.PingRsp

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.