/** * Determines whether the channel is connected to a group. * @return true if channel is connected to cluster (group) and can send/receive messages, false otherwise */ @ManagedAttribute public boolean isConnected() {return ch.isConnected();}
public synchronized void connect() throws Exception { if (logger.isTraceEnabled()) { logger.trace(this + ":: Connecting " + channelName, new Exception("Trace")); } // It is important to check this otherwise we could reconnect an already connected channel if (connected) { return; } connected = true; if (!channel.isConnected()) { channel.connect(channelName); } }
public Object down(Message msg) { if(channel != null) { if(!(channel.isConnected() || channel.isConnecting())) { // return null; throw new IllegalStateException("channel is not connected"); } return channel.down(msg); } return null; }
/** Sets the logical name for the channel. The name will stay associated with this channel for the channel's lifetime * (until close() is called). This method must be called <em>before</em> calling connect() */ @ManagedAttribute(writable=true, description="The logical name of this channel. Stays with the channel until " + "the channel is closed") public JChannel setName(String name) { if(name != null) { if(isConnected()) throw new IllegalStateException("name cannot be set if channel is connected (should be done before)"); this.name=name; if(local_addr != null) NameCache.add(local_addr, this.name); } return this; }
protected void loop() throws Exception { List<String> lock_names; while(ch.isConnected()) { String line=Util.readStringFromStdin(": "); if(line == null || line.startsWith("quit") || line.startsWith("exit"))
public void run() { if(bridge == null || !bridge.isConnected() || remote_view != null) return; Message msg=new Message().putHeader(id, RelayHeader.create(RELAY.RelayHeader.Type.BROADCAST_VIEW)); try { bridge.send(msg); } catch(Exception e) { } } }
protected void loop() throws Exception { while(ch.isConnected()) { String line=Util.readStringFromStdin(": "); if(line.startsWith("quit") || line.startsWith("exit"))
if(!this.main_channel.isConnected()) throw new IllegalStateException("main channel is not connected"); if(state == State.CONNECTED)
NetView oldView = this.view; if (!myChannel.isConnected()) { logger.info("JGroupsMessenger channel is closed - messaging is not possible"); throw new DistributedSystemDisconnectedException("Distributed System is shutting down");
protected void sendViewToRemote(ViewData view_data, boolean use_seperate_thread) { try { if(bridge != null && bridge.isConnected()) { byte[] buf=Util.streamableToByteBuffer(view_data); final Message msg=new Message(null, buf).putHeader(id, RelayHeader.create(RelayHeader.Type.VIEW)); if(use_seperate_thread) { timer.execute(() -> { try { bridge.send(msg); } catch(Exception e) { log.error(Util.getMessage("FailedSendingViewToRemote"), e); } }); } else bridge.send(msg); } } catch(Exception e) { log.error(Util.getMessage("FailedSendingViewToRemote"), e); } }
/** * @return the {@link Status} of the manager */ public Status getStatus() { if (this.channel == null) { return Status.STATUS_UNINITIALISED; } if (!this.channel.isConnected()) { return Status.STATUS_SHUTDOWN; } return Status.STATUS_ALIVE; }
public boolean isConnected() { if (channel == null) { return false; } return channel.isConnected(); }
/** * Constructor * * @param jchannel unconnected JGroups JChannel object * @param clusterName name of the group to connect the JChannel to */ public JGroupsChannel(JChannel jchannel, String clusterName) { if (jchannel.isConnected()) throw new IllegalArgumentException("JChannel already connected"); this.jchannel = jchannel; this.clusterName = clusterName; }
private void assertChannel () { if (!channel.isConnected()) throw new SpaceError ("Channel is not connected"); } /** Called when a member is suspected */
protected void sendMessage(Message msg) throws Exception { if (channel == null || !channel.isConnected()) { throw new Exception("The channel is null or not connected"); } channel.send(msg); }
public synchronized void connect() throws Exception { if (logger.isTraceEnabled()) { logger.trace(this + ":: Connecting " + channelName, new Exception("Trace")); } // It is important to check this otherwise we could reconnect an already connected channel if (connected) { return; } connected = true; if (!channel.isConnected()) { channel.connect(channelName); } }
/** * Determines whether the channel is connected to a group. * @return true if channel is connected to cluster (group) and can send/receive messages, false otherwise */ @ManagedAttribute public boolean isConnected() {return ch.isConnected();}
public void advertise() { if (channel == null || !channel.isConnected()) { return; } Message msg = new Message(); msg.setObject(localServices.keySet().toArray(new DistributedServiceDescription[0])); try { sendMessage(msg); } catch (Exception e) { Log.error(this, "Error sending advertise message", e); } }
public void run() { if(bridge == null || !bridge.isConnected() || remote_view != null) return; Message msg=new Message().putHeader(id, RelayHeader.create(RELAY.RelayHeader.Type.BROADCAST_VIEW)); try { bridge.send(msg); } catch(Exception e) { } } }
protected void _close(boolean disconnect, boolean close_mq) { super._close(disconnect, close_mq); closed=!ch.isOpen(); setConnected(ch.isConnected()); notifyChannelClosed(this); }