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.l1.api;
06:
07: import com.tc.exception.ImplementMe;
08: import com.tc.net.groups.NodeID;
09: import com.tc.object.ObjectID;
10: import com.tc.objectserver.managedobject.BackReferences;
11: import com.tc.text.PrettyPrinter;
12:
13: import java.util.ArrayList;
14: import java.util.Collection;
15: import java.util.Collections;
16: import java.util.HashSet;
17: import java.util.Iterator;
18: import java.util.List;
19: import java.util.Set;
20:
21: public class TestClientStateManager implements ClientStateManager {
22:
23: public NodeID shutdownClient = null;
24: public Collection allClientIDs = new HashSet();
25: public List addReferenceCalls = new ArrayList();
26:
27: public void shutdownNode(NodeID deadNode) {
28: this .shutdownClient = deadNode;
29: }
30:
31: public void addReference(NodeID nodeID, ObjectID objectID) {
32: addReferenceCalls
33: .add(new AddReferenceContext(nodeID, objectID));
34: }
35:
36: public static class AddReferenceContext {
37: public final NodeID nodeID;
38: public final ObjectID objectID;
39:
40: private AddReferenceContext(NodeID nodeID, ObjectID objectID) {
41: this .nodeID = nodeID;
42: this .objectID = objectID;
43: }
44: }
45:
46: public void removeReferences(NodeID nodeID, Set removed) {
47: //
48: }
49:
50: public List createPrunedChangesAndAddObjectIDTo(Collection changes,
51: BackReferences includeIDs, NodeID clientID, Set objectIDs) {
52: return Collections.EMPTY_LIST;
53: }
54:
55: public boolean hasReference(NodeID nodeID, ObjectID objectID) {
56: // to be consistent with createPrunedChangesAndAddObjectIDTo, return false
57: return false;
58: }
59:
60: public void addAllReferencedIdsTo(Set rescueIds) {
61: throw new ImplementMe();
62:
63: }
64:
65: public PrettyPrinter prettyPrint(PrettyPrinter out) {
66: return out.print(getClass().getName());
67: }
68:
69: public Collection getAllClientIDs() {
70: return allClientIDs;
71: }
72:
73: public void stop() {
74: // TODO Auto-generated method stub
75:
76: }
77:
78: public void removeReferencedFrom(NodeID nodeID, Set secondPass) {
79: throw new ImplementMe();
80:
81: }
82:
83: public Set addReferences(NodeID nodeID, Set oids) {
84: for (Iterator i = oids.iterator(); i.hasNext();) {
85: ObjectID oid = (ObjectID) i.next();
86: addReferenceCalls.add(new AddReferenceContext(nodeID, oid));
87: }
88: return oids;
89: }
90:
91: public void startupNode(NodeID nodeID) {
92: // NOP
93: }
94:
95: }
|