public ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service) { this(); this.setClusterReceiver(receiver); this.setClusterSender(sender); this.setMembershipService(service); }
public void setClusterReceiver(ChannelReceiver clusterReceiver) { if ( clusterReceiver != null ) { this.clusterReceiver = clusterReceiver; this.clusterReceiver.setMessageListener(this); } else { if (this.clusterReceiver!=null ) this.clusterReceiver.setMessageListener(null); this.clusterReceiver = null; } }
public void setClusterReceiver(ChannelReceiver clusterReceiver) { if (clusterReceiver != null) { this.clusterReceiver = clusterReceiver; this.clusterReceiver.setMessageListener(this); } else { if (this.clusterReceiver != null) this.clusterReceiver.setMessageListener(null); this.clusterReceiver = null; } }
public ChannelReceiver getClusterReceiver() { return clusterReceiver; }
/** * Returns the channel receiver component * @return ChannelReceiver */ @Override public ChannelReceiver getChannelReceiver() { return coordinator.getClusterReceiver(); }
/** * Sets the channel receiver component * @param clusterReceiver ChannelReceiver */ @Override public void setChannelReceiver(ChannelReceiver clusterReceiver) { coordinator.setClusterReceiver(clusterReceiver); }
@Override public synchronized void run() { if ( buffer == null ) { int size = getRxBufSize(); if (key.channel() instanceof DatagramChannel) { size = ChannelReceiver.MAX_UDP_SIZE; } if ( (getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER) { buffer = ByteBuffer.allocateDirect(size); } else { buffer = ByteBuffer.allocate(size); } } else { buffer.clear(); } if (key == null) { return; // just in case } if ( log.isTraceEnabled() ) log.trace("Servicing key:"+key); try { ObjectReader reader = (ObjectReader)key.attachment(); if ( reader == null ) { if ( log.isTraceEnabled() ) log.trace("No object reader, cancelling:"+key); cancelKey(key); } else { if ( log.isTraceEnabled() ) log.trace("Draining channel:"+key); drainChannel(key, reader); } } catch (Exception e) { //this is common, since the sockets on the other //end expire after a certain time. if ( e instanceof CancelledKeyException ) { //do nothing } else if ( e instanceof IOException ) { //dont spew out stack traces for IO exceptions unless debug is enabled. if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].", e); else log.warn ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"]."); } else if ( log.isErrorEnabled() ) { //this is a real error, log it. log.error("Exception caught in TcpReplicationThread.drainChannel.",e); } cancelKey(key); } finally { } key = null; // done, ready for more, return to pool getTaskPool().returnWorker (this); }
public static Data createRandomData() { return createRandomData(ChannelReceiver.MAX_UDP_SIZE); }
@Override public synchronized void run() { if (buffer == null) { int size = getRxBufSize(); if (key.channel() instanceof DatagramChannel) { size = ChannelReceiver.MAX_UDP_SIZE; } if ((getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER) { buffer = ByteBuffer.allocateDirect(size); } else { buffer = ByteBuffer.allocate(size); } } else { buffer.clear(); } if (key == null) { return; // just in case } if (log.isTraceEnabled()) log.trace("Servicing key:" + key); try { ObjectReader reader = (ObjectReader) key.attachment(); if (reader == null) { if (log.isTraceEnabled()) log.trace("No object reader, cancelling:" + key); cancelKey(key); } else { if (log.isTraceEnabled()) log.trace("Draining channel:" + key); drainChannel(key, reader); } } catch (Exception e) { // this is common, since the sockets on the other // end expire after a certain time. if (e instanceof CancelledKeyException) { // do nothing } else if (e instanceof IOException) { // dont spew out stack traces for IO exceptions unless debug is // enabled. if (log.isDebugEnabled()) log.debug( "IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed[" + e.getMessage() + "].", e); else log.warn( "IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed[" + e.getMessage() + "]."); } else if (log.isErrorEnabled()) { // this is a real error, log it. log.error("Exception caught in TcpReplicationThread.drainChannel.", e); } cancelKey(key); } finally { } key = null; // done, ready for more, return to pool getTaskPool().returnWorker(this); }