001: /*
002: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.l2.objectserver;
006:
007: import com.tc.net.groups.NodeID;
008: import com.tc.object.dmi.DmiDescriptor;
009: import com.tc.object.dna.impl.ObjectStringSerializer;
010: import com.tc.object.gtx.GlobalTransactionID;
011: import com.tc.object.lockmanager.api.LockID;
012: import com.tc.object.tx.ServerTransactionID;
013: import com.tc.object.tx.TransactionID;
014: import com.tc.object.tx.TxnBatchID;
015: import com.tc.object.tx.TxnType;
016: import com.tc.objectserver.tx.ServerTransaction;
017: import com.tc.util.Assert;
018: import com.tc.util.SequenceID;
019:
020: import java.util.Collection;
021: import java.util.Collections;
022: import java.util.List;
023: import java.util.Map;
024: import java.util.Set;
025:
026: public class ObjectSyncServerTransaction implements ServerTransaction {
027:
028: private final TransactionID txnID;
029: private final Set oids;
030: private final List changes;
031: private final ServerTransactionID serverTxnID;
032: private final Map rootsMap;
033: private final NodeID serverID;
034:
035: public ObjectSyncServerTransaction(TransactionID txnID, Set oids,
036: int dnaCount, List changes, Map rootsMap, NodeID serverID) {
037: this .txnID = txnID;
038: this .oids = oids;
039: this .changes = changes;
040: this .rootsMap = rootsMap;
041: this .serverID = serverID;
042: this .serverTxnID = new ServerTransactionID(serverID, txnID);
043: Assert.assertEquals(dnaCount, oids.size());
044: Assert.assertEquals(dnaCount, changes.size());
045: }
046:
047: public Collection getNotifies() {
048: return Collections.EMPTY_LIST;
049: }
050:
051: public TxnBatchID getBatchID() {
052: return TxnBatchID.NULL_BATCH_ID;
053: }
054:
055: public List getChanges() {
056: return changes;
057: }
058:
059: public NodeID getSourceID() {
060: return serverID;
061: }
062:
063: public SequenceID getClientSequenceID() {
064: throw new UnsupportedOperationException();
065: }
066:
067: public DmiDescriptor[] getDmiDescriptors() {
068: throw new UnsupportedOperationException();
069: }
070:
071: public LockID[] getLockIDs() {
072: return new LockID[0];
073: }
074:
075: public Map getNewRoots() {
076: return rootsMap;
077: }
078:
079: public Set getObjectIDs() {
080: return oids;
081: }
082:
083: /*
084: * All objects contained in ObjectSync Message are new Objects for the passive
085: */
086: public Set getNewObjectIDs() {
087: return oids;
088: }
089:
090: public ObjectStringSerializer getSerializer() {
091: throw new UnsupportedOperationException();
092: }
093:
094: public ServerTransactionID getServerTransactionID() {
095: return serverTxnID;
096: }
097:
098: public TransactionID getTransactionID() {
099: return txnID;
100: }
101:
102: public TxnType getTransactionType() {
103: return TxnType.NORMAL;
104: }
105:
106: // XXX:: this is server generated txn, hence GID is not assigned.
107: public GlobalTransactionID getGlobalTransactionID() {
108: return GlobalTransactionID.NULL_ID;
109: }
110:
111: public boolean needsBroadcast() {
112: return false;
113: }
114:
115: }
|