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.objectserver.gtx;
06:
07: import com.tc.exception.ImplementMe;
08: import com.tc.net.groups.NodeID;
09: import com.tc.object.gtx.GlobalTransactionID;
10: import com.tc.object.tx.ServerTransactionID;
11: import com.tc.objectserver.persistence.api.PersistenceTransaction;
12: import com.tc.util.sequence.Sequence;
13:
14: import java.util.Collection;
15: import java.util.HashSet;
16: import java.util.Iterator;
17: import java.util.Set;
18:
19: public final class TestGlobalTransactionManager implements
20: ServerGlobalTransactionManager {
21:
22: private long idSequence = 0;
23: private Set commitedSIDs = new HashSet();
24:
25: public boolean initiateApply(ServerTransactionID stxID) {
26: return !commitedSIDs.contains(stxID);
27: }
28:
29: public void commit(PersistenceTransaction persistenceTransaction,
30: ServerTransactionID stxID) {
31: commitedSIDs.add(stxID);
32: }
33:
34: public GlobalTransactionID getLowGlobalTransactionIDWatermark() {
35: return null;
36: }
37:
38: public void clearCommitedTransactionsBelowLowWaterMark(
39: ServerTransactionID sid) {
40: return;
41: }
42:
43: public void shutdownNode(NodeID nodeID) {
44: return;
45: }
46:
47: public void commitAll(
48: PersistenceTransaction persistenceTransaction,
49: Collection stxIDs) {
50: for (Iterator iter = stxIDs.iterator(); iter.hasNext();) {
51: commit(persistenceTransaction, (ServerTransactionID) iter
52: .next());
53: }
54: }
55:
56: public void clear() {
57: commitedSIDs.clear();
58: }
59:
60: public GlobalTransactionID getOrCreateGlobalTransactionID(
61: ServerTransactionID serverTransactionID) {
62: return new GlobalTransactionID(idSequence++);
63: }
64:
65: public void createGlobalTransactionDescIfNeeded(
66: ServerTransactionID stxnID,
67: GlobalTransactionID globalTransactionID) {
68: throw new ImplementMe();
69: }
70:
71: public void shutdownAllClientsExcept(Set cids) {
72: return;
73: }
74:
75: public Sequence getGlobalTransactionIDSequence() {
76: throw new ImplementMe();
77: }
78:
79: public GlobalTransactionIDSequenceProvider getGlobalTransactionIDSequenceProvider() {
80: throw new ImplementMe();
81: }
82:
83: public GlobalTransactionID getGlobalTransactionID(
84: ServerTransactionID serverTransactionID) {
85: throw new ImplementMe();
86: }
87:
88: public void clearCommitedTransactionsBelowLowWaterMark(
89: GlobalTransactionID lowGlobalTransactionIDWatermark) {
90: return;
91: }
92: }
|