package org.apache.catalina.tribes.group.interceptors;
+import java.text.DecimalFormat;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.apache.catalina.tribes.ChannelException;
import org.apache.catalina.tribes.ChannelMessage;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.group.InterceptorPayload;
import org.apache.catalina.tribes.io.ChannelData;
import org.apache.catalina.tribes.io.XByteBuffer;
-import java.text.DecimalFormat;
-import org.apache.catalina.tribes.membership.MemberImpl;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
super.sendMessage(destination, msg, payload);
}catch ( ChannelException x ) {
msgTxErr.addAndGet(1);
- access.addAndGet(-1);
+ if ( access.get() == 1 ) access.addAndGet(-1);
throw x;
}
mbTx += ((double)(bytes*destination.length))/(1024d*1024d);
return interval;
}
+ public double getLastCnt() {
+ return lastCnt;
+ }
+
+ public double getMbAppTx() {
+ return mbAppTx;
+ }
+
+ public double getMbRx() {
+ return mbRx;
+ }
+
+ public double getMbTx() {
+ return mbTx;
+ }
+
+ public AtomicLong getMsgRxCnt() {
+ return msgRxCnt;
+ }
+
+ public AtomicLong getMsgTxCnt() {
+ return msgTxCnt;
+ }
+
+ public AtomicLong getMsgTxErr() {
+ return msgTxErr;
+ }
+
+ public long getRxStart() {
+ return rxStart;
+ }
+
+ public double getTimeTx() {
+ return timeTx;
+ }
+
+ public long getTxStart() {
+ return txStart;
+ }
+
}
import java.util.LinkedList;
import java.util.Set;
import java.nio.channels.CancelledKeyException;
+import java.nio.channels.ClosedSelectorException;
/**
* @author Filip Hanik
}
serverChannel.close();
- if (selector != null)
- selector.close();
+ closeSelector();
}
if (selector != null) {
try {
selector.wakeup();
- selector.close();
+ closeSelector();
} catch (Exception x) {
log.error("Unable to close cluster receiver selector.", x);
} finally {
}
}
+ private void closeSelector() throws IOException {
+ Selector selector = this.selector;
+ this.selector = null;
+ if (selector==null) return;
+ try {
+ Iterator it = selector.keys().iterator();
+ // look at each key in the selected set
+ while (it.hasNext()) {
+ SelectionKey key = (SelectionKey)it.next();
+ key.channel().close();
+ key.attach(null);
+ key.cancel();
+ }
+ }catch ( IOException ignore ){
+ if (log.isWarnEnabled()) {
+ log.warn("Unable to cleanup on selector close.",ignore);
+ }
+ }catch ( ClosedSelectorException ignore){}
+ selector.close();
+ }
+
// ----------------------------------------------------------
/**