Author: kfujino Date: Tue Jun 6 05:38:44 2017 New Revision: 1797729 URL: http://svn.apache.org/viewvc?rev=1797729&view=rev Log: Backport the JMX support for Tribes component.
Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java (with props) tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java (with props) Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml tomcat/tc8.5.x/trunk/webapps/docs/config/cluster-channel.xml Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes; + +import javax.management.MBeanRegistration; + + +public interface JmxChannel extends MBeanRegistration { + + /** + * If set to true, this channel is registered with jmx. + * @return true if this channel will be registered with jmx. + */ + public boolean isJmxEnabled(); + + /** + * If set to true, this channel is registered with jmx. + * @param jmxEnabled set to true if this channel should be registered with jmx. + */ + public void setJmxEnabled(boolean jmxEnabled); + + /** + * Return the jmx domain which this channel is registered. + * @return jmxDomain + */ + public String getJmxDomain(); + + /** + * Set the jmx domain which this channel should be registered. + * @param jmxDomain The jmx domain which this channel should be registered. + */ + public void setJmxDomain(String jmxDomain); + + /** + * Return the jmx prefix which will be used with channel ObjectName. + * @return jmxPrefix + */ + public String getJmxPrefix(); + + /** + * Set the jmx prefix which will be used with channel ObjectName. + * @param jmxPrefix The jmx prefix which will be used with channel ObjectName. + */ + public void setJmxPrefix(String jmxPrefix); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/JmxChannel.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java Tue Jun 6 05:38:44 2017 @@ -16,11 +16,14 @@ */ package org.apache.catalina.tribes.group; +import javax.management.ObjectName; + import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; import org.apache.catalina.tribes.ChannelInterceptor; import org.apache.catalina.tribes.ChannelMessage; import org.apache.catalina.tribes.Member; +import org.apache.catalina.tribes.jmx.JmxRegistry; /** * Abstract class for the interceptor base class. @@ -33,6 +36,11 @@ public abstract class ChannelInterceptor //default value, always process protected int optionFlag = 0; + /** + * the ObjectName of this ChannelInterceptor. + */ + private ObjectName oname = null; + public ChannelInterceptorBase() { } @@ -155,6 +163,10 @@ public abstract class ChannelInterceptor @Override public void start(int svc) throws ChannelException { if ( getNext()!=null ) getNext().start(svc); + // register jmx + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel); + if (jmxRegistry != null) this.oname = jmxRegistry.registerJmx( + ",component=Interceptor,interceptorName=" + getClass().getSimpleName(), this); } /** @@ -171,6 +183,10 @@ public abstract class ChannelInterceptor @Override public void stop(int svc) throws ChannelException { if (getNext() != null) getNext().stop(svc); + if (oname != null) { + JmxRegistry.getRegistry(channel).unregisterJmx(oname); + oname = null; + } channel = null; } Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java Tue Jun 6 05:38:44 2017 @@ -22,6 +22,9 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import javax.management.MBeanServer; +import javax.management.ObjectName; + import org.apache.catalina.tribes.ByteMessage; import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; @@ -32,6 +35,7 @@ import org.apache.catalina.tribes.Channe import org.apache.catalina.tribes.ChannelSender; import org.apache.catalina.tribes.ErrorHandler; import org.apache.catalina.tribes.Heartbeat; +import org.apache.catalina.tribes.JmxChannel; import org.apache.catalina.tribes.ManagedChannel; import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.MembershipListener; @@ -42,6 +46,7 @@ import org.apache.catalina.tribes.group. import org.apache.catalina.tribes.io.BufferPool; import org.apache.catalina.tribes.io.ChannelData; import org.apache.catalina.tribes.io.XByteBuffer; +import org.apache.catalina.tribes.jmx.JmxRegistry; import org.apache.catalina.tribes.util.Arrays; import org.apache.catalina.tribes.util.Logs; import org.apache.catalina.tribes.util.StringManager; @@ -55,7 +60,9 @@ import org.apache.juli.logging.LogFactor * The channel has an chain of interceptors that can modify the message or perform other logic.<br> * It manages a complete group, both membership and replication. */ -public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel { +public class GroupChannel extends ChannelInterceptorBase + implements ManagedChannel, JmxChannel, GroupChannelMBean { + private static final Log log = LogFactory.getLog(GroupChannel.class); protected static final StringManager sm = StringManager.getManager(GroupChannel.class); @@ -111,6 +118,26 @@ public class GroupChannel extends Channe protected String name = null; /** + * the jmx domain which this channel is registered. + */ + private String jmxDomain = "ClusterChannel"; + + /** + * the jmx prefix which will be used with channel ObjectName. + */ + private String jmxPrefix = ""; + + /** + * If set to true, this channel is registered with jmx. + */ + private boolean jmxEnabled = true; + + /** + * the ObjectName of this channel. + */ + private ObjectName oname = null; + + /** * Creates a GroupChannel. This constructor will also * add the first interceptor in the GroupChannel.<br> * The first interceptor is always the channel itself. @@ -432,6 +459,9 @@ public class GroupChannel extends Channe public synchronized void start(int svc) throws ChannelException { setupDefaultStack(); if (optionCheck) checkOptionFlags(); + // register jmx + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(this); + if (jmxRegistry != null) this.oname = jmxRegistry.registerJmx(",component=Channel", this); super.start(svc); if ( hbthread == null && heartbeat ) { hbthread = new HeartbeatThread(this,heartbeatSleeptime); @@ -452,6 +482,10 @@ public class GroupChannel extends Channe hbthread = null; } super.stop(svc); + if (oname != null) { + JmxRegistry.getRegistry(this).unregisterJmx(oname); + oname = null; + } } /** @@ -640,6 +674,58 @@ public class GroupChannel extends Channe this.name = name; } + @Override + public boolean isJmxEnabled() { + return jmxEnabled; + } + + @Override + public void setJmxEnabled(boolean jmxEnabled) { + this.jmxEnabled = jmxEnabled; + } + + @Override + public String getJmxDomain() { + return jmxDomain; + } + + @Override + public void setJmxDomain(String jmxDomain) { + this.jmxDomain = jmxDomain; + } + + @Override + public String getJmxPrefix() { + return jmxPrefix; + } + + @Override + public void setJmxPrefix(String jmxPrefix) { + this.jmxPrefix = jmxPrefix; + } + + @Override + public ObjectName preRegister(MBeanServer server, ObjectName name) + throws Exception { + // NOOP + return null; + } + + @Override + public void postRegister(Boolean registrationDone) { + // NOOP + } + + @Override + public void preDeregister() throws Exception { + // NOOP + } + + @Override + public void postDeregister() { + JmxRegistry.removeRegistry(this, true); + } + /** * * <p>Title: Interceptor Iterator</p> Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group; + +import java.io.Serializable; + +import org.apache.catalina.tribes.ChannelException; +import org.apache.catalina.tribes.ChannelListener; +import org.apache.catalina.tribes.ErrorHandler; +import org.apache.catalina.tribes.Member; +import org.apache.catalina.tribes.MembershipListener; +import org.apache.catalina.tribes.UniqueId; + +public interface GroupChannelMBean { + + // Attributes + public boolean getOptionCheck(); + + public boolean getHeartbeat(); + + public long getHeartbeatSleeptime(); + + // Operations + public void start(int svc) throws ChannelException; + + public void stop(int svc) throws ChannelException; + + public UniqueId send(Member[] destination, Serializable msg, int options) + throws ChannelException; + + public UniqueId send(Member[] destination, Serializable msg, int options, ErrorHandler handler) + throws ChannelException; + + public void addMembershipListener(MembershipListener listener); + + public void addChannelListener(ChannelListener listener); + + public void removeMembershipListener(MembershipListener listener); + + public void removeChannelListener(ChannelListener listener); + + public boolean hasMembers() ; + + public Member[] getMembers() ; + + public Member getLocalMember(boolean incAlive); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/GroupChannelMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java Tue Jun 6 05:38:44 2017 @@ -35,7 +35,9 @@ import org.apache.juli.logging.LogFactor * * @version 1.0 */ -public class DomainFilterInterceptor extends ChannelInterceptorBase { +public class DomainFilterInterceptor extends ChannelInterceptorBase + implements DomainFilterInterceptorMBean { + private static final Log log = LogFactory.getLog(DomainFilterInterceptor.class); protected static final StringManager sm = StringManager.getManager(DomainFilterInterceptor.class); protected volatile Membership membership = null; @@ -115,6 +117,7 @@ public class DomainFilterInterceptor ext } + @Override public byte[] getDomain() { return domain; } @@ -131,10 +134,12 @@ public class DomainFilterInterceptor ext setDomain(org.apache.catalina.tribes.util.Arrays.convert(domain)); } + @Override public int getLogInterval() { return logInterval; } + @Override public void setLogInterval(int logInterval) { this.logInterval = logInterval; } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group.interceptors; + +public interface DomainFilterInterceptorMBean { + + public int getOptionFlag(); + + public byte[] getDomain(); + + public int getLogInterval(); + + public void setLogInterval(int logInterval); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java Tue Jun 6 05:38:44 2017 @@ -17,6 +17,7 @@ package org.apache.catalina.tribes.group.interceptors; import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -40,7 +41,8 @@ import org.apache.juli.logging.LogFactor * <code>Channel.SEND_OPTIONS_ASYNCHRONOUS</code> flag to be set, if it is, it * will queue the message for delivery and immediately return to the sender. */ -public class MessageDispatchInterceptor extends ChannelInterceptorBase { +public class MessageDispatchInterceptor extends ChannelInterceptorBase + implements MessageDispatchInterceptorMBean { private static final Log log = LogFactory.getLog(MessageDispatchInterceptor.class); protected static final StringManager sm = @@ -144,7 +146,7 @@ public class MessageDispatchInterceptor this.useDeepClone = useDeepClone; } - + @Override public long getMaxQueueSize() { return maxQueueSize; } @@ -154,7 +156,7 @@ public class MessageDispatchInterceptor return useDeepClone; } - + @Override public long getCurrentSize() { return currentSize.get(); } @@ -170,16 +172,17 @@ public class MessageDispatchInterceptor return value; } - + @Override public long getKeepAliveTime() { return keepAliveTime; } - + @Override public int getMaxSpareThreads() { return maxSpareThreads; } + @Override public int getMaxThreads() { return maxThreads; } @@ -199,12 +202,12 @@ public class MessageDispatchInterceptor this.maxThreads = maxThreads; } - + @Override public boolean isAlwaysSend() { return alwaysSend; } - + @Override public void setAlwaysSend(boolean alwaysSend) { this.alwaysSend = alwaysSend; } @@ -276,4 +279,57 @@ public class MessageDispatchInterceptor addAndGetCurrentSize(-msg.getMessage().getLength()); } } + + // ---------------------------------------------- stats of the thread pool + /** + * Return the current number of threads that are managed by the pool. + * @return the current number of threads that are managed by the pool + */ + @Override + public int getPoolSize() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getPoolSize(); + } else { + return -1; + } + } + + /** + * Return the current number of threads that are in use. + * @return the current number of threads that are in use + */ + @Override + public int getActiveCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getActiveCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have ever been scheduled for execution by the pool. + * @return the total number of tasks that have ever been scheduled for execution by the pool + */ + @Override + public long getTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getTaskCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have completed execution by the pool. + * @return the total number of tasks that have completed execution by the pool + */ + @Override + public long getCompletedTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getCompletedTaskCount(); + } else { + return -1; + } + } } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group.interceptors; + +public interface MessageDispatchInterceptorMBean { + + public int getOptionFlag(); + + public boolean isAlwaysSend(); + + public void setAlwaysSend(boolean alwaysSend); + + public long getMaxQueueSize(); + + public long getCurrentSize(); + + public long getKeepAliveTime(); + + public int getMaxSpareThreads(); + + public int getMaxThreads(); + + // pool stats + public int getPoolSize(); + + public int getActiveCount(); + + public long getTaskCount(); + + public long getCompletedTaskCount(); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java Tue Jun 6 05:38:44 2017 @@ -32,7 +32,8 @@ import org.apache.catalina.tribes.util.S import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -public class StaticMembershipInterceptor extends ChannelInterceptorBase { +public class StaticMembershipInterceptor extends ChannelInterceptorBase + implements StaticMembershipInterceptorMBean { private static final Log log = LogFactory.getLog(StaticMembershipInterceptor.class); protected static final StringManager sm = Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group.interceptors; + +import org.apache.catalina.tribes.Member; + +public interface StaticMembershipInterceptorMBean { + + public int getOptionFlag(); + + public Member getLocalMember(boolean incAlive); +} \ No newline at end of file Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java Tue Jun 6 05:38:44 2017 @@ -59,7 +59,7 @@ import org.apache.juli.logging.LogFactor * * @version 1.0 */ -public class TcpFailureDetector extends ChannelInterceptorBase { +public class TcpFailureDetector extends ChannelInterceptorBase implements TcpFailureDetectorMBean { private static final Log log = LogFactory.getLog(TcpFailureDetector.class); protected static final StringManager sm = StringManager.getManager(TcpFailureDetector.class); @@ -218,6 +218,7 @@ public class TcpFailureDetector extends checkMembers(false); } + @Override public void checkMembers(boolean checkAll) { try { if (membership == null) setupMembership(); @@ -360,42 +361,52 @@ public class TcpFailureDetector extends return false; } + @Override public long getReadTestTimeout() { return readTestTimeout; } + @Override public boolean getPerformSendTest() { return performSendTest; } + @Override public boolean getPerformReadTest() { return performReadTest; } + @Override public long getConnectTimeout() { return connectTimeout; } + @Override public int getRemoveSuspectsTimeout() { return removeSuspectsTimeout; } + @Override public void setPerformReadTest(boolean performReadTest) { this.performReadTest = performReadTest; } + @Override public void setPerformSendTest(boolean performSendTest) { this.performSendTest = performSendTest; } + @Override public void setReadTestTimeout(long readTestTimeout) { this.readTestTimeout = readTestTimeout; } + @Override public void setConnectTimeout(long connectTimeout) { this.connectTimeout = connectTimeout; } + @Override public void setRemoveSuspectsTimeout(int removeSuspectsTimeout) { this.removeSuspectsTimeout = removeSuspectsTimeout; } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group.interceptors; + +public interface TcpFailureDetectorMBean { + + public int getOptionFlag(); + + // Attributes + public long getConnectTimeout(); + + public boolean getPerformSendTest(); + + public boolean getPerformReadTest(); + + public long getReadTestTimeout(); + + public int getRemoveSuspectsTimeout(); + + public void setPerformReadTest(boolean performReadTest); + + public void setPerformSendTest(boolean performSendTest); + + public void setReadTestTimeout(long readTestTimeout); + + public void setConnectTimeout(long connectTimeout); + + public void setRemoveSuspectsTimeout(int removeSuspectsTimeout); + + // Operations + public void checkMembers(boolean checkAll); +} \ No newline at end of file Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetectorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java Tue Jun 6 05:38:44 2017 @@ -40,7 +40,7 @@ import org.apache.juli.logging.LogFactor * @version 1.0 */ -public class TcpPingInterceptor extends ChannelInterceptorBase { +public class TcpPingInterceptor extends ChannelInterceptorBase implements TcpPingInterceptorMBean { private static final Log log = LogFactory.getLog(TcpPingInterceptor.class); protected static final StringManager sm = StringManager.getManager(TcpPingInterceptor.class); @@ -103,6 +103,7 @@ public class TcpPingInterceptor extends if (!getUseThread()) sendPing(); } + @Override public long getInterval() { return interval; } @@ -119,6 +120,7 @@ public class TcpPingInterceptor extends this.staticOnly = staticOnly; } + @Override public boolean getUseThread() { return useThread; } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.catalina.tribes.group.interceptors; + +public interface TcpPingInterceptorMBean { + + public int getOptionFlag(); + + public long getInterval(); + + public boolean getUseThread(); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java Tue Jun 6 05:38:44 2017 @@ -38,7 +38,9 @@ import org.apache.juli.logging.LogFactor * * @version 1.0 */ -public class ThroughputInterceptor extends ChannelInterceptorBase { +public class ThroughputInterceptor extends ChannelInterceptorBase + implements ThroughputInterceptorMBean { + private static final Log log = LogFactory.getLog(ThroughputInterceptor.class); protected static final StringManager sm = StringManager.getManager(ThroughputInterceptor.class); @@ -92,6 +94,7 @@ public class ThroughputInterceptor exten } + @Override public void report(double timeTx) { if ( log.isInfoEnabled() ) log.info(sm.getString("throughputInterceptor.report", @@ -100,50 +103,62 @@ public class ThroughputInterceptor exten df.format(mbRx))); } + @Override public void setInterval(int interval) { this.interval = interval; } + @Override public int getInterval() { return interval; } + @Override public double getLastCnt() { return lastCnt; } + @Override public double getMbAppTx() { return mbAppTx; } + @Override public double getMbRx() { return mbRx; } + @Override public double getMbTx() { return mbTx; } + @Override public AtomicLong getMsgRxCnt() { return msgRxCnt; } + @Override public AtomicLong getMsgTxCnt() { return msgTxCnt; } + @Override public AtomicLong getMsgTxErr() { return msgTxErr; } + @Override public long getRxStart() { return rxStart; } + @Override public double getTimeTx() { return timeTx; } + @Override public long getTxStart() { return txStart; } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.group.interceptors; + +import java.util.concurrent.atomic.AtomicLong; + +public interface ThroughputInterceptorMBean { + + public int getOptionFlag(); + + // Attributes + public int getInterval(); + + public void setInterval(int interval); + + // stats + public double getLastCnt(); + + public double getMbAppTx(); + + public double getMbRx(); + + public double getMbTx(); + + public AtomicLong getMsgRxCnt(); + + public AtomicLong getMsgTxCnt(); + + public AtomicLong getMsgTxErr(); + + public long getRxStart(); + + public double getTimeTx(); + + public long getTxStart(); + + // Operations + public void report(double timeTx); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptorMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.jmx; + +import java.lang.management.ManagementFactory; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import javax.management.InstanceNotFoundException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectName; + +import org.apache.catalina.tribes.Channel; +import org.apache.catalina.tribes.JmxChannel; +import org.apache.catalina.tribes.util.StringManager; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; + +public class JmxRegistry { + + private static final Log log = LogFactory.getLog(JmxRegistry.class); + protected static final StringManager sm = StringManager.getManager(JmxRegistry.class); + private static ConcurrentHashMap<String, JmxRegistry> registryCache = new ConcurrentHashMap<>(); + + private MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); + private ObjectName baseOname = null; + + private JmxRegistry() { + } + + public static JmxRegistry getRegistry(Channel channel) { + if (channel == null || channel.getName() == null) { + return null; + } + JmxRegistry registry = registryCache.get(channel.getName()); + if (registry != null) return registry; + + if (!(channel instanceof JmxChannel)) return null; + JmxChannel jmxChannel = (JmxChannel) channel; + if (!jmxChannel.isJmxEnabled()) return null; + ObjectName baseOn = createBaseObjectName(jmxChannel.getJmxDomain(), + jmxChannel.getJmxPrefix(), channel.getName()); + if (baseOn == null) return null; + // create registry + registry = new JmxRegistry(); + registry.baseOname = baseOn; + registryCache.putIfAbsent(channel.getName(), registry); + return registry; + } + + public static void removeRegistry(Channel channel, boolean clear) { + JmxRegistry registry = registryCache.get(channel.getName()); + if (registry == null) return; + if (clear) { + registry.clearMBeans(); + } + registryCache.remove(channel.getName()); + } + + private static ObjectName createBaseObjectName(String domain, String prefix, String name) { + if (domain == null) { + log.warn(sm.getString("jmxRegistry.no.domain")); + return null; + } + ObjectName on = null; + StringBuilder sb = new StringBuilder(domain); + sb.append(':'); + sb.append(prefix); + sb.append("type=Channel,channel="); + sb.append(name); + try { + on = new ObjectName(sb.toString()); + } catch (MalformedObjectNameException e) { + log.error(sm.getString("jmxRegistry.objectName.failed", sb.toString()), e); + } + return on; + } + + public ObjectName registerJmx(String keyprop, Object bean) { + String oNameStr = baseOname.toString() + keyprop; + ObjectName oName = null; + try { + oName = new ObjectName(oNameStr); + if (mbserver.isRegistered(oName)) { + mbserver.unregisterMBean(oName); + } + mbserver.registerMBean(bean, oName); + } catch (NotCompliantMBeanException e) { + log.warn(sm.getString("jmxRegistry.registerJmx.notCompliant", bean), e); + return null; + } catch (MalformedObjectNameException e) { + log.error(sm.getString("jmxRegistry.objectName.failed", oNameStr), e); + return null; + } catch (Exception e) { + log.error(sm.getString("jmxRegistry.registerJmx.failed", bean, oNameStr), e); + return null; + } + return oName; + } + + public void unregisterJmx(ObjectName oname) { + if (oname ==null) return; + try { + mbserver.unregisterMBean(oname); + } catch (InstanceNotFoundException e) { + log.warn(sm.getString("jmxRegistry.unregisterJmx.notFound", oname), e); + } catch (Exception e) { + log.warn(sm.getString("jmxRegistry.unregisterJmx.failed", oname), e); + } + } + + private void clearMBeans() { + String query = baseOname.toString() + ",*"; + try { + ObjectName name = new ObjectName(query); + Set<ObjectName> onames = mbserver.queryNames(name, null); + for (ObjectName objectName : onames) { + unregisterJmx(objectName); + } + } catch (MalformedObjectNameException e) { + log.error(sm.getString("jmxRegistry.objectName.failed", query), e); + } + } + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/JmxRegistry.java ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties Tue Jun 6 05:38:44 2017 @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +jmxRegistry.no.domain=JMX domain is not specified +jmxRegistry.objectName.failed=The requested ObjectName [{0}] is not valid +jmxRegistry.registerJmx.notCompliant=The requested object[{0}] is not compliant with JMX specification +jmxRegistry.registerJmx.failed=Failed to register object [{0}] with name [{1}] +jmxRegistry.unregisterJmx.notFound=The requested ObjectName [{0}] has not been registered in the MBeanServer +jmxRegistry.unregisterJmx.failed=Failed to unregister MBean with name [{0}] \ No newline at end of file Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/jmx/LocalStrings.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java Tue Jun 6 05:38:44 2017 @@ -21,6 +21,8 @@ import java.io.IOException; import java.net.DatagramPacket; import java.util.Properties; +import javax.management.ObjectName; + import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; import org.apache.catalina.tribes.ChannelMessage; @@ -30,6 +32,7 @@ import org.apache.catalina.tribes.Member import org.apache.catalina.tribes.MessageListener; import org.apache.catalina.tribes.io.ChannelData; import org.apache.catalina.tribes.io.XByteBuffer; +import org.apache.catalina.tribes.jmx.JmxRegistry; import org.apache.catalina.tribes.util.Arrays; import org.apache.catalina.tribes.util.StringManager; import org.apache.catalina.tribes.util.UUIDGenerator; @@ -42,7 +45,8 @@ import org.apache.juli.logging.LogFactor * This class is responsible for maintaining a list of active cluster nodes in the cluster. * If a node fails to send out a heartbeat, the node will be dismissed. */ -public class McastService implements MembershipService,MembershipListener,MessageListener { +public class McastService + implements MembershipService,MembershipListener,MessageListener, McastServiceMBean { private static final Log log = LogFactory.getLog(McastService.class); @@ -81,6 +85,11 @@ public class McastService implements Mem private Channel channel; /** + * the ObjectName of this McastService. + */ + private ObjectName oname = null; + + /** * Create a membership service. */ public McastService() { @@ -172,6 +181,7 @@ public class McastService implements Mem properties.setProperty("mcastAddress", addr); } + @Override public String getAddress() { return properties.getProperty("mcastAddress"); } @@ -184,6 +194,7 @@ public class McastService implements Mem properties.setProperty("mcastBindAddress", bindaddr); } + @Override public String getBind() { return properties.getProperty("mcastBindAddress"); } @@ -196,6 +207,7 @@ public class McastService implements Mem properties.setProperty("recoveryCounter", String.valueOf(recoveryCounter)); } + @Override public int getRecoveryCounter(){ String p = properties.getProperty("recoveryCounter"); if(p != null){ @@ -208,6 +220,7 @@ public class McastService implements Mem properties.setProperty("recoveryEnabled", String.valueOf(recoveryEnabled)); } + @Override public boolean getRecoveryEnabled() { String p = properties.getProperty("recoveryEnabled"); if(p != null){ @@ -220,6 +233,7 @@ public class McastService implements Mem properties.setProperty("recoverySleepTime", String.valueOf(recoverySleepTime)); } + @Override public long getRecoverySleepTime(){ String p = properties.getProperty("recoverySleepTime"); if(p != null){ @@ -232,6 +246,7 @@ public class McastService implements Mem properties.setProperty("localLoopbackDisabled",String.valueOf(localLoopbackDisabled)); } + @Override public boolean getLocalLoopbackDisabled() { String p = properties.getProperty("localLoopbackDisabled"); if(p != null){ @@ -240,6 +255,7 @@ public class McastService implements Mem return false; } + @Override public int getPort() { String p = properties.getProperty("mcastPort"); return Integer.parseInt(p); @@ -249,6 +265,7 @@ public class McastService implements Mem properties.setProperty("mcastFrequency", String.valueOf(time)); } + @Override public long getFrequency() { String p = properties.getProperty("mcastFrequency"); return Long.parseLong(p); @@ -261,6 +278,7 @@ public class McastService implements Mem properties.setProperty("memberDropTime", String.valueOf(time)); } + @Override public long getDropTime() { String p = properties.getProperty("memberDropTime"); return Long.parseLong(p); @@ -363,7 +381,11 @@ public class McastService implements Mem impl.setChannel(channel); impl.start(level); - + // register jmx + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel); + if (jmxRegistry != null) { + this.oname = jmxRegistry.registerJmx(",component=Membership", this); + } } @@ -375,6 +397,10 @@ public class McastService implements Mem public void stop(int svc) { try { if ( impl != null && impl.stop(svc) ) { + if (oname != null) { + JmxRegistry.getRegistry(channel).unregisterJmx(oname); + oname = null; + } impl.setChannel(null); impl = null; channel = null; @@ -513,6 +539,7 @@ public class McastService implements Mem } } + @Override public int getSoTimeout() { return mcastSoTimeout; } @@ -522,6 +549,7 @@ public class McastService implements Mem properties.setProperty("mcastSoTimeout", String.valueOf(mcastSoTimeout)); } + @Override public int getTtl() { return mcastTTL; } Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.membership; + +import java.util.Properties; + +import org.apache.catalina.tribes.Member; + +public interface McastServiceMBean { + + // Attributes + public String getAddress(); + + public int getPort(); + + public long getFrequency(); + + public long getDropTime(); + + public String getBind(); + + public int getTtl(); + + public byte[] getDomain(); + + public int getSoTimeout(); + + public boolean getRecoveryEnabled(); + + public int getRecoveryCounter(); + + public long getRecoverySleepTime(); + + public boolean getLocalLoopbackDisabled(); + + public String getLocalMemberName(); + + // Operation + public Properties getProperties(); + + public boolean hasMembers(); + + public String[] getMembersByName(); + + public Member findMemberByName(String name); +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java Tue Jun 6 05:38:44 2017 @@ -23,14 +23,18 @@ import java.net.InetSocketAddress; import java.net.ServerSocket; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import javax.management.ObjectName; + import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelMessage; import org.apache.catalina.tribes.ChannelReceiver; import org.apache.catalina.tribes.MessageListener; import org.apache.catalina.tribes.io.ListenCallback; +import org.apache.catalina.tribes.jmx.JmxRegistry; import org.apache.catalina.tribes.util.ExecutorFactory; import org.apache.catalina.tribes.util.StringManager; import org.apache.juli.logging.Log; @@ -82,6 +86,11 @@ public abstract class ReceiverBase imple private ExecutorService executor; private Channel channel; + /** + * the ObjectName of this Receiver. + */ + private ObjectName oname = null; + public ReceiverBase() { } @@ -94,12 +103,20 @@ public abstract class ReceiverBase imple TaskThreadFactory tf = new TaskThreadFactory("Tribes-Task-Receiver" + channelName + "-"); executor = ExecutorFactory.newThreadPool(minThreads, maxThreads, maxIdleTime, TimeUnit.MILLISECONDS, tf); } + // register jmx + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel); + if (jmxRegistry != null) this.oname = jmxRegistry.registerJmx(",component=Receiver", this); } @Override public void stop() { if ( executor != null ) executor.shutdownNow();//ignore left overs executor = null; + if (oname != null) { + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel); + if (jmxRegistry != null) jmxRegistry.unregisterJmx(oname); + oname = null; + } channel = null; } @@ -500,6 +517,55 @@ public abstract class ReceiverBase imple this.channel = channel; } + // ---------------------------------------------- stats of the thread pool + /** + * Return the current number of threads that are managed by the pool. + * @return the current number of threads that are managed by the pool + */ + public int getPoolSize() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getPoolSize(); + } else { + return -1; + } + } + + /** + * Return the current number of threads that are in use. + * @return the current number of threads that are in use + */ + public int getActiveCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getActiveCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have ever been scheduled for execution by the pool. + * @return the total number of tasks that have ever been scheduled for execution by the pool + */ + public long getTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getTaskCount(); + } else { + return -1; + } + } + + /** + * Return the total number of tasks that have completed execution by the pool. + * @return the total number of tasks that have completed execution by the pool + */ + public long getCompletedTaskCount() { + if (executor instanceof ThreadPoolExecutor) { + return ((ThreadPoolExecutor) executor).getCompletedTaskCount(); + } else { + return -1; + } + } + // ---------------------------------------------- ThreadFactory Inner Class class TaskThreadFactory implements ThreadFactory { final ThreadGroup group; Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java Tue Jun 6 05:38:44 2017 @@ -16,11 +16,14 @@ */ package org.apache.catalina.tribes.transport; +import javax.management.ObjectName; + import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; import org.apache.catalina.tribes.ChannelMessage; import org.apache.catalina.tribes.ChannelSender; import org.apache.catalina.tribes.Member; +import org.apache.catalina.tribes.jmx.JmxRegistry; import org.apache.catalina.tribes.transport.nio.PooledParallelSender; /** @@ -32,6 +35,11 @@ public class ReplicationTransmitter impl private Channel channel; + /** + * the ObjectName of this Sender. + */ + private ObjectName oname = null; + public ReplicationTransmitter() { } @@ -66,6 +74,9 @@ public class ReplicationTransmitter impl @Override public void start() throws java.io.IOException { getTransport().connect(); + // register jmx + JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel); + if (jmxRegistry != null) this.oname = jmxRegistry.registerJmx(",component=Sender", transport); } /** @@ -76,6 +87,10 @@ public class ReplicationTransmitter impl @Override public synchronized void stop() { getTransport().disconnect(); + if (oname != null) { + JmxRegistry.getRegistry(channel).unregisterJmx(oname); + oname = null; + } channel = null; } Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java Tue Jun 6 05:38:44 2017 @@ -42,7 +42,7 @@ import org.apache.catalina.tribes.util.S import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -public class NioReceiver extends ReceiverBase implements Runnable { +public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMBean { private static final Log log = LogFactory.getLog(NioReceiver.class); Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.catalina.tribes.transport.nio; + + +public interface NioReceiverMBean { + + // Receiver Attributes + public String getAddress(); + + public boolean getDirect(); + + public int getPort(); + + public int getAutoBind(); + + public int getSecurePort(); + + public int getUdpPort(); + + public long getSelectorTimeout(); + + public int getMaxThreads(); + + public int getMinThreads(); + + public long getMaxIdleTime(); + + public boolean getOoBInline(); + + public int getRxBufSize(); + + public int getTxBufSize(); + + public int getUdpRxBufSize(); + + public int getUdpTxBufSize(); + + public boolean getSoKeepAlive(); + + public boolean getSoLingerOn(); + + public int getSoLingerTime(); + + public boolean getSoReuseAddress(); + + public boolean getTcpNoDelay(); + + public int getTimeout(); + + public boolean getUseBufferPool(); + + public boolean isListening(); + + // pool stats + public int getPoolSize(); + + public int getActiveCount(); + + public long getTaskCount(); + + public long getCompletedTaskCount(); + +} Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiverMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java Tue Jun 6 05:38:44 2017 @@ -26,7 +26,7 @@ import org.apache.catalina.tribes.transp import org.apache.catalina.tribes.transport.PooledSender; import org.apache.catalina.tribes.util.StringManager; -public class PooledParallelSender extends PooledSender { +public class PooledParallelSender extends PooledSender implements PooledParallelSenderMBean { protected static final StringManager sm = StringManager.getManager(PooledParallelSender.class); @Override Added: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java?rev=1797729&view=auto ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java (added) +++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java Tue Jun 6 05:38:44 2017 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.transport.nio; + +public interface PooledParallelSenderMBean { + + // Transport Attributes + public int getRxBufSize(); + + public int getTxBufSize(); + + public int getUdpRxBufSize(); + + public int getUdpTxBufSize(); + + public boolean getDirectBuffer(); + + public int getKeepAliveCount(); + + public long getKeepAliveTime(); + + public long getTimeout(); + + public int getMaxRetryAttempts(); + + public boolean getOoBInline(); + + public boolean getSoKeepAlive(); + + public boolean getSoLingerOn(); + + public int getSoLingerTime(); + + public boolean getSoReuseAddress(); + + public int getSoTrafficClass(); + + public boolean getTcpNoDelay(); + + public boolean getThrowOnFailedAck(); + + // PooledSender Attributes + public int getPoolSize(); + + public long getMaxWait(); + + // Operation + public boolean isConnected(); + + public int getInPoolSize(); + + public int getInUsePoolSize(); + +} \ No newline at end of file Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSenderMBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Tue Jun 6 05:38:44 2017 @@ -113,6 +113,13 @@ </add> </changelog> </subsection> + <subsection name="Tribes"> + <changelog> + <add> + Add JMX support for Tribes components. (kfujino) + </add> + </changelog> + </subsection> <subsection name="Other"> <changelog> <add> Modified: tomcat/tc8.5.x/trunk/webapps/docs/config/cluster-channel.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/config/cluster-channel.xml?rev=1797729&r1=1797728&r2=1797729&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/webapps/docs/config/cluster-channel.xml (original) +++ tomcat/tc8.5.x/trunk/webapps/docs/config/cluster-channel.xml Tue Jun 6 05:38:44 2017 @@ -118,6 +118,22 @@ flag. The default is false. </attribute> + <attribute name="jmxEnabled" required="false"> + Flag whether the channel components register with JMX or not. + The default value is true. + </attribute> + + <attribute name="jmxDomain" required="false"> + if <code>jmxEnabled</code> set to true, specifies the jmx domain which + this channel should be registered. The ClusterChannel is used as the + default value. + </attribute> + + <attribute name="jmxPrefix" required="false"> + if <code>jmxEnabled</code> set to true, specifies the jmx prefix which + will be used with channel ObjectName. + </attribute> + </attributes> </subsection> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org