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.net.protocol.delivery;
06:
07: import com.tc.bytes.TCByteBuffer;
08: import com.tc.net.protocol.AbstractTCNetworkMessage;
09: import com.tc.net.protocol.TCNetworkMessage;
10:
11: class OOOProtocolMessageImpl extends AbstractTCNetworkMessage implements
12: OOOProtocolMessage {
13:
14: /**
15: * Create a header-only message (no payload). Useful for ack and ack request messages.
16: */
17: OOOProtocolMessageImpl(OOOProtocolMessageHeader header) {
18: super (header);
19: }
20:
21: /**
22: * Create a message with the given payload from the network. Useful for propogating messages up the network stack.
23: */
24: OOOProtocolMessageImpl(OOOProtocolMessageHeader header,
25: TCByteBuffer[] payload) {
26: super (header, payload);
27: }
28:
29: /**
30: * Create a message with the given TCNetworkMessage payload. Useful for propogating messages down the network stack.
31: */
32: OOOProtocolMessageImpl(OOOProtocolMessageHeader header,
33: TCNetworkMessage msgPayload) {
34: super (header, msgPayload);
35: }
36:
37: private OOOProtocolMessageHeader getOOOPHeader() {
38: return (OOOProtocolMessageHeader) getHeader();
39: }
40:
41: public long getAckSequence() {
42: return getOOOPHeader().getSequence();
43: }
44:
45: public long getSent() {
46: return getOOOPHeader().getSequence();
47: }
48:
49: public short getSessionId() {
50: OOOProtocolMessageHeader header = (OOOProtocolMessageHeader) getHeader();
51: return (header.getSession());
52: }
53:
54: public boolean isHandshake() {
55: return getOOOPHeader().isHandshake();
56: }
57:
58: public boolean isHandshakeReplyOk() {
59: return getOOOPHeader().isHandshakeReplyOk();
60: }
61:
62: public boolean isHandshakeReplyFail() {
63: return getOOOPHeader().isHandshakeReplyFail();
64: }
65:
66: public boolean isSend() {
67: return getOOOPHeader().isSend();
68: }
69:
70: public boolean isAck() {
71: return getOOOPHeader().isAck();
72: }
73:
74: public boolean isGoodbye() {
75: return getOOOPHeader().isGoodbye();
76: }
77:
78: public void doRecycleOnWrite() {
79: // we are disabling this because on ooo layer knows when it's safe to recycle the message
80: }
81:
82: public void reallyDoRecycleOnWrite() {
83: getOOOPHeader().recycle();
84: AbstractTCNetworkMessage messagePayLoad = (AbstractTCNetworkMessage) getMessagePayload();
85: if (messagePayLoad != null) {
86: messagePayLoad.doRecycleOnWrite();
87: }
88: }
89: }
|