01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.object.lockmanager.impl;
06:
07: import com.tc.io.TCByteBufferInput;
08: import com.tc.io.TCByteBufferOutput;
09: import com.tc.io.TCSerializable;
10: import com.tc.net.groups.NodeID;
11: import com.tc.net.groups.NodeIDSerializer;
12: import com.tc.object.lockmanager.api.LockID;
13: import com.tc.object.lockmanager.api.ThreadID;
14:
15: import java.io.IOException;
16:
17: /**
18: * This class is used to hold the global holder/waiter information of a lock.
19: */
20: public class GlobalLockStateInfo implements TCSerializable {
21: private LockID lockID;
22: private NodeID nodeID;
23: private ThreadID threadID;
24: private long timeout;
25: private long timestamp;
26: private int lockLevel;
27:
28: public GlobalLockStateInfo() {
29: super ();
30: }
31:
32: public GlobalLockStateInfo(LockID lockID, NodeID nodeID,
33: ThreadID threadID, long timestamp, long timeout,
34: int lockLevel) {
35: this .lockID = lockID;
36: this .nodeID = nodeID;
37: this .threadID = threadID;
38: this .timestamp = timestamp;
39: this .timeout = timeout;
40: this .lockLevel = lockLevel;
41: }
42:
43: public NodeID getNodeID() {
44: return nodeID;
45: }
46:
47: public LockID getLockID() {
48: return lockID;
49: }
50:
51: public int getLockLevel() {
52: return lockLevel;
53: }
54:
55: public long getTimeout() {
56: return timeout;
57: }
58:
59: public long getTimestamp() {
60: return timestamp;
61: }
62:
63: public ThreadID getThreadID() {
64: return threadID;
65: }
66:
67: public void serializeTo(TCByteBufferOutput serialOutput) {
68: serialOutput.writeLong(timestamp);
69: serialOutput.writeString(lockID.asString());
70: NodeIDSerializer ns = new NodeIDSerializer(nodeID);
71: ns.serializeTo(serialOutput);
72: serialOutput.writeLong(threadID.toLong());
73: serialOutput.writeLong(timeout);
74: serialOutput.writeInt(lockLevel);
75: }
76:
77: public Object deserializeFrom(TCByteBufferInput serialInput)
78: throws IOException {
79: this .timestamp = serialInput.readLong();
80: this .lockID = new LockID(serialInput.readString());
81: NodeIDSerializer ns = new NodeIDSerializer();
82: ns.deserializeFrom(serialInput);
83: this .nodeID = ns.getNodeID();
84: this .threadID = new ThreadID(serialInput.readLong());
85: this.timeout = serialInput.readLong();
86: this.lockLevel = serialInput.readInt();
87: return this;
88: }
89:
90: }
|