01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.l2.msg;
06:
07: import com.tc.object.gtx.GlobalTransactionID;
08: import com.tc.object.msg.CommitTransactionMessage;
09: import com.tc.objectserver.tx.ServerTransaction;
10:
11: import java.util.Collection;
12: import java.util.HashMap;
13: import java.util.Iterator;
14: import java.util.Map;
15:
16: public class RelayedCommitTransactionMessageFactory {
17:
18: public static RelayedCommitTransactionMessage createRelayedCommitTransactionMessage(
19: CommitTransactionMessage commitMsg, Collection txns,
20: long seqID, GlobalTransactionID lowWaterMark) {
21: RelayedCommitTransactionMessage msg = new RelayedCommitTransactionMessage(
22: commitMsg.getClientID(), commitMsg.getBatchData(),
23: commitMsg.getSerializer(),
24: getGlobalTransactionIDMapping(txns), seqID,
25: lowWaterMark);
26: return msg;
27: }
28:
29: private static Map getGlobalTransactionIDMapping(Collection txns) {
30: Map sid2gid = new HashMap(txns.size());
31: for (Iterator i = txns.iterator(); i.hasNext();) {
32: ServerTransaction txn = (ServerTransaction) i.next();
33: sid2gid.put(txn.getServerTransactionID(), txn
34: .getGlobalTransactionID());
35: }
36: return sid2gid;
37: }
38:
39: }
|