Package org.jgroups.util

Examples of org.jgroups.util.Rsp


        stop=System.currentTimeMillis();
        System.out.println("rsps:\n" + rsps);
        System.out.println("call took " + (stop-start) + " ms");
        assertNotNull(rsps);
        assertEquals(2, rsps.size());
        Rsp rsp=rsps.get(ch.getLocalAddress());
        assertNotNull(rsp);
        Object ret=rsp.getValue();
        assertNull(ret);


        rsp=rsps.get(ch2.getLocalAddress());
        assertNotNull(rsp);
        ret=rsp.getValue();
        assertNull(ret);
    }
View Full Code Here


        stop=System.currentTimeMillis();
        System.out.println("rsps:\n" + rsps);
        System.out.println("call took " + (stop-start) + " ms");
        assertNotNull(rsps);
        assertEquals(2, rsps.size());
        Rsp rsp=rsps.get(ch.getLocalAddress());
        assertNotNull(rsp);
        byte[] ret=(byte[])rsp.getValue();
        assertEquals(size, ret.length);

        rsp=rsps.get(ch2.getLocalAddress());
        assertNotNull(rsp);
        ret=(byte[])rsp.getValue();
        assertEquals(size, ret.length);
    }
View Full Code Here

        System.out.println("invoking RPC on shunned member");
        rsps=disp2.callRemoteMethods(null, "getCurrentTime", null, (Class[])null, GroupRequest.GET_ALL, 10000);
        System.out.println(">> rsps:\n" + rsps);
        assertEquals(2, rsps.size());
        for(Map.Entry<Address, Rsp> entry: rsps.entrySet()) {
            Rsp rsp=entry.getValue();
            assertFalse(rsp.wasSuspected());
            assertTrue(rsp.wasReceived());
        }

        c1.setReceiver(null);
        c2.setReceiver(null);
        c1.clearChannelListeners();
View Full Code Here

     */
    public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException {
        Vector mbrs=new Vector();
        RspList rsp_list=null;
        Object dest=msg.getDest();
        Rsp rsp;
        GroupRequest _req=null;

        if(dest == null) {
            if(log.isErrorEnabled())
                log.error("the message's destination is null, cannot send message");
            return null;
        }

        mbrs.addElement(dest);   // dummy membership (of destination address)

        _req=new GroupRequest(msg, corr, mbrs, mode, timeout, 0);
        _req.setCaller(local_addr);
        try {
            _req.execute();
        }
        catch(Exception t) {
            throw new RuntimeException("failed executing request " + _req, t);
        }

        if(mode == GroupRequest.GET_NONE) {
            return null;
        }

        rsp_list=_req.getResults();

        if(rsp_list.isEmpty()) {
            if(log.isWarnEnabled())
                log.warn(" response list is empty");
            return null;
        }
        if(rsp_list.size() > 1) {
            if(log.isWarnEnabled())
                log.warn("response list contains more that 1 response; returning first response !");
        }
        rsp=(Rsp)rsp_list.elementAt(0);
        if(rsp.wasSuspected()) {
            throw new SuspectedException(dest);
        }
        if(!rsp.wasReceived()) {
            throw new TimeoutException("timeout sending message to " + dest);
        }
        return rsp.getValue();
    }
View Full Code Here

        a1=new IpAddress(1111);
        a2=new IpAddress(2222);
        a3=new IpAddress(3333);
        a4=new IpAddress(4444);
        a5=new IpAddress(5555);
        rsp1=new Rsp(a1);
        rsp2=new Rsp(a2, true);
        rsp3=new Rsp(a3, "hello world");
        rsp4=new Rsp(a4, Boolean.TRUE);
        rsp5=new Rsp(a5, true);
        rl.put(a1, rsp1);
        rl.put(a2, rsp2);
        rl.put(a3, rsp3);
        rl.put(a4, rsp4);
        rl.put(a5, rsp5);
View Full Code Here

        assertTrue(rl.containsValue(rsp1));
        assertTrue(rl.containsValue(rsp3));
    }

    public void testGet() {
        Rsp rsp=(Rsp)rl.get(a1);
        assertEquals(rsp, rsp1);
        rsp=(Rsp)rl.get(a3);
        assertEquals(rsp, rsp3);
    }
View Full Code Here

        rsp=(Rsp)rl.get(a3);
        assertEquals(rsp, rsp3);
    }

    public void testPut() {
        Rsp rsp;
        rsp=(Rsp)rl.put(new IpAddress(6666), new Rsp(new IpAddress(6666), true));
        assertNull(rsp);
        rsp=(Rsp)rl.put(a2, rsp2);
        assertEquals(rsp, rsp2);
        assertEquals(6, rl.size());
    }
View Full Code Here

        assertEquals(rsp, rsp2);
        assertEquals(6, rl.size());
    }

    public void testRemove() {
        Rsp rsp;
        rsp=(Rsp)rl.remove(new IpAddress(6666));
        assertNull(rsp);
        rsp=(Rsp)rl.remove(a2);
        assertEquals(rsp, rsp2);
        assertEquals(4, rl.size());
View Full Code Here

    }

    public void testAddRsp() {
        rl.addRsp(new IpAddress(6666), new Integer(322649));
        assertEquals(6, rl.size());
        Rsp rsp=(Rsp)rl.get(new IpAddress(6666));
        assertNotNull(rsp);
        assertTrue(rsp.wasReceived());
        assertFalse(rsp.wasSuspected());
        assertEquals(new Integer(322649), rsp.getValue());
    }
View Full Code Here

    }

    public void testAddRsp2() {
        rl.addRsp(a1, new Integer(322649));
        assertEquals(5, rl.size());
        Rsp rsp=(Rsp)rl.get(a1);
        assertNotNull(rsp);
        assertTrue(rsp.wasReceived());
        assertFalse(rsp.wasSuspected());
        assertEquals(new Integer(322649), rsp.getValue());
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.Rsp

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.