KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > stack > StateTransferInfo


1 // $Id: StateTransferInfo.java,v 1.3 2004/09/16 13:55:32 belaban Exp $
2

3 package org.jgroups.stack;
4
5
6 import org.jgroups.Address;
7
8 import java.util.Vector JavaDoc;
9
10
11 /**
12  * Contains parameters for state transfer. Exchanged between channel and STATE_TRANSFER
13  * layer. If type is GET_FROM_SINGLE, then the state is retrieved from 'target'. If
14  * target is null, then the state will be retrieved from the oldest member (usually the
15  * coordinator). If type is GET_FROM_MANY, the the state is retrieved from
16  * 'targets'. If targets is null, then the state is retrieved from all members.
17  *
18  * @author Bela Ban
19  */

20 public class StateTransferInfo {
21     public static final int GET_FROM_SINGLE=1; // get the state from a single member
22
public static final int GET_FROM_MANY=2; // get the state from multiple members (possibly all)
23

24     public Address requester=null;
25     public int type=GET_FROM_SINGLE;
26     public Address target=null;
27     public Vector JavaDoc targets=null;
28     public long timeout=0;
29
30
31     public StateTransferInfo(Address requester, int type, Address target) {
32         this.requester=requester;
33         this.type=type;
34         this.target=target;
35     }
36
37     public StateTransferInfo(int type, Address target) {
38         this.type=type;
39         this.target=target;
40     }
41
42
43     public StateTransferInfo(int type, Vector JavaDoc targets) {
44         this.type=type;
45         this.targets=targets;
46     }
47
48
49     public String JavaDoc toString() {
50         StringBuffer JavaDoc ret=new StringBuffer JavaDoc();
51         ret.append("type=" + (type == GET_FROM_MANY ? "GET_FROM_MANY" : "GET_FROM_SINGLE") + ", ");
52         if(type == GET_FROM_MANY)
53             ret.append("targets=" + targets);
54         else
55             ret.append("target=" + target);
56         ret.append(", timeout=" + timeout);
57         return ret.toString();
58     }
59 }
60
Popular Tags