/** * Creates a channel with the same configuration as the channel passed to this constructor. This is used by * testing code, and should not be used by clients! */ public JChannel(JChannel ch) throws Exception { init(ch); discard_own_messages=ch.discard_own_messages; }
/** * Constructs a JChannel with the protocol stack configuration contained by the protocol stack configurator parameter. * <p> * All of the public constructors of this class eventually delegate to this method. * @param configurator A protocol stack configurator containing a JGroups protocol stack configuration. */ public JChannel(ProtocolStackConfigurator configurator) throws Exception { init(configurator); }
/** * Creates a JChannel without a protocol stack; used for programmatic creation of channel and protocol stack * @param create_protocol_stack If true, the default config is used. If false, no protocol stack is created */ public JChannel(boolean create_protocol_stack) { if(create_protocol_stack) { try { init(ConfiguratorFactory.getStackConfigurator(Global.DEFAULT_PROTOCOL_STACK)); } catch(Exception e) { throw new RuntimeException(e); } } }
protected JChannel _connect(Event connect_event) throws Exception { try { down(connect_event); return this; } catch(SecurityException sex) { throw new SecurityException("connecting to channel " + connect_event.getArg() + " failed", sex); } catch(Throwable t) { stopStack(true, false); state=State.OPEN; init(); throw new Exception("connecting to channel " + connect_event.getArg() + " failed", t); } }
protected JChannel _close(boolean disconnect) { Address old_addr=local_addr; if(state == State.CLOSED) return this; if(disconnect) disconnect(); // leave group if connected stopStack(true, true); state=State.CLOSED; notifyChannelClosed(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining if(old_addr != null) NameCache.remove(old_addr); return this; }
/** * Leaves the cluster (disconnects the channel if it is connected). If the channel is closed or disconnected, this * operation is ignored. The channel can then be used to join the same or a different cluster again. * @see #connect(String) */ @ManagedOperation(description="Disconnects the channel if connected") public synchronized JChannel disconnect() { switch(state) { case OPEN: case CLOSED: break; case CONNECTING: case CONNECTED: if(cluster_name != null) { try { down(new Event(Event.DISCONNECT, local_addr)); // DISCONNECT is handled by each layer } catch(Throwable t) { log.error(Util.getMessage("DisconnectFailure"), local_addr, t); } } state=State.OPEN; stopStack(true, false); notifyChannelDisconnected(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining break; default: throw new IllegalStateException("state " + state + " unknown"); } return this; }
/** * Creates a channel with the same configuration as the channel passed to this constructor. This is used by * testing code, and should not be used by clients! */ public JChannel(JChannel ch) throws Exception { init(ch); discard_own_messages=ch.discard_own_messages; }
/** * Constructs a JChannel with the protocol stack configuration contained by the protocol stack configurator parameter. * <p> * All of the public constructors of this class eventually delegate to this method. * @param configurator A protocol stack configurator containing a JGroups protocol stack configuration. */ public JChannel(ProtocolStackConfigurator configurator) throws Exception { init(configurator); }
/** * Constructs a <code>JChannel</code> instance with the protocol stack * configuration contained by the protocol stack configurator parameter. * <p> * All of the public constructors of this class eventually delegate to this * method. * * @param configurator a protocol stack configurator containing a JGroups * protocol stack configuration. * * @throws ChannelException if problems occur during the initialization of * the protocol stack. */ protected JChannel(ProtocolStackConfigurator configurator) throws ChannelException { init(configurator); }
/** * Creates a JChannel without a protocol stack; used for programmatic creation of channel and protocol stack * @param create_protocol_stack If true, the default config is used. If false, no protocol stack is created */ public JChannel(boolean create_protocol_stack) { if(create_protocol_stack) { try { init(ConfiguratorFactory.getStackConfigurator(Global.DEFAULT_PROTOCOL_STACK)); } catch(Exception e) { throw new RuntimeException(e); } } }
protected JChannel _connect(Event connect_event) throws Exception { try { down(connect_event); return this; } catch(SecurityException sex) { throw new SecurityException("connecting to channel " + connect_event.getArg() + " failed", sex); } catch(Throwable t) { stopStack(true, false); state=State.OPEN; init(); throw new Exception("connecting to channel " + connect_event.getArg() + " failed", t); } }
/** * Creates a new JChannel with the protocol stack as defined in the properties * parameter. an example of this parameter is<BR> * "UDP:PING:FD:STABLE:NAKACK:UNICAST:FRAG:FLUSH:GMS:VIEW_ENFORCER:STATE_TRANSFER:QUEUE"<BR> * Other examples can be found in the ./conf directory<BR> * @param properties the protocol stack setup; if null, the default protocol stack will be used. * The properties can also be a java.net.URL object or a string that is a URL spec. * The JChannel will validate any URL object and String object to see if they are a URL. * In case of the parameter being a url, the JChannel will try to load the xml from there. * In case properties is a org.w3c.dom.Element, the ConfiguratorFactory will parse the * DOM tree with the element as its root element. * @deprecated Use the constructors with specific parameter types instead. */ public JChannel(Object properties) throws ChannelException { if (properties == null) properties = DEFAULT_PROTOCOL_STACK; ProtocolStackConfigurator c=null; try { c=ConfiguratorFactory.getStackConfigurator(properties); } catch(Exception x) { throw new ChannelException("unable to load protocol stack", x); } init(c); }
/** * Disconnects the channel if it is connected. If the channel is closed, this operation is ignored<BR> * Otherwise the following actions happen in the listed order<BR> * <ol> * <li> The JChannel sends a DISCONNECT event down the protocol stack<BR> * <li> Blocks until the event has returned<BR> * <li> Sends a STOP_QUEING event down the stack<BR> * <li> Stops the protocol stack by calling ProtocolStack.stop()<BR> * <li> Notifies the listener, if the listener is available<BR> * </ol> */ public synchronized void disconnect() { if(closed) return; if(connected) { if(cluster_name != null) { // Send down a DISCONNECT event, which travels down to the GMS, where a response is returned Event disconnect_event=new Event(Event.DISCONNECT, local_addr); down(disconnect_event); // DISCONNECT is handled by each layer } connected=false; try { prot_stack.stopStack(); // calls stop() in all protocols, from top to bottom } catch(Exception e) { if(log.isErrorEnabled()) log.error("exception: " + e); } notifyChannelDisconnected(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining } }
protected JChannel _close(boolean disconnect) { Address old_addr=local_addr; if(state == State.CLOSED) return this; if(disconnect) disconnect(); // leave group if connected stopStack(true, true); state=State.CLOSED; notifyChannelClosed(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining if(old_addr != null) NameCache.remove(old_addr); return this; }
connected=false; notifyChannelClosed(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining
/** * Leaves the cluster (disconnects the channel if it is connected). If the channel is closed or disconnected, this * operation is ignored. The channel can then be used to join the same or a different cluster again. * @see #connect(String) */ @ManagedOperation(description="Disconnects the channel if connected") public synchronized JChannel disconnect() { switch(state) { case OPEN: case CLOSED: break; case CONNECTING: case CONNECTED: if(cluster_name != null) { try { down(new Event(Event.DISCONNECT, local_addr)); // DISCONNECT is handled by each layer } catch(Throwable t) { log.error(Util.getMessage("DisconnectFailure"), local_addr, t); } } state=State.OPEN; stopStack(true, false); notifyChannelDisconnected(this); init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining break; default: throw new IllegalStateException("state " + state + " unknown"); } return this; }