Refine search
public void setSocketFactory(SocketFactory factory) { ProtocolStack stack=getProtocolStack(); Protocol prot=stack != null? stack.getTopProtocol() : null; if(prot != null) prot.setSocketFactory(factory); }
public void start(long timeout) throws Exception { if(channel != null) // already started return; channel=new JChannel(channel_properties); disp=new RpcDispatcher(channel, this, this, this); channel.connect(groupname); rc=channel.getState(null, timeout); if(rc) { if(log.isInfoEnabled()) log.info("state was retrieved successfully"); } else if(log.isInfoEnabled()) log.info("state could not be retrieved (must be first member in group)"); }
public void onEvent(RuntimeStop event) { if (domainDispatcher != null) { domainDispatcher.stop(); } if (domainChannel != null && domainChannel.isConnected()) { domainChannel.disconnect(); domainChannel.close(); } for (Channel channel : channels.values()) { if (channel.isConnected()) { channel.disconnect(); channel.close(); } } } }
protected void startupExternal() throws Exception { // TODO: need to do more research to figure out the best default transport // settings // to avoid fragmentation, etc. // if config file is set, use it, otherwise use a default // set of properties, trying to configure multicast address and port if (configURL != null) { channel = new JChannel(configURL); } else { String configString = buildConfigString(); channel = new JChannel(configString); } // Important - discard messages from self channel.setOpt(Channel.LOCAL, Boolean.FALSE); channel.connect(externalSubject); if (receivesExternalEvents()) { adapter = new PullPushAdapter(channel, this); } }
public void start(String props, boolean use_additional_data) throws Exception { channel=new JChannel(props); channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE); if(use_additional_data) { HashMap m=new HashMap(); m.put("additional_data", "bela".getBytes()); channel.down(new Event(Event.CONFIG, m)); } channel.connect("ViewDemo"); new PullPushAdapter(channel, this); while(true) { Util.sleep(10000); } }
public DrawRepl() { colors.put(new Integer(1), Color.white); colors.put(new Integer(2), Color.black); colors.put(new Integer(3), Color.red); colors.put(new Integer(4), Color.orange); colors.put(new Integer(5), Color.green); colors.put(new Integer(6), Color.magenta); colors.put(new Integer(7), Color.cyan); colors.put(new Integer(8), Color.blue); mythread=new Thread(this); try { channel=new JChannel(); dispatcher=new RpcDispatcher(channel, null, null, this); channel.connect(groupname); } catch(Exception e) { System.err.println(e); System.exit(0); } }
@Override protected void init() { try { if (this.channel == null) { this.channel = newChannel(jgroupsConfig); } ProtocolStack protocolStack = channel.getProtocolStack(); Protocol centralLock = protocolStack.findProtocol(CENTRAL_LOCK.class); if (centralLock == null) { // add the locking protocol CENTRAL_LOCK lockingProtocol = new CENTRAL_LOCK(); // we have to call init because the channel has already been created lockingProtocol.init(); protocolStack.addProtocol(lockingProtocol); } // Add a listener through which we'll know what's going on within the cluster ... this.channel.addChannelListener(listener); // Set the receiver through which we'll receive all of the changes ... this.channel.setReceiver(receiver); // Now connect to the cluster ... this.channel.connect(clusterName); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Creates a ReplicatedHashtable * @param groupname The name of the group to join * @param factory The ChannelFactory which will be used to create a channel * @param properties The property string to be used to define the channel * @param state_timeout The time to wait until state is retrieved in milliseconds. A value of 0 means wait forever. */ public ReplicatedHashtable(String groupname, ChannelFactory factory, StateTransferListener l, String properties, long state_timeout) { if(l != null) addStateTransferListener(l); try { channel=factory != null ? factory.createChannel(properties) : new JChannel(properties); channel.connect(groupname); adapter=new PullPushAdapter(channel, this, this); adapter.setListener(this); getInitState(channel, state_timeout); } catch(Exception e) { if(log.isErrorEnabled()) log.error("exception=" + e); } }
public Void run() { channel.disconnect(); channel.close(); return null; } });
@Override public void channelConnected(Channel channel) { // Validate view String localName = channel.getName(); Address localAddress = channel.getAddress(); for (Address address: channel.getView()) { String name = channel.getName(address); if ((name != null) && name.equals(localName) && !address.equals(localAddress)) { channel.close(); throw JGroupsMessages.MESSAGES.duplicateNodeName(this.factory.getValue().getProtocolStackConfiguration().getEnvironment().getNodeName()); } } }
public void disconnect() { if (channel != null && channel.isOpen()) { if (log.isInfoEnabled()) log.info("Disconnecting and closing the Channel"); channel.disconnect(); channel.close(); } }
protected final void handlePingRequest(Channel channel, InputStream stream) throws Exception { OpenshiftPing handler = (OpenshiftPing) channel.getProtocolStack().findProtocol(OpenshiftPing.class); handler.handlePingRequest(stream); } }
void connect() throws ChannelException, ChannelClosedException { if (channel != null && !channel.isConnected()) channel.connect(channelName); }
public void destroy() { System.out.println("DESTROY!!!!!"); if(clusterChannel != null && clusterChannel.isConnected()) { // This calls disconnect() first clusterChannel.close(); } }
protected void initializeChannel(Channel channel) { // turn off local message reception channel.setDiscardOwnMessages(true); TP transport = channel.getProtocolStack().getTransport(); // Replace the default thread pool transport.setDefaultThreadPool(executor); for (Protocol protocol : channel.getProtocolStack().getProtocols()) { if (protocol instanceof GMS) { ((GMS) protocol).setPrintLocalAddr(printLocalAddress); } } }
public void start() throws Exception { channel.connect(bus_name); }
/** * {@inheritDoc} * @see net.sf.hajdbc.Lifecycle#stop() */ @Override public void stop() { Channel channel = this.dispatcher.getChannel(); if (channel.isOpen()) { if (channel.isConnected()) { channel.disconnect(); } } }
private void send(Message message) throws IOException { if (log.isDebugEnabled()) log.debug("Sending message[" + message + "]"); try { channel.send(message); } catch (ChannelException ex) { throw new IOException("Failed to request help for a put operation", ex); } }
/** * {@inheritDoc} */ protected Address getLocalAddress() { return channel.getAddress(); }