1 22 package org.jboss.test.cluster.drm; 23 24 import java.util.ArrayList ; 25 import java.util.Vector ; 26 27 import org.jboss.ha.framework.interfaces.ClusterNode; 28 import org.jboss.ha.framework.interfaces.DistributedReplicantManager; 29 import org.jboss.ha.framework.interfaces.DistributedState; 30 import org.jboss.ha.framework.interfaces.HAPartition; 31 32 40 public class MockHAPartition implements HAPartition 41 { 42 public static final String PARTITION_NAME = "MockPartition"; 43 44 private DistributedReplicantManager drm; 45 private Vector currentNodes; 46 private ClusterNode localAddress; 47 private ArrayList remoteReplicants; 48 49 public MockHAPartition(ClusterNode localAddress) 50 { 51 this.localAddress = localAddress; 52 } 53 55 public String getNodeName() 56 { 57 return localAddress.getName(); 58 } 59 60 public String getPartitionName() 61 { 62 return PARTITION_NAME; 63 } 64 65 public DistributedReplicantManager getDistributedReplicantManager() 66 { 67 return drm; 68 } 69 70 public DistributedState getDistributedStateService() 71 { 72 73 throw new UnsupportedOperationException ("not implemented"); 74 } 75 76 public void registerRPCHandler(String serviceName, Object handler) 77 { 78 if (handler instanceof DistributedReplicantManager) 79 drm = (DistributedReplicantManager) handler; 80 else 81 throw new UnsupportedOperationException ("not implemented"); 82 } 83 84 public void unregisterRPCHandler(String serviceName, Object subscriber) 85 { 86 if (subscriber == drm) 87 drm = null; 88 else 89 throw new UnsupportedOperationException ("not implemented"); 90 } 91 92 public ArrayList callMethodOnCluster(String serviceName, String methodName, Object [] args, Class [] types, 93 boolean excludeSelf) throws Exception 94 { 95 if (excludeSelf) 96 { 97 if ("_add".equals(methodName)) 98 { 99 return null; 101 } 102 else if ("lookupLocalReplicants".equals(methodName) && args.length == 0) 103 { 104 return remoteReplicants; 105 } 106 } 107 109 throw new UnsupportedOperationException ("not implemented"); 110 } 111 112 public ArrayList callMethodOnCluster(String serviceName, String methodName, Object [] args, boolean excludeSelf) 113 throws Exception 114 { 115 116 throw new UnsupportedOperationException ("not implemented"); 117 } 118 119 public void callAsynchMethodOnCluster(String serviceName, String methodName, Object [] args, Class [] types, 120 boolean excludeSelf) throws Exception 121 { 122 if (excludeSelf && "_remove".equals(methodName)) 123 { 124 return; 126 } 127 128 throw new UnsupportedOperationException ("not implemented"); 129 } 130 131 public void callAsynchMethodOnCluster(String serviceName, String methodName, Object [] args, boolean excludeSelf) 132 throws Exception 133 { 134 throw new UnsupportedOperationException ("not implemented"); 135 } 136 137 public ArrayList callMethodOnCoordinatorNode(String serviceName, String methodName, Object [] args, Class [] types, 138 boolean excludeSelf) throws Exception 139 { 140 throw new UnsupportedOperationException ("not implemented"); 141 } 142 143 public void subscribeToStateTransferEvents(String serviceName, HAPartitionStateTransfer subscriber) 144 { 145 } 148 149 public void unsubscribeFromStateTransferEvents(String serviceName, HAPartitionStateTransfer subscriber) 150 { 151 } 154 155 public void registerMembershipListener(HAMembershipListener listener) 156 { 157 } 160 161 public void unregisterMembershipListener(HAMembershipListener listener) 162 { 163 } 166 167 public boolean getAllowSynchronousMembershipNotifications() 168 { 169 return false; 170 } 171 172 public void setAllowSynchronousMembershipNotifications(boolean allowSync) 173 { 174 } 176 177 public long getCurrentViewId() 178 { 179 180 throw new UnsupportedOperationException ("not implemented"); 181 } 182 183 public Vector getCurrentView() 184 { 185 Vector result = new Vector (); 186 for (int i = 0; i < currentNodes.size(); i++) 187 result.add(((ClusterNode) currentNodes.elementAt(i)).getName()); 188 189 return result; 190 } 191 192 public ClusterNode[] getClusterNodes() 193 { 194 ClusterNode[] result = new ClusterNode[currentNodes.size()]; 195 return (ClusterNode[]) currentNodes.toArray(result); 196 } 197 198 public ClusterNode getClusterNode() 199 { 200 return localAddress; 201 } 202 203 205 public void setCurrentViewClusterNodes(Vector nodes) 206 { 207 this.currentNodes = nodes; 208 } 209 210 public void setRemoteReplicants(ArrayList remoteReplicants) 211 { 212 this.remoteReplicants = remoteReplicants; 213 } 214 215 } 216 | Popular Tags |