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.msg;
06:
07: import com.tc.bytes.TCByteBuffer;
08: import com.tc.io.TCByteBufferOutput;
09: import com.tc.net.groups.NodeID;
10: import com.tc.net.groups.NodeIDSerializer;
11: import com.tc.net.protocol.tcm.MessageChannel;
12: import com.tc.net.protocol.tcm.MessageMonitor;
13: import com.tc.net.protocol.tcm.TCMessageHeader;
14: import com.tc.net.protocol.tcm.TCMessageType;
15: import com.tc.object.session.SessionID;
16: import com.tc.object.tx.TransactionID;
17:
18: import java.io.IOException;
19:
20: /**
21: * @author steve
22: */
23: public class AcknowledgeTransactionMessageImpl extends DSOMessageBase
24: implements AcknowledgeTransactionMessage {
25: private final static byte REQUEST_ID = 1;
26: private final static byte REQUESTER_ID = 2;
27:
28: private TransactionID requestID;
29: private NodeID requesterID;
30:
31: public AcknowledgeTransactionMessageImpl(SessionID sessionID,
32: MessageMonitor monitor, TCByteBufferOutput out,
33: MessageChannel channel, TCMessageType type) {
34: super (sessionID, monitor, out, channel, type);
35: }
36:
37: public AcknowledgeTransactionMessageImpl(SessionID sessionID,
38: MessageMonitor monitor, MessageChannel channel,
39: TCMessageHeader header, TCByteBuffer[] data) {
40: super (sessionID, monitor, channel, header, data);
41: }
42:
43: protected void dehydrateValues() {
44: putNVPair(REQUEST_ID, requestID.toLong());
45: putNVPair(REQUESTER_ID, new NodeIDSerializer(requesterID));
46: }
47:
48: protected boolean hydrateValue(byte name) throws IOException {
49: switch (name) {
50: case REQUESTER_ID:
51: requesterID = ((NodeIDSerializer) getObject(new NodeIDSerializer()))
52: .getNodeID();
53: return true;
54: case REQUEST_ID:
55: requestID = new TransactionID(getLongValue());
56: return true;
57: default:
58: return false;
59: }
60: }
61:
62: public void initialize(NodeID nid, TransactionID txID) {
63: this .requesterID = nid;
64: this .requestID = txID;
65: }
66:
67: public NodeID getRequesterID() {
68: return requesterID;
69: }
70:
71: public TransactionID getRequestID() {
72: return requestID;
73: }
74:
75: }
|