1 5 package com.tc.net.groups; 6 7 import com.tc.async.api.Sink; 8 9 import java.util.Collections ; 10 import java.util.List ; 11 12 17 public class SingleNodeGroupManager implements GroupManager { 18 19 private static final GroupResponse DUMMY_RESPONSE = new GroupResponse() { 20 public List getResponses() { 21 return Collections.EMPTY_LIST; 22 } 23 24 public GroupMessage getResponse(NodeID nodeID) { 25 return null; 26 } 27 }; 28 29 private static final byte[] CURRENT_NODE_ID = new byte[] { 36, 24, 32 }; 30 31 NodeID thisNode; 32 33 public NodeID join() throws GroupException { 34 if (thisNode != null) { throw new GroupException("Already Joined !"); } 35 this.thisNode = new NodeID("CurrentNode", CURRENT_NODE_ID); 36 return this.thisNode; 37 } 38 39 public NodeID getLocalNodeID() throws GroupException { 40 if (thisNode == null) { throw new GroupException("Not Joined yet !"); } 41 return this.thisNode; 42 } 43 44 45 public void registerForMessages(Class msgClass, GroupMessageListener listener) { 46 } 48 49 public void routeMessages(Class msgClass, Sink sink) { 50 } 52 53 public void sendAll(GroupMessage msg) { 54 } 56 57 public GroupResponse sendAllAndWaitForResponse(GroupMessage msg) { 58 return DUMMY_RESPONSE; 60 } 61 62 public void sendTo(NodeID node, GroupMessage msg) throws GroupException { 63 throw new GroupException("Can't write to Node : " + node + " Node Not found !"); 64 } 65 66 public GroupMessage sendToAndWaitForResponse(NodeID nodeID, GroupMessage msg) { 67 return null; 69 } 70 71 public void registerForGroupEvents(GroupEventsListener listener) { 72 } 74 75 public void zapNode(NodeID nodeID) { 76 } 78 79 } 80 | Popular Tags |