Package org.jgroups.util

Examples of org.jgroups.util.Rsp


                                                new Class[]{String.class},
                                                GroupRequest.GET_ALL, 10000);

                Float val=null;
                for(int i=0; i < rsp_list.size(); i++) {
                    Rsp rsp=(Rsp)rsp_list.elementAt(i);
                    Object obj=rsp.getValue();
                    if(obj == null || obj instanceof Throwable)
                        continue;
                    val=(Float)obj;
                    break;
                }

                if(val != null) {
                    value_field.setText(val.toString());
                    clearMsg();
                }
                else {
                    value_field.setText("");
                    showMsg("Value for " + stock_name + " not found");
                }
            }
            else
                if(command.equals("Set")) {
                    String stock_name=stock_field.getText();
                    String stock_val=value_field.getText();
                    if(stock_name == null || stock_val == null || stock_name.length() == 0 ||
                            stock_val.length() == 0) {
                        showMsg("Stock name and value have to be present to enter a new value");
                        return;
                    }
                    Float val=new Float(stock_val);
                    disp.callRemoteMethods(null, "setQuote", new Object[]{stock_name, val},
                                           new Class[]{String.class, Float.class},
                                           GroupRequest.GET_FIRST, 0);

                    showMsg("Stock " + stock_name + " set to " + val);
                }
                else
                    if(command.equals("All")) {
                        listbox.removeAll();
                        showMsg("Getting all stocks:");
                        rsp_list=disp.callRemoteMethods(null, "getAllStocks",
                                                        null, (Class[])null,
                                                        GroupRequest.GET_ALL, 5000);

                        System.out.println("rsp_list is " + rsp_list);

                        Hashtable all_stocks=null;
                        for(int i=0; i < rsp_list.size(); i++) {
                            Rsp rsp=(Rsp)rsp_list.elementAt(i);
                            Object obj=rsp.getValue();
                            if(obj == null || obj instanceof Throwable)
                                continue;
                            all_stocks=(Hashtable)obj;
                            break;
                        }
View Full Code Here


     * <code>execute()</code> returns.
     */
    public void receiveResponse(Object response_value, Address sender) {
        if(done)
            return;
        Rsp rsp=requests.get(sender);
        if(rsp == null)
            return;

        RspFilter rsp_filter=options.getRspFilter();
        boolean responseReceived=false;

        lock.lock();
        try {
            if(!rsp.wasReceived()) {
                if((responseReceived=(rsp_filter == null) || rsp_filter.isAcceptable(response_value, sender)))
                    rsp.setValue(response_value);
                rsp.setReceived(responseReceived);
            }
            if(responseReceived)
                num_received++;
            done=rsp_filter == null? responsesComplete() : !rsp_filter.needMoreResponses();
            if(responseReceived || done)
View Full Code Here

    public void suspect(Address suspected_member) {
        if(suspected_member == null)
            return;

        boolean changed=false;
        Rsp rsp=requests.get(suspected_member);
        if(rsp !=  null) {
            if(rsp.setSuspected(true)) {
                rsp.setValue(null);
                changed=true;
                lock.lock();
                try {
                    num_suspected++;
                    completed.signalAll();
View Full Code Here

        lock.lock();
        try {
            for(Map.Entry<Address,Rsp> entry: requests.entrySet()) {
                Address mbr=entry.getKey();
                if(!mbrs.contains(mbr)) {
                    Rsp rsp=entry.getValue();
                    rsp.setValue(null);
                    if(rsp.setSuspected(true)) {
                        num_suspected++;
                        changed=true;
                    }
                }
            }
View Full Code Here

        if(!requests.isEmpty()) {
            ret.append(", entries:\n");
            for(Map.Entry<Address,Rsp> entry: requests.entrySet()) {
                Address mbr=entry.getKey();
                Rsp rsp=entry.getValue();
                ret.append(mbr).append(": ").append(rsp).append("\n");
            }
        }
        return ret.toString();
    }
View Full Code Here


    /* --------------------------------- Private Methods -------------------------------------*/

    private void setTarget(Address mbr) {
        requests.put(mbr, new Rsp(mbr));
        num_not_received=1;
    }
View Full Code Here

        num_not_received=1;
    }

    private void setTargets(Collection<Address> mbrs) {
        for(Address mbr: mbrs)
            requests.put(mbr, new Rsp(mbr));
        num_not_received=requests.size();
    }
View Full Code Here

        boolean voteResult = false;
        int totalPositiveVotes = 0;
        int totalNegativeVotes = 0;

        for(Iterator it=responses.values().iterator(); it.hasNext();) {
            Rsp response = (Rsp)it.next();

            switch(checkResponse(response)) {
        case PROCESS_SKIP : continue;
        case PROCESS_BREAK : return false;
            }

            VoteResult result = (VoteResult)response.getValue();

            totalPositiveVotes += result.getPositiveVotes();
            totalNegativeVotes += result.getNegativeVotes();
        }
View Full Code Here

        int totalPositiveVotes = 0;
        int totalNegativeVotes = 0;

        for (int i = 0; i < responses.size(); i++) {
            Rsp response = (Rsp) responses.elementAt(i);

            switch (checkResponse(response)) {
                case PROCESS_SKIP:
                    continue;
                case PROCESS_BREAK:
                    return false;
            }

            VoteResult result = (VoteResult) response.getValue();

            totalPositiveVotes += result.getPositiveVotes();
            totalNegativeVotes += result.getNegativeVotes();
        }
View Full Code Here

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

        rsp=rsps.get(c2.getAddress());
        assertNotNull(rsp);
        ret=rsp.getValue();
        assert ret == null;

        Util.close(c2);
    }
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.