01: // $Id: StateTransferInfo.java,v 1.13 2006/08/29 02:43:32 vlada Exp $
02:
03: package org.jgroups.stack;
04:
05: import java.io.InputStream;
06: import java.io.OutputStream;
07:
08: import org.jgroups.Address;
09:
10: /**
11: * Contains parameters for state transfer. Exchanged between channel and STATE_TRANSFER
12: * layer. The state is retrieved from 'target'. If target is null, then the state will be retrieved from the oldest
13: * member (usually the coordinator).
14: * @author Bela Ban
15: * @version $Id: StateTransferInfo.java,v 1.13 2006/08/29 02:43:32 vlada Exp $
16: */
17: public class StateTransferInfo {
18: public Address target = null;
19: public long timeout = 0;
20: public byte[] state = null;
21: public String state_id = null;
22: public InputStream inputStream = null;
23: public OutputStream outputStream = null;
24:
25: public StateTransferInfo() {
26: }
27:
28: public StateTransferInfo(Address target) {
29: this .target = target;
30: }
31:
32: public StateTransferInfo(Address target, long timeout) {
33: this .target = target;
34: this .timeout = timeout;
35: }
36:
37: public StateTransferInfo(Address target, String state_id,
38: long timeout) {
39: this .target = target;
40: this .state_id = state_id;
41: this .timeout = timeout;
42: }
43:
44: public StateTransferInfo(Address target, String state_id,
45: long timeout, byte[] state) {
46: this .target = target;
47: this .state = state;
48: this .state_id = state_id;
49: this .timeout = timeout;
50: }
51:
52: public StateTransferInfo(Address target, InputStream is,
53: String state_id) {
54: this .target = target;
55: this .state_id = state_id;
56: this .inputStream = is;
57: }
58:
59: public StateTransferInfo(Address target, OutputStream os,
60: String state_id) {
61: this .target = target;
62: this .state_id = state_id;
63: this .outputStream = os;
64: }
65:
66: public StateTransferInfo copy() {
67: if (inputStream != null) {
68: return new StateTransferInfo(target, inputStream, state_id);
69: } else if (outputStream != null) {
70: return new StateTransferInfo(target, outputStream, state_id);
71: } else {
72: return new StateTransferInfo(target, state_id, timeout,
73: state);
74: }
75: }
76:
77: public String toString() {
78: StringBuffer ret = new StringBuffer();
79: ret.append("target=" + target);
80: if (state != null)
81: ret.append(", state=" + state.length + " bytes");
82: if (state_id != null)
83: ret.append(", state_id=" + state_id);
84: ret.append(", timeout=" + timeout);
85: return ret.toString();
86: }
87: }
|