1 5 package com.tc.l2.msg; 6 7 import com.tc.async.api.EventContext; 8 import com.tc.bytes.TCByteBuffer; 9 import com.tc.net.groups.AbstractGroupMessage; 10 import com.tc.net.protocol.tcm.ChannelID; 11 import com.tc.object.dna.impl.ObjectStringSerializer; 12 import com.tc.util.Assert; 13 14 import java.io.IOException ; 15 import java.io.ObjectInput ; 16 import java.io.ObjectOutput ; 17 18 public class RelayedCommitTransactionMessage extends AbstractGroupMessage implements EventContext { 19 20 public static final int RELAYED_COMMIT_TXN_MSG_TYPE = 0; 21 22 private TCByteBuffer[] batchData; 23 private ObjectStringSerializer serializer; 24 25 private ChannelID channelID; 26 27 public RelayedCommitTransactionMessage() { 29 super(-1); 30 } 31 32 public RelayedCommitTransactionMessage(ChannelID channelID, TCByteBuffer[] batchData, 33 ObjectStringSerializer serializer) { 34 super(RELAYED_COMMIT_TXN_MSG_TYPE); 35 this.channelID = channelID; 36 this.batchData = batchData; 37 this.serializer = serializer; 38 } 39 40 public ChannelID getChannelID() { 41 return channelID; 42 } 43 44 public TCByteBuffer[] getBatchData() { 45 return batchData; 46 } 47 48 public ObjectStringSerializer getSerializer() { 49 return serializer; 50 } 51 52 protected void basicReadExternal(int msgType, ObjectInput in) throws IOException { 53 Assert.assertEquals(RELAYED_COMMIT_TXN_MSG_TYPE, msgType); 54 this.channelID = new ChannelID(in.readLong()); 55 this.serializer = readObjectStringSerializer(in); 56 this.batchData = readByteBuffers(in); 57 } 58 59 protected void basicWriteExternal(int msgType, ObjectOutput out) throws IOException { 60 Assert.assertEquals(RELAYED_COMMIT_TXN_MSG_TYPE, msgType); 61 out.writeLong(channelID.toLong()); 62 writeObjectStringSerializer(out, serializer); 63 writeByteBuffers(out, batchData); 64 } 65 66 } 67 | Popular Tags |