public void setup(List<ProtocolConfiguration> configs) throws Exception { if(top_prot == null) { top_prot=new Configurator(this).setupProtocolStack(configs); top_prot.setUpProtocol(this); this.setDownProtocol(top_prot); bottom_prot=getBottomProtocol(); initProtocolStack(); } }
protected void handleRegister(Address sender, DataInput in) { GossipData req=readRequest(in, GossipType.REGISTER); if(req != null) { String group=req.getGroup(); Address addr=req.getAddress(); PhysicalAddress phys_addr=req.getPhysicalAddress(); String logical_name=req.getLogicalName(); addAddressMapping(sender, group, addr, phys_addr, logical_name); } }
public void connectStubs() { for(RouterStub stub : stubs) { try { if(!stub.isConnected()) stub.connect(cluster_name, local_addr, logical_name, phys_addr); } catch (Throwable e) { moveStubToReconnects(stub); } } }
/** * Creates an instance of TcpServer. * @param bind_addr The local bind address and port. If null, a bind address and port will be picked by the OS. */ public TcpServer(IpAddress bind_addr) throws Exception { this(bind_addr != null? bind_addr.getIpAddress() : null, bind_addr != null? bind_addr.getPort() : 0); }
public void init() throws Exception { List<Protocol> protocols=getProtocols(); Collections.reverse(protocols); top_prot=Configurator.connectProtocols(protocols); top_prot.setUpProtocol(this); this.setDownProtocol(top_prot); bottom_prot=getBottomProtocol(); Configurator.setDefaultValues(protocols); initProtocolStack(); }
public void receive(Address sender, DataInput in) throws Exception { GossipData data=new GossipData(); data.readFrom(in); switch(data.getType()) { case MESSAGE: case SUSPECT: if(receiver != null) receiver.receive(data); break; case GET_MBRS_RSP: notifyResponse(data.getGroup(), data.getPingData()); break; } }
/** * A message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it * before passing it down. * @since 4.0 */ public Object down(Message msg) { return down_prot.down(msg); }
protected void handleUnregister(DataInput in) { GossipData req=readRequest(in, GossipType.UNREGISTER); if(req != null) removeAddressMapping(req.getGroup(), req.getAddress()); }
public RouterStub createAndRegisterStub(IpAddress local, IpAddress router_addr) { RouterStub stub=new RouterStub(local, router_addr, use_nio, this); RouterStub old_stub=unregisterStub(router_addr); if(old_stub != null) old_stub.destroy(); add(stub); return stub; }
public void disconnectStubs() { stopReconnector(); for(RouterStub stub : stubs) { try { stub.disconnect(cluster_name, local_addr); } catch (Throwable e) { } } }
public void disconnect(String group, Address addr) throws Exception { writeRequest(new GossipData(GossipType.UNREGISTER, group, addr)); }
/** Creates a fork-stack from the configuration, initializes all protocols (setting values), * sets the protocol stack as top protocol, connects the protocols and calls init() on them. Returns * the protocols in a list, from bottom to top */ protected static List<Protocol> createProtocols(ProtocolStack stack, List<ProtocolConfiguration> protocol_configs) throws Exception { return Configurator.createProtocols(protocol_configs,stack); }
public void start() throws Exception { super.start(); running=true; ack_mode=true; }
/** * Sends an event down the protocol stack. Note that - contrary to {@link #send(Message)}, if the event is a message, * no checks are performed whether the channel is closed or disconnected. Note that this method is not typically * used by applications. * @param evt the message to send down, encapsulated in an event */ public Object down(Event evt) { if(evt == null) return null; return prot_stack.down(evt); }
@Override public synchronized void startStack() throws Exception { if(++connects == 1) super.startStack(); }
public TP unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler) { if(diag_handler != null) diag_handler.unregisterProbeHandler(handler); return this; }
public void setup(ProtocolStack stack) throws Exception { if(top_prot == null) { top_prot=new Configurator(this).setupProtocolStack(stack); top_prot.setUpProtocol(this); this.setDownProtocol(top_prot); bottom_prot=getBottomProtocol(); initProtocolStack(); } }
public void run() { down_prot.down(msg); num_stable_msgs_sent++; } public String toString() {return STABLE.class.getSimpleName() + ": STABLE-GOSSIP";}
public Object down(Message msg) { // Do something with the event, e.g. add a header to the message // Optionally pass down return down_prot.down(msg); }