This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 7094596844 Code-clean-up - formatting. No functional change.
7094596844 is described below
commit 70945968440bc5163f0e4db737cea59412722923
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Aug 8 13:43:32 2023 +0100
Code-clean-up - formatting. No functional change.
Files missed when package was re-formatted
---
java/org/apache/catalina/ha/CatalinaCluster.java | 16 +-
.../apache/catalina/ha/tcp/SendMessageData.java | 15 +-
.../apache/catalina/ha/tcp/SimpleTcpCluster.java | 170 ++++++++++-----------
3 files changed, 99 insertions(+), 102 deletions(-)
diff --git a/java/org/apache/catalina/ha/CatalinaCluster.java
b/java/org/apache/catalina/ha/CatalinaCluster.java
index 7246d586d9..af53bbaca0 100644
--- a/java/org/apache/catalina/ha/CatalinaCluster.java
+++ b/java/org/apache/catalina/ha/CatalinaCluster.java
@@ -26,14 +26,14 @@ import org.apache.catalina.tribes.Member;
/**
- * A <b>CatalinaCluster</b> interface allows to plug in and out the
- * different cluster implementations
+ * A <b>CatalinaCluster</b> interface allows to plug in and out the different
cluster implementations
*/
public interface CatalinaCluster extends Cluster {
// ----------------------------------------------------- Instance Variables
/**
* Sends a message to all the members in the cluster
+ *
* @param msg ClusterMessage
*/
void send(ClusterMessage msg);
@@ -41,7 +41,7 @@ public interface CatalinaCluster extends Cluster {
/**
* Sends a message to a specific member in the cluster.
*
- * @param msg ClusterMessage
+ * @param msg ClusterMessage
* @param dest Member
*/
void send(ClusterMessage msg, Member dest);
@@ -49,8 +49,8 @@ public interface CatalinaCluster extends Cluster {
/**
* Sends a message with the specified sendOptions to a specific member in
the cluster.
*
- * @param msg ClusterMessage
- * @param dest Member
+ * @param msg ClusterMessage
+ * @param dest Member
* @param sendOptions sendOptions
*/
void send(ClusterMessage msg, Member dest, int sendOptions);
@@ -87,15 +87,19 @@ public interface CatalinaCluster extends Cluster {
/**
* Get Manager
+ *
* @param name The manager name
+ *
* @return The manager
*/
Manager getManager(String name);
/**
* Get a new cluster name for a manager.
- * @param name Override name (optional)
+ *
+ * @param name Override name (optional)
* @param manager The manager
+ *
* @return the manager name in the cluster
*/
String getManagerName(String name, Manager manager);
diff --git a/java/org/apache/catalina/ha/tcp/SendMessageData.java
b/java/org/apache/catalina/ha/tcp/SendMessageData.java
index 5f1fc12c30..12e3a54429 100644
--- a/java/org/apache/catalina/ha/tcp/SendMessageData.java
+++ b/java/org/apache/catalina/ha/tcp/SendMessageData.java
@@ -23,18 +23,17 @@ import org.apache.catalina.tribes.Member;
*/
public class SendMessageData {
- private Object message ;
- private Member destination ;
- private Exception exception ;
+ private Object message;
+ private Member destination;
+ private Exception exception;
/**
- * @param message The message to send
+ * @param message The message to send
* @param destination Member destination
- * @param exception Associated error
+ * @param exception Associated error
*/
- public SendMessageData(Object message, Member destination,
- Exception exception) {
+ public SendMessageData(Object message, Member destination, Exception
exception) {
super();
this.message = message;
this.destination = destination;
@@ -47,12 +46,14 @@ public class SendMessageData {
public Member getDestination() {
return destination;
}
+
/**
* @return the exception.
*/
public Exception getException() {
return exception;
}
+
/**
* @return the message.
*/
diff --git a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
index 3f01ebf0eb..a970df0d7e 100644
--- a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
+++ b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
@@ -58,17 +58,14 @@ import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
/**
- * A <b>Cluster </b> implementation using simple multicast. Responsible for
- * setting up a cluster and provides callers with a valid multicast
- * receiver/sender.
- *
- * FIXME wrote testcases
+ * A <b>Cluster </b> implementation using simple multicast. Responsible for
setting up a cluster and provides callers
+ * with a valid multicast receiver/sender. FIXME wrote testcases
*
* @author Remy Maucherat
* @author Peter Rossbach
*/
public class SimpleTcpCluster extends LifecycleMBeanBase
- implements CatalinaCluster, MembershipListener, ChannelListener{
+ implements CatalinaCluster, MembershipListener, ChannelListener {
public static final Log log = LogFactory.getLog(SimpleTcpCluster.class);
@@ -108,13 +105,14 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* The cluster name to join
*/
- protected String clusterName ;
+ protected String clusterName;
/**
* call Channel.heartbeat() at container background thread
+ *
* @see org.apache.catalina.tribes.group.GroupChannel#heartbeat()
*/
- protected boolean heartbeatBackgroundEnabled =false ;
+ protected boolean heartbeatBackgroundEnabled = false;
/**
* The Container associated with this Cluster.
@@ -129,7 +127,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* The context name <-> manager association for distributed contexts.
*/
- protected final Map<String, ClusterManager> managers = new HashMap<>();
+ protected final Map<String,ClusterManager> managers = new HashMap<>();
protected ClusterManager managerTemplate = new DeltaManager();
@@ -162,6 +160,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* Return heartbeat enable flag (default false)
+ *
* @return the heartbeatBackgroundEnabled
*/
public boolean isHeartbeatBackgroundEnabled() {
@@ -170,6 +169,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* enabled that container backgroundThread call heartbeat at channel
+ *
* @param heartbeatBackgroundEnabled the heartbeatBackgroundEnabled to set
*/
public void setHeartbeatBackgroundEnabled(boolean
heartbeatBackgroundEnabled) {
@@ -177,11 +177,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
/**
- * Set the name of the cluster to join, if no cluster with this name is
- * present create one.
+ * Set the name of the cluster to join, if no cluster with this name is
present create one.
*
- * @param clusterName
- * The clustername to join
+ * @param clusterName The clustername to join
*/
@Override
public void setClusterName(String clusterName) {
@@ -189,15 +187,14 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
/**
- * Return the name of the cluster that this Server is currently configured
- * to operate within.
+ * Return the name of the cluster that this Server is currently configured
to operate within.
*
* @return The name of the cluster associated with this server
*/
@Override
public String getClusterName() {
- if(clusterName == null && container != null) {
- return container.getName() ;
+ if (clusterName == null && container != null) {
+ return container.getName();
}
return clusterName;
}
@@ -205,8 +202,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* Set the Container associated with our Cluster
*
- * @param container
- * The Container to use
+ * @param container The Container to use
*/
@Override
public void setContainer(Container container) {
@@ -233,21 +229,18 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
/**
- * @param notifyListenerOnFailure
- * The notifyLifecycleListenerOnFailure to set.
+ * @param notifyListenerOnFailure The notifyLifecycleListenerOnFailure to
set.
*/
- public void setNotifyLifecycleListenerOnFailure(
- boolean notifyListenerOnFailure) {
+ public void setNotifyLifecycleListenerOnFailure(boolean
notifyListenerOnFailure) {
boolean oldNotifyListenerOnFailure =
this.notifyLifecycleListenerOnFailure;
this.notifyLifecycleListenerOnFailure = notifyListenerOnFailure;
- support.firePropertyChange("notifyLifecycleListenerOnFailure",
- oldNotifyListenerOnFailure,
+ support.firePropertyChange("notifyLifecycleListenerOnFailure",
oldNotifyListenerOnFailure,
this.notifyLifecycleListenerOnFailure);
}
/**
- * Add cluster valve
- * Cluster Valves are only add to container when cluster is started!
+ * Add cluster valve Cluster Valves are only add to container when cluster
is started!
+ *
* @param valve The new cluster Valve.
*/
@Override
@@ -259,6 +252,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* get all cluster valves
+ *
* @return current cluster valves
*/
@Override
@@ -267,8 +261,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
/**
- * Get the cluster listeners associated with this cluster. If this Array
has
- * no listeners registered, a zero-length array is returned.
+ * Get the cluster listeners associated with this cluster. If this Array
has no listeners registered, a zero-length
+ * array is returned.
+ *
* @return the listener array
*/
public ClusterListener[] findClusterListeners() {
@@ -279,6 +274,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* Add cluster message listener and register cluster to this listener.
*
* @param listener The new listener
+ *
* @see
org.apache.catalina.ha.CatalinaCluster#addClusterListener(org.apache.catalina.ha.ClusterListener)
*/
@Override
@@ -293,6 +289,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* Remove message listener and deregister Cluster from listener.
*
* @param listener The listener to remove
+ *
* @see
org.apache.catalina.ha.CatalinaCluster#removeClusterListener(org.apache.catalina.ha.ClusterListener)
*/
@Override
@@ -313,6 +310,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* set a new Deployer, must be set before cluster started!
+ *
* @param clusterDeployer The associated deployer
*/
@Override
@@ -345,6 +343,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* has members
*/
protected boolean hasMembers = false;
+
@Override
public boolean hasMembers() {
return hasMembers;
@@ -352,6 +351,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* Get all current cluster members
+ *
* @return all members or empty array
*/
@Override
@@ -376,7 +376,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* @return Returns the managers.
*/
@Override
- public Map<String, ClusterManager> getManagers() {
+ public Map<String,ClusterManager> getManagers() {
return managers;
}
@@ -395,25 +395,26 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* returns the SendOptions as a comma separated list of names for use by
JMX
+ *
* @return a comma separated list of the option names
*/
- public String getChannelSendOptionsName(){
+ public String getChannelSendOptionsName() {
return Channel.getSendOptionsAsString(channelSendOptions);
}
/**
* Create new Manager without add to cluster (comes with start the manager)
*
- * @param name
- * Context Name of this manager
+ * @param name Context Name of this manager
+ *
* @see org.apache.catalina.Cluster#createManager(java.lang.String)
* @see DeltaManager#start()
*/
@Override
public synchronized Manager createManager(String name) {
if (log.isDebugEnabled()) {
- log.debug("Creating ClusterManager for context " + name +
- " using class " +
getManagerTemplate().getClass().getName());
+ log.debug("Creating ClusterManager for context " + name + " using
class " +
+ getManagerTemplate().getClass().getName());
}
ClusterManager manager = null;
try {
@@ -423,7 +424,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
log.error(sm.getString("simpleTcpCluster.clustermanager.cloneFailed"), x);
manager = new org.apache.catalina.ha.session.DeltaManager();
} finally {
- if ( manager != null) {
+ if (manager != null) {
manager.setCluster(this);
}
}
@@ -433,7 +434,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
@Override
public void registerManager(Manager manager) {
- if (! (manager instanceof ClusterManager)) {
+ if (!(manager instanceof ClusterManager)) {
log.warn(sm.getString("simpleTcpCluster.clustermanager.notImplement", manager));
return;
}
@@ -453,6 +454,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* Remove an application from cluster replication bus.
*
* @param manager The manager
+ *
* @see org.apache.catalina.Cluster#removeManager(Manager)
*/
@Override
@@ -460,8 +462,8 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
if (manager instanceof ClusterManager) {
ClusterManager cmgr = (ClusterManager) manager;
// Notify our interested LifecycleListeners
- fireLifecycleEvent(BEFORE_MANAGERUNREGISTER_EVENT,manager);
- managers.remove(getManagerName(cmgr.getName(),manager));
+ fireLifecycleEvent(BEFORE_MANAGERUNREGISTER_EVENT, manager);
+ managers.remove(getManagerName(cmgr.getName(), manager));
cmgr.setCluster(null);
// Notify our interested LifecycleListeners
fireLifecycleEvent(AFTER_MANAGERUNREGISTER_EVENT, manager);
@@ -470,16 +472,15 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
@Override
public String getManagerName(String name, Manager manager) {
- String clusterName = name ;
+ String clusterName = name;
if (clusterName == null) {
clusterName = manager.getContext().getName();
}
if (getContainer() instanceof Engine) {
Context context = manager.getContext();
Container host = context.getParent();
- if (host instanceof Host && clusterName != null &&
- !(clusterName.startsWith(host.getName() +"#"))) {
- clusterName = host.getName() +"#" + clusterName ;
+ if (host instanceof Host && clusterName != null &&
!(clusterName.startsWith(host.getName() + "#"))) {
+ clusterName = host.getName() + "#" + clusterName;
}
}
return clusterName;
@@ -493,12 +494,11 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
// ------------------------------------------------------ Lifecycle Methods
/**
- * Execute a periodic task, such as reloading, etc. This method will be
- * invoked inside the classloading context of this container. Unexpected
- * throwables will be caught and logged.
+ * Execute a periodic task, such as reloading, etc. This method will be
invoked inside the classloading context of
+ * this container. Unexpected throwables will be caught and logged.
+ *
* @see org.apache.catalina.ha.deploy.FarmWarDeployer#backgroundProcess()
* @see org.apache.catalina.tribes.group.GroupChannel#heartbeat()
- *
*/
@Override
public void backgroundProcess() {
@@ -506,8 +506,8 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
clusterDeployer.backgroundProcess();
}
- //send a heartbeat through the channel
- if ( isHeartbeatBackgroundEnabled() && channel !=null ) {
+ // send a heartbeat through the channel
+ if (isHeartbeatBackgroundEnabled() && channel != null) {
channel.heartbeat();
}
@@ -534,11 +534,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
- * Start Cluster and implement the requirements
- * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
+ * Start Cluster and implement the requirements of {@link
org.apache.catalina.util.LifecycleBase#startInternal()}.
*
- * @exception LifecycleException if this component detects a fatal error
- * that prevents this component from being used
+ * @exception LifecycleException if this component detects a fatal error
that prevents this component from being
+ * used
*/
@Override
protected void startInternal() throws LifecycleException {
@@ -569,20 +568,20 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
protected void checkDefaults() {
- if ( clusterListeners.size() == 0 && managerTemplate instanceof
DeltaManager ) {
+ if (clusterListeners.size() == 0 && managerTemplate instanceof
DeltaManager) {
addClusterListener(new ClusterSessionListener());
}
- if ( valves.size() == 0 ) {
+ if (valves.size() == 0) {
addValve(new JvmRouteBinderValve());
addValve(new ReplicationValve());
}
- if ( clusterDeployer != null ) {
+ if (clusterDeployer != null) {
clusterDeployer.setCluster(this);
}
- if ( channel == null ) {
+ if (channel == null) {
channel = new GroupChannel();
}
- if ( channel instanceof GroupChannel &&
!((GroupChannel)channel).getInterceptors().hasNext()) {
+ if (channel instanceof GroupChannel && !((GroupChannel)
channel).getInterceptors().hasNext()) {
channel.addInterceptor(new MessageDispatchInterceptor());
channel.addInterceptor(new TcpFailureDetector());
}
@@ -595,12 +594,11 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* register all cluster valve to host or engine
*/
protected void registerClusterValve() {
- if(container != null ) {
+ if (container != null) {
for (Valve v : valves) {
ClusterValve valve = (ClusterValve) v;
if (log.isDebugEnabled()) {
- log.debug("Invoking addValve on " + getContainer()
- + " with class=" + valve.getClass().getName());
+ log.debug("Invoking addValve on " + getContainer() + "
with class=" + valve.getClass().getName());
}
if (valve != null) {
container.getPipeline().addValve(valve);
@@ -617,8 +615,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
for (Valve v : valves) {
ClusterValve valve = (ClusterValve) v;
if (log.isDebugEnabled()) {
- log.debug("Invoking removeValve on " + getContainer()
- + " with class=" + valve.getClass().getName());
+ log.debug("Invoking removeValve on " + getContainer() + " with
class=" + valve.getClass().getName());
}
if (valve != null) {
container.getPipeline().removeValve(valve);
@@ -629,11 +626,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
- * Stop Cluster and implement the requirements
- * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
+ * Stop Cluster and implement the requirements of {@link
org.apache.catalina.util.LifecycleBase#stopInternal()}.
*
- * @exception LifecycleException if this component detects a fatal error
- * that prevents this component from being used
+ * @exception LifecycleException if this component detects a fatal error
that prevents this component from being
+ * used
*/
@Override
protected void stopInternal() throws LifecycleException {
@@ -646,7 +642,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
}
this.managers.clear();
try {
- if ( clusterDeployer != null ) {
+ if (clusterDeployer != null) {
clusterDeployer.setCluster(null);
}
channel.stop(channelStartOptions);
@@ -682,6 +678,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* send message to all cluster members
+ *
* @param msg message to transfer
*
* @see
org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage)
@@ -694,10 +691,11 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
/**
* send a cluster message to one member
*
- * @param msg message to transfer
+ * @param msg message to transfer
* @param dest Receiver member
+ *
* @see
org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage,
- * org.apache.catalina.tribes.Member)
+ * org.apache.catalina.tribes.Member)
*/
@Override
public void send(ClusterMessage msg, Member dest) {
@@ -710,16 +708,16 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
msg.setAddress(getLocalMember());
if (dest != null) {
if (!getLocalMember().equals(dest)) {
- channel.send(new Member[] {dest}, msg, sendOptions);
+ channel.send(new Member[] { dest }, msg, sendOptions);
} else {
log.error(sm.getString("simpleTcpCluster.unableSend.localMember", msg));
}
} else {
Member[] destmembers = channel.getMembers();
- if (destmembers.length>0) {
- channel.send(destmembers,msg, sendOptions);
+ if (destmembers.length > 0) {
+ channel.send(destmembers, msg, sendOptions);
} else if (log.isDebugEnabled()) {
- log.debug("No members in cluster, ignoring message:"+msg);
+ log.debug("No members in cluster, ignoring message:" +
msg);
}
}
} catch (Exception x) {
@@ -780,11 +778,9 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
// messages
/**
- * notify all listeners from receiving a new message is not ClusterMessage
- * emit Failure Event to LifecycleListener
+ * notify all listeners from receiving a new message is not ClusterMessage
emit Failure Event to LifecycleListener
*
- * @param msg
- * received Message
+ * @param msg received Message
*/
@Override
public boolean accept(Serializable msg, Member sender) {
@@ -794,7 +790,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
@Override
public void messageReceived(Serializable message, Member sender) {
- ClusterMessage fwd = (ClusterMessage)message;
+ ClusterMessage fwd = (ClusterMessage) message;
fwd.setAddress(sender);
messageReceived(fwd);
}
@@ -802,13 +798,11 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
public void messageReceived(ClusterMessage message) {
if (log.isDebugEnabled() && message != null) {
- log.debug("Assuming clocks are synched: Replication for "
- + message.getUniqueId() + " took="
- + (System.currentTimeMillis() - (message).getTimestamp())
- + " ms.");
+ log.debug("Assuming clocks are synched: Replication for " +
message.getUniqueId() + " took=" +
+ (System.currentTimeMillis() - (message).getTimestamp()) +
" ms.");
}
- //invoke all the listeners
+ // invoke all the listeners
boolean accepted = false;
if (message != null) {
for (ClusterListener listener : clusterListeners) {
@@ -820,12 +814,10 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
if (!accepted && notifyLifecycleListenerOnFailure) {
Member dest = message.getAddress();
// Notify our interested LifecycleListeners
- fireLifecycleEvent(RECEIVE_MESSAGE_FAILURE_EVENT,
- new SendMessageData(message, dest, null));
+ fireLifecycleEvent(RECEIVE_MESSAGE_FAILURE_EVENT, new
SendMessageData(message, dest, null));
if (log.isDebugEnabled()) {
- log.debug("Message " + message.toString() + " from type "
- + message.getClass().getName()
- + " transferred but no listener registered");
+ log.debug("Message " + message.toString() + " from type "
+ message.getClass().getName() +
+ " transferred but no listener registered");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]