Package org.jgroups

Examples of org.jgroups.Message


        String messageText="hello this is a test message";
        Cipher cipher=encrypt2.getSymEncodingCipher();
        byte[] encodedBytes=cipher.doFinal(messageText.getBytes());
        assert !new String(encodedBytes).equals(messageText);

        Message msg=new Message(null, null, encodedBytes);
        Event event=new Event(Event.MSG, msg);
        encrypt.up(event);
        assert observer.getUpMessages().isEmpty();

View Full Code Here


        encrypt.init();

        MockObserver observer=new MockObserver();
        encrypt.setObserver(observer);
        encrypt.keyServer=true;
        Message msg=new Message(null, null, null);
        Event event=new Event(Event.MSG, msg);
        encrypt.up(event);
        assert observer.getUpMessages().size() == 1;
    }
View Full Code Here

    }

    public Object up(Event evt) {
        switch(evt.getType()) {
            case Event.MSG:
                Message msg=(Message)evt.getArg();
                LockingHeader hdr=(LockingHeader)msg.getHeader(id);
                if(hdr == null)
                    break;

                Request req=(Request)msg.getObject();
                if(log.isTraceEnabled())
                    log.trace("[" + local_addr + "] <-- [" + msg.getSrc() + "] " + req);
                switch(req.type) {
                    case GRANT_LOCK:
                    case RELEASE_LOCK:
                        handleLockRequest(req);
                        break;
                    case LOCK_GRANTED:
                        handleLockGrantedResponse(req.lock_name, req.owner, msg.getSrc());
                        break;
                    case LOCK_DENIED:
                        handleLockDeniedResponse(req.lock_name, req.owner);
                        break;
                    case CREATE_LOCK:
View Full Code Here

    abstract protected void sendDeleteAwaitConditionRequest(String lock_name, Owner owner);


    protected void sendRequest(Address dest, Type type, String lock_name, Owner owner, long timeout, boolean is_trylock) {
        Request req=new Request(type, lock_name, owner, timeout, is_trylock);
        Message msg=new Message(dest, null, req);
        msg.putHeader(id, new LockingHeader());
        if(bypass_bundling)
            msg.setFlag(Message.DONT_BUNDLE);
        if(log.isTraceEnabled())
            log.trace("[" + local_addr + "] --> [" + (dest == null? "ALL" : dest) + "] " + req);
        try {
            down_prot.down(new Event(Event.MSG, msg));
        }
View Full Code Here

    }


    protected void sendLockResponse(Type type, Owner dest, String lock_name) {
        Request rsp=new Request(type, lock_name, dest, 0);
        Message lock_granted_rsp=new Message(dest.getAddress(), null, rsp);
        lock_granted_rsp.putHeader(id, new LockingHeader());
        if(bypass_bundling)
            lock_granted_rsp.setFlag(Message.DONT_BUNDLE);

        if(log.isTraceEnabled())
            log.trace("[" + local_addr + "] --> [" + dest.getAddress() + "] " + rsp);

        try {
View Full Code Here

    }


    protected void sendSignalResponse(Owner dest, String lock_name) {
        Request rsp=new Request(Type.SIG_RET, lock_name, dest, 0);
        Message lock_granted_rsp=new Message(dest.getAddress(), null, rsp);
        lock_granted_rsp.putHeader(id, new LockingHeader());
        if(bypass_bundling)
            lock_granted_rsp.setFlag(Message.DONT_BUNDLE);

        if(log.isTraceEnabled())
            log.trace("[" + local_addr + "] --> [" + dest.getAddress() + "] " + rsp);

        try {
View Full Code Here

        setProps(channel);
        channel.connect("DisconnectTest.testgroup-1");
        channel.disconnect();
        channel.connect(GROUP);

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

        Message msg=msgPromise.getResult(20000);
        assert msg != null;
        assert "payload".equals(msg.getObject());
    }
View Full Code Here

        setProps(channel);
        channel.connect("DisconnectTest.testgroup-1");
        channel.disconnect();
        channel.connect(GROUP);

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

        Message msg=msgPromise.getResult(20000);
        assert msg != null;
        assert "payload".equals(msg.getObject());
    }
View Full Code Here


   
    private void sendLeaveResponses(Collection<Address> leaving_members) {
        for(Address address:leaving_members){
            Message msg=new Message(address, null, null); // send an ack to the leaving member
            msg.setFlag(Message.OOB);
            GMS.GmsHeader hdr=new GMS.GmsHeader(GMS.GmsHeader.LEAVE_RSP);
            msg.putHeader(gms.getId(), hdr);
            gms.getDownProtocol().down(new Event(Event.MSG, msg));
        }      
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public Object down(Event evt) {
        switch(evt.getType()) {
            case Event.MSG:
                Message msg=(Message)evt.getArg();
                if(msg.isFlagSet(Message.NO_FC))
                    break;

                Address dest=msg.getDest();
                boolean multicast=dest == null || dest.isMulticastAddress();
                boolean handle_multicasts=handleMulticastMessage();
                boolean process=(handle_multicasts && multicast) || (!handle_multicasts && !multicast);
                if(!process)
                    break;

                int length=msg.getLength();
                if(length == 0)
                    break;

                if(ignore_synchronous_response && ignore_thread.get()) { // JGRP-465
                    if(log.isTraceEnabled())
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.