| Method from org.apache.catalina.tribes.transport.ReceiverBase Detail: |
protected int bind(ServerSocket socket,
int portstart,
int retries) throws IOException {
InetSocketAddress addr = null;
while ( retries > 0 ) {
try {
addr = new InetSocketAddress(getBind(), portstart);
socket.bind(addr);
setPort(portstart);
log.info("Receiver Server Socket bound to:"+addr);
return 0;
}catch ( IOException x) {
retries--;
if ( retries < = 0 ) {
log.info("Unable to bind server socket to:"+addr+" throwing error.");
throw x;
}
portstart++;
try {Thread.sleep(25);}catch( InterruptedException ti){Thread.currentThread().interrupted();}
retries = bind(socket,portstart,retries);
}
}
return retries;
}
recursive bind to find the next available port |
public boolean doListen() {
return listen;
}
|
public String getAddress() {
getBind();
return this.host;
}
|
public int getAutoBind() {
return autoBind;
}
|
public InetAddress getBind() {
if (bind == null) {
try {
if ("auto".equals(host)) {
host = java.net.InetAddress.getLocalHost().getHostAddress();
}
if (log.isDebugEnabled())
log.debug("Starting replication listener on address:"+ host);
bind = java.net.InetAddress.getByName(host);
} catch (IOException ioe) {
log.error("Failed bind replication listener on address:"+ host, ioe);
}
}
return bind;
}
|
public boolean getDirect() {
return direct;
}
|
public ExecutorService getExecutor() {
return executor;
}
|
public String getHost() {
return getAddress();
}
|
public MessageListener getListener() {
return listener;
}
|
public int getMaxTasks() {
return maxTasks;
}
|
public int getMaxThreads() {
return maxThreads;
}
|
public MessageListener getMessageListener() {
return listener;
}
|
public int getMinTasks() {
return minTasks;
}
|
public int getMinThreads() {
return minThreads;
}
|
public boolean getOoBInline() {
return ooBInline;
}
|
public int getPort() {
return port;
}
|
public int getRxBufSize() {
return rxBufSize;
}
|
public int getSecurePort() {
return securePort;
}
|
public long getSelectorTimeout() {
return tcpSelectorTimeout;
}
|
public boolean getSoKeepAlive() {
return soKeepAlive;
}
|
public boolean getSoLingerOn() {
return soLingerOn;
}
|
public int getSoLingerTime() {
return soLingerTime;
}
|
public boolean getSoReuseAddress() {
return soReuseAddress;
}
|
public int getSoTrafficClass() {
return soTrafficClass;
}
|
public RxTaskPool getTaskPool() {
return pool;
}
|
public String getTcpListenAddress() {
return getAddress();
} Deprecated! use - getAddress
|
public int getTcpListenPort() {
return getPort();
} Deprecated! use - getPort
|
public boolean getTcpNoDelay() {
return tcpNoDelay;
}
|
public long getTcpSelectorTimeout() {
return getSelectorTimeout();
} Deprecated! use - getSelectorTimeout
|
public int getTcpThreadCount() {
return getMaxThreads();
} Deprecated! use - getMinThreads()/getMaxThreads()
|
public int getTimeout() {
return timeout;
}
|
public int getTxBufSize() {
return txBufSize;
}
|
public boolean getUseBufferPool() {
return useBufferPool;
}
|
public int getWorkerThreadOptions() {
int options = 0;
if ( getDirect() ) options = options | OPTION_DIRECT_BUFFER;
return options;
}
|
public void heartbeat() {
//empty operation
}
|
public boolean isListening() {
return listen;
}
|
public void messageDataReceived(ChannelMessage data) {
if ( this.listener != null ) {
if ( listener.accept(data) ) listener.messageReceived(data);
}
}
|
public void setAddress(String host) {
this.host = host;
}
|
public void setAutoBind(int autoBind) {
this.autoBind = autoBind;
if ( this.autoBind < = 0 ) this.autoBind = 1;
}
|
public void setBind(InetAddress bind) {
this.bind = bind;
}
|
public void setDirect(boolean direct) {
this.direct = direct;
}
|
public void setExecutor(ExecutorService executor) {
this.executor = executor;
}
|
public void setHost(String host) {
setAddress(host);
}
|
public void setListen(boolean doListen) {
this.listen = doListen;
}
|
public void setListener(MessageListener listener) {
this.listener = listener;
}
|
public void setLog(Log log) {
this.log = log;
}
|
public void setMaxTasks(int maxTasks) {
this.maxTasks = maxTasks;
}
|
public void setMaxThreads(int maxThreads) {
this.maxThreads = maxThreads;
}
|
public void setMessageListener(MessageListener listener) {
this.listener = listener;
}
|
public void setMinTasks(int minTasks) {
this.minTasks = minTasks;
}
|
public void setMinThreads(int minThreads) {
this.minThreads = minThreads;
}
|
public void setOoBInline(boolean ooBInline) {
this.ooBInline = ooBInline;
}
|
public void setPool(RxTaskPool pool) {
this.pool = pool;
}
|
public void setPort(int port) {
this.port = port;
}
|
public void setRxBufSize(int rxBufSize) {
this.rxBufSize = rxBufSize;
}
|
public void setSecurePort(int securePort) {
this.securePort = securePort;
}
|
public void setSelectorTimeout(long selTimeout) {
tcpSelectorTimeout = selTimeout;
}
|
public void setSoKeepAlive(boolean soKeepAlive) {
this.soKeepAlive = soKeepAlive;
}
|
public void setSoLingerOn(boolean soLingerOn) {
this.soLingerOn = soLingerOn;
}
|
public void setSoLingerTime(int soLingerTime) {
this.soLingerTime = soLingerTime;
}
|
public void setSoReuseAddress(boolean soReuseAddress) {
this.soReuseAddress = soReuseAddress;
}
|
public void setSoTrafficClass(int soTrafficClass) {
this.soTrafficClass = soTrafficClass;
}
|
public void setTcpListenAddress(String tcpListenHost) {
setAddress(tcpListenHost);
} Deprecated! use - setAddress
|
public void setTcpListenPort(int tcpListenPort) {
setPort(tcpListenPort);
} Deprecated! use - setPort
|
public void setTcpNoDelay(boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
}
|
public void setTcpSelectorTimeout(long selTimeout) {
setSelectorTimeout(selTimeout);
} Deprecated! use - setSelectorTimeout
|
public void setTcpThreadCount(int tcpThreadCount) {
setMaxThreads(tcpThreadCount);
setMinThreads(tcpThreadCount);
} Deprecated! use - setMaxThreads/setMinThreads
|
public void setTimeout(int timeout) {
this.timeout = timeout;
}
|
public void setTxBufSize(int txBufSize) {
this.txBufSize = txBufSize;
}
|
public void setUseBufferPool(boolean useBufferPool) {
this.useBufferPool = useBufferPool;
}
|
public void start() throws IOException {
if ( executor == null ) {
executor = new ThreadPoolExecutor(minThreads,maxThreads,60,TimeUnit.SECONDS,new LinkedBlockingQueue< Runnable >());
}
}
|
public void stop() {
if ( executor != null ) executor.shutdownNow();//ignore left overs
executor = null;
}
|