Package org.jgroups

Examples of org.jgroups.Message


        PhysicalAddress physical_addr=(PhysicalAddress)down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
        PingData data=new PingData(local_addr, null, false, UUID.get(local_addr), Arrays.asList(physical_addr));

        for (Address mbr_addr : initial_mbrs) {
            Message msg = new Message(mbr_addr);
            msg.setFlag(Message.OOB);
            PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ, data, cluster_name);
            hdr.return_view_only = return_views_only;
            msg.putHeader(this.id, hdr);
            if (log.isTraceEnabled())
                log.trace("[FIND_INITIAL_MBRS] sending GET_MBRS_REQ request to " + mbr_addr);           
            down_prot.down(new Event(Event.MSG, msg));
        }
    }
View Full Code Here


        int received_msgs=receiveMessages(NUM_MSGS, TIMEOUT);
        assert received_msgs >= NUM_MSGS;
    }

    private void sendMessages(int num) {
        Message msg;
        for(int i=0; i < num; i++) {
            try {
                msg=new Message();
                channel.send(msg);
                System.out.print(i + " ");
            }
            catch(Throwable t) {
                assert false : "could not send message #" + i;
View Full Code Here

                corr.sendRequest(requestId, targetMembers, request_msg, options.getMode() == GET_NONE? null : this, options);
            }
            else {
                if(options.getAnycasting()) {                                                         
                    for(Address mbr: targetMembers) {
                        Message copy=request_msg.copy(true);
                        copy.setDest(mbr);
                        transport.send(copy);
                    }
                }
                else {
                    transport.send(request_msg);
View Full Code Here

            ch2.setReceiver(receiver);
            ch1.connect(cluster_name);
            ch2.connect(cluster_name);

            if(mcast)
                ch1.send(new Message(null, null, buf));
            else {
                Address dest=ch2.getAddress();
                ch1.send(new Message(dest, null, buf));
            }

            Util.sleep(500); // msgs are sent asynchronously, give ch2 some time to receive them
            List<Message> list=receiver.getMsgs();
            assert !list.isEmpty();
            Message msg=list.get(0);
            UUID src=(UUID)msg.getSrc();
            assert src != null;
            assert src.getAdditionalData() != null;
            assert src.getAdditionalData().length == 4;
        }
        finally {
View Full Code Here

                c.connect("ChannelConcurrencyTest");
                if(useDispatcher && c.isConnected()) {
                    final MessageDispatcher md=new MessageDispatcher(c, null, null, new MyHandler());
                    for(int i=0;i < 10;i++) {
                        final RspList rsp=md.castMessage(null,
                                                         new Message(null, null, i),
                                                         GroupRequest.GET_ALL,
                                                         2500);
                        for(Object o:rsp.getResults()) {
                            assertEquals("Wrong result received at " + c.getAddress(), i, o);
                        }
View Full Code Here

    static final short PING_ID=102;
    static final short NAKACK_ID=103;


    public static void testFlags() {
        Message m1=new Message();
        assert !(m1.isFlagSet(Message.OOB));
        try {
            m1.setFlag((byte)1002);
            assert false : "1002 is not a byte value";
        }
        catch(IllegalArgumentException ex) {
        }
        assert m1.getFlags() == 0;
    }
View Full Code Here

        assert m1.getFlags() == 0;
    }


    public static void testFlags2() {
        Message m1=new Message();
        m1.setFlag(Message.OOB);
        assert m1.isFlagSet(Message.OOB);
        assert Message.OOB == (m1.getFlags() & Message.OOB);
        assert !(m1.isFlagSet(Message.DONT_BUNDLE));
        Assert.assertNotSame((m1.getFlags() & Message.DONT_BUNDLE), Message.DONT_BUNDLE);
    }
View Full Code Here

        assert !(m1.isFlagSet(Message.DONT_BUNDLE));
        Assert.assertNotSame((m1.getFlags() & Message.DONT_BUNDLE), Message.DONT_BUNDLE);
    }

    public static void testFlags3() {
        Message msg=new Message();
        assert msg.isFlagSet(Message.OOB) == false;
        msg.setFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB);
        msg.setFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB);
    }
View Full Code Here

        assert msg.isFlagSet(Message.OOB);
    }


    public static void testClearFlags() {
        Message msg=new Message();
        msg.setFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB);
        msg.clearFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB) == false;
        msg.clearFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB) == false;
        msg.setFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB);
    }
View Full Code Here

        assert msg.isFlagSet(Message.OOB);
    }


    public static void testClearFlags2() {
        Message msg=new Message();
        msg.setFlag(Message.OOB);
        msg.setFlag(Message.NO_FC);
        assert msg.isFlagSet(Message.DONT_BUNDLE) == false;
        assert msg.isFlagSet(Message.OOB);
        assert msg.isFlagSet(Message.NO_FC);

        msg.clearFlag(Message.OOB);
        assert msg.isFlagSet(Message.OOB) == false;
        msg.setFlag(Message.DONT_BUNDLE);
        assert msg.isFlagSet(Message.DONT_BUNDLE);
        assert msg.isFlagSet(Message.NO_FC);
        msg.clearFlag(Message.NO_FC);
        assert msg.isFlagSet(Message.NO_FC) == false;
        msg.clearFlag(Message.NO_FC);
        assert msg.isFlagSet(Message.NO_FC) == false;
        msg.clearFlag(Message.DONT_BUNDLE);
        msg.clearFlag(Message.OOB);
        assert msg.getFlags() == 0;
        assert msg.isFlagSet(Message.OOB) == false;
        assert msg.isFlagSet(Message.DONT_BUNDLE) == false;
        assert msg.isFlagSet(Message.NO_FC) == false;
        msg.setFlag(Message.DONT_BUNDLE);
        assert msg.isFlagSet(Message.DONT_BUNDLE);
        msg.setFlag(Message.DONT_BUNDLE);
        assert msg.isFlagSet(Message.DONT_BUNDLE);
    }
View Full Code Here

TOP

Related Classes of org.jgroups.Message

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.