This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new cae270d2a3 Align with 9.0.x onwards
cae270d2a3 is described below
commit cae270d2a3a7381943848efc7959ec5b8e475d0e
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Aug 8 14:25:58 2023 +0100
Align with 9.0.x onwards
---
java/org/apache/catalina/ha/ClusterRuleSet.java | 5 -
.../apache/catalina/ha/backend/CollectedInfo.java | 24 +++--
.../catalina/ha/backend/HeartbeatListener.java | 119 +++++++++++++++++++--
.../catalina/ha/backend/MultiCastSender.java | 2 +-
.../apache/catalina/ha/deploy/FarmWarDeployer.java | 6 +-
.../catalina/ha/deploy/FileMessageFactory.java | 3 +
.../catalina/ha/deploy/LocalStrings.properties | 3 +-
.../catalina/ha/deploy/LocalStrings_fr.properties | 2 +
.../catalina/ha/deploy/LocalStrings_ja.properties | 2 +
.../catalina/ha/deploy/LocalStrings_ko.properties | 2 +
.../ha/deploy/LocalStrings_zh_CN.properties | 2 +
.../ha/session/ClusterSessionListener.java | 2 +-
.../apache/catalina/ha/session/DeltaManager.java | 7 ++
.../apache/catalina/ha/session/DeltaSession.java | 2 +-
.../catalina/ha/tcp/LocalStrings_es.properties | 1 -
.../apache/catalina/ha/tcp/SimpleTcpCluster.java | 23 ++--
java/org/apache/catalina/util/ToStringUtil.java | 62 +++++++++++
17 files changed, 221 insertions(+), 46 deletions(-)
diff --git a/java/org/apache/catalina/ha/ClusterRuleSet.java
b/java/org/apache/catalina/ha/ClusterRuleSet.java
index 8aed8fefff..a24ed5f29e 100644
--- a/java/org/apache/catalina/ha/ClusterRuleSet.java
+++ b/java/org/apache/catalina/ha/ClusterRuleSet.java
@@ -16,11 +16,9 @@
*/
package org.apache.catalina.ha;
-
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSetBase;
-
/**
* <p>
* <strong>RuleSet</strong> for processing the contents of a Cluster
definition element.
@@ -48,9 +46,7 @@ public class ClusterRuleSet extends RuleSetBase {
* Construct an instance of this <code>RuleSet</code> with the default
matching pattern prefix.
*/
public ClusterRuleSet() {
-
this("");
-
}
@@ -60,7 +56,6 @@ public class ClusterRuleSet extends RuleSetBase {
* @param prefix Prefix for matching pattern rules (including the trailing
slash character)
*/
public ClusterRuleSet(String prefix) {
- super();
this.prefix = prefix;
}
diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java
b/java/org/apache/catalina/ha/backend/CollectedInfo.java
index 235e161df1..ab2436717c 100644
--- a/java/org/apache/catalina/ha/backend/CollectedInfo.java
+++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java
@@ -61,7 +61,13 @@ public class CollectedInfo {
Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
for (ObjectInstance oi : set) {
objName = oi.getObjectName();
+ String subtype = objName.getKeyProperty("subType");
+ if (subtype != null && subtype.equals("SocketProperties")) {
+ objName = null;
+ continue;
+ }
String name = objName.getKeyProperty("name");
+ name = name.replace("\"", "");
// Example names:
// ajp-nio-8009
@@ -71,18 +77,22 @@ public class CollectedInfo {
String[] elenames = name.split("-");
String sport = elenames[elenames.length - 1];
iport = Integer.parseInt(sport);
- String[] shosts = elenames[1].split("%2F");
- shost = shosts[0];
+ if (elenames.length == 4) {
+ shost = elenames[2];
+ }
if (port == 0 && host == null) {
break; /* Done: take the first one */
}
- if (host == null && iport == port) {
- break; /* Only port done */
- }
- if (shost.compareTo(host) == 0) {
- break; /* Done port and host are the expected ones */
+ if (iport == port) {
+ if (host == null) {
+ break; /* Done: return the first with the right port */
+ } else if (shost != null && shost.compareTo(host) == 0) {
+ break; /* Done port and host are the expected ones */
+ }
}
+ objName = null;
+ shost = null;
}
if (objName == null) {
throw new Exception(sm.getString("collectedInfo.noConnector",
host, Integer.valueOf(port)));
diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
index de6dfcada4..8cd64304b3 100644
--- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
+++ b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
@@ -38,48 +38,147 @@ public class HeartbeatListener implements
LifecycleListener, ContainerListener {
private static final StringManager sm =
StringManager.getManager(HeartbeatListener.class);
/* To allow to select the connector */
- private int port = 0;
- private String host = null;
-
- /* for multicasting stuff */
- private final String ip = "224.0.1.105"; /* Multicast IP */
- private final int multiport = 23364; /* Multicast Port */
- private final int ttl = 16;
+ protected int port = 8009;
+ protected String host = null;
+ /**
+ * @return the host corresponding to the connector we want to proxy.
+ */
public String getHost() {
- return host;
+ return this.host;
}
+ /**
+ * Set the host corresponding to the connector.
+ *
+ * @param host the hostname or ip string.
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ /**
+ * @return the port of the connector we want to proxy.
+ */
+ public int getPort() {
+ return this.port;
+ }
+
+ /**
+ * Set the port corresponding to the connector.
+ *
+ * @param port default 8009 the ajp one.
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ /* for multicasting stuff */
+ protected String ip = "224.0.1.105"; /* Multicast IP */
+ protected int multiport = 23364; /* Multicast Port */
+ protected int ttl = 16;
+
+ /* corresponding setters and getters */
+
+ /**
+ * @return the Multicast IP we are using for Multicast
+ */
public String getGroup() {
return ip;
}
+ /**
+ * Set the Multicast IP to use for Multicast
+ *
+ * @param group the multi address to use.
+ */
+ public void setGroup(String group) {
+ this.ip = group;
+ }
+
+ /**
+ * @return the Multicast Port we are using for Multicast.
+ */
public int getMultiport() {
return multiport;
}
+ /**
+ * Set the Port to use for Multicast
+ *
+ * @param port the port to use.
+ */
+ public void setMultiport(int port) {
+ this.multiport = port;
+ }
+
+ /**
+ * @return the TTL for Multicast packets.
+ */
public int getTtl() {
return ttl;
}
+ /**
+ * Set the TTL for Multicast packets.
+ *
+ * @param ttl value for TTL.
+ */
+ public void setTtl(int ttl) {
+ this.ttl = ttl;
+ }
+
/**
* Proxy list, format "address:port,address:port".
*/
- private final String proxyList = null;
+ protected String proxyList = null;
+ /**
+ * @return the list of proxies that send us requests.
+ */
public String getProxyList() {
return proxyList;
}
+ /**
+ * Set the list of Proxies that send is requests, when not empty it
toggles the multi to off. A SetHandler heartbeat
+ * must be existing in httpd.conf.
+ *
+ * @param proxyList the list of proxy, format "address:port,address:port".
+ */
+ public void setProxyList(String proxyList) {
+ this.proxyList = proxyList;
+ }
+
/**
* URL prefix.
*/
- private final String proxyURL = "/HeartbeatListener";
+ protected String proxyURL = "/HeartbeatListener";
+ /**
+ * @return the URL specified in <Location/> for the SetHandler
heartbeat.
+ */
public String getProxyURL() {
return proxyURL;
}
+ /**
+ * Set the URL of receiver in httpd. That is the location used in
+ *
+ * <pre>
+ * <Location "/HeartbeatListener">
+ * SetHandler heartbeat
+ * </Location>
+ * </pre>
+ *
+ * All proxies MUST use the same location.
+ *
+ * @param proxyURL a String with the URL starting with /
+ */
+ public void setProxyURLString(String proxyURL) {
+ this.proxyURL = proxyURL;
+ }
+
private CollectedInfo coll = null;
private Sender sender = null;
diff --git a/java/org/apache/catalina/ha/backend/MultiCastSender.java
b/java/org/apache/catalina/ha/backend/MultiCastSender.java
index c8a8e6908b..424ed20a65 100644
--- a/java/org/apache/catalina/ha/backend/MultiCastSender.java
+++ b/java/org/apache/catalina/ha/backend/MultiCastSender.java
@@ -59,7 +59,7 @@ public class MultiCastSender implements Sender {
}
s.setTimeToLive(config.getTtl());
- s.joinGroup(group);
+ s.joinGroup(new InetSocketAddress(group, 0), null);
} catch (Exception ex) {
log.error(sm.getString("multiCastSender.multiCastFailed"), ex);
s = null;
diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
index cfa77cbfe5..27ad2d77cb 100644
--- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
+++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
@@ -238,7 +238,7 @@ public class FarmWarDeployer extends ClusterListener
implements ClusterDeployer,
log.error(sm.getString("farmWarDeployer.servicingDeploy", contextName, name));
}
} catch (Exception ex) {
- log.error(ex);
+
log.error(sm.getString("farmWarDeployer.fileMessageError"), ex);
} finally {
removeFactory(fmsg);
}
@@ -263,7 +263,7 @@ public class FarmWarDeployer extends ClusterListener
implements ClusterDeployer,
log.error(sm.getString("farmWarDeployer.servicingUndeploy", contextName));
}
} catch (Exception ex) {
- log.error(ex);
+
log.error(sm.getString("farmWarDeployer.undeployMessageError"), ex);
}
}
} catch (java.io.IOException x) {
@@ -747,7 +747,7 @@ public class FarmWarDeployer extends ClusterListener
implements ClusterDeployer,
}
try (java.io.FileInputStream is = new java.io.FileInputStream(from);
- java.io.FileOutputStream os = new java.io.FileOutputStream(to,
false);) {
+ java.io.FileOutputStream os = new java.io.FileOutputStream(to,
false)) {
byte[] buf = new byte[4096];
while (true) {
int len = is.read(buf);
diff --git a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
index 942b273f30..18c32268e4 100644
--- a/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
+++ b/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
@@ -334,7 +334,10 @@ public class FileMessageFactory {
* @param args String[], args[0] - read from filename, args[1] write to
filename
*
* @throws Exception An error occurred
+ *
+ * @deprecated This method will be removed in Tomcat 10.0.x
*/
+ @Deprecated
public static void main(String[] args) throws Exception {
System.out.println("Usage: FileMessageFactory fileToBeRead
fileToBeWritten");
System.out.println("Usage: This will make a copy of the file on the
local file system");
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings.properties
b/java/org/apache/catalina/ha/deploy/LocalStrings.properties
index 57b98534d3..8b2df01de2 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings.properties
@@ -18,12 +18,12 @@ farmWarDeployer.delete=Deleted [{0}] before the full file
was received as the ma
farmWarDeployer.deleteFail=Failed to delete [{0}]
farmWarDeployer.deployEnd=Deployment from [{0}] finished.
farmWarDeployer.fileCopyFail=Unable to copy from [{0}] to [{1}]
+farmWarDeployer.fileMessageError=Error processing file message
farmWarDeployer.hostOnly=FarmWarDeployer can only work as host cluster
subelement!
farmWarDeployer.hostParentEngine=FarmWarDeployer can only work if parent of
[{0}] is an engine!
farmWarDeployer.mbeanNameFail=Cannot construct MBean object name for engine
[{0}] and host [{1}]
farmWarDeployer.modInstall=Installing webapp [{0}] from [{1}]
farmWarDeployer.modInstallFail=Unable to install WAR file
-farmWarDeployer.modRemoveFail=No removal
farmWarDeployer.msgIoe=Unable to read farm deploy file message.
farmWarDeployer.msgRxDeploy=Receive cluster deployment path [{0}], war [{1}]
farmWarDeployer.msgRxUndeploy=Receive cluster undeployment from path [{0}]
@@ -43,6 +43,7 @@ farmWarDeployer.started=Cluster FarmWarDeployer started.
farmWarDeployer.stopped=Cluster FarmWarDeployer stopped.
farmWarDeployer.undeployEnd=Undeployment from [{0}] finished.
farmWarDeployer.undeployLocal=Undeploy local context [{0}]
+farmWarDeployer.undeployMessageError=Error processing undeploy message
farmWarDeployer.watchDir=Cluster deployment is watching [{0}] for changes.
fileMessageFactory.cannotRead=Cannot read message, this factory is writing
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings_fr.properties
b/java/org/apache/catalina/ha/deploy/LocalStrings_fr.properties
index 0b2825dbc3..4264fe7ac8 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings_fr.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings_fr.properties
@@ -18,6 +18,7 @@ farmWarDeployer.delete=[{0}] a été supprimé avant que le
fichier complet n''a
farmWarDeployer.deleteFail=Pas réussi à supprimer [{0}]
farmWarDeployer.deployEnd=Le déploiement de [{0}] est terminé
farmWarDeployer.fileCopyFail=Impossible de copier depuis [{0}] vers [{1}]
+farmWarDeployer.fileMessageError=Erreur lors du traitement du message fichier
farmWarDeployer.hostOnly=Le FarmWarDeployer ne fonctionne qu'en tant que
sous-élément d'un "host cluster" !
farmWarDeployer.hostParentEngine=FarmWarDeployer peut fonctionner uniquement
si le parent de [{0}] est un moteur
farmWarDeployer.mbeanNameFail=Impossible de construire le nom d''objet du
mbean pour le moteur [{0}] et l''hôte [{1}]
@@ -42,6 +43,7 @@ farmWarDeployer.started=Le FarmWarDeployer du cluster a
démarré
farmWarDeployer.stopped=Le FarmWarDeployer du cluster a été arrêté
farmWarDeployer.undeployEnd=Retrait de [{0}] terminé
farmWarDeployer.undeployLocal=Le contexte local [{0}] est retiré
+farmWarDeployer.undeployMessageError=Erreur lors du traitement du message de
retrait
farmWarDeployer.watchDir=Le déploiement du cluster surveille [{0}] pour des
modifications
fileMessageFactory.cannotRead=Impossible de lire un message, cette fabrique
est en train d'écrire
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings_ja.properties
b/java/org/apache/catalina/ha/deploy/LocalStrings_ja.properties
index 0cc9772c39..5c5c28085d 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings_ja.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings_ja.properties
@@ -18,6 +18,7 @@ farmWarDeployer.delete=[{1}] 秒の maxValidTime が期限切れになったた
farmWarDeployer.deleteFail=[{0}] を削除できません。
farmWarDeployer.deployEnd=[{0}] からの配備が完了しました。
farmWarDeployer.fileCopyFail=[{0}] から [{1}] へコピーできません。
+farmWarDeployer.fileMessageError=ファイルメッセージ処理中のエラー
farmWarDeployer.hostOnly=FarmWarDeployer はHostクラスタのサブエレメントとしてのみ機能します
farmWarDeployer.hostParentEngine=FarmWarDeployer は親 [{0}] が Engine
のインスタンスでなければ機能しません。
farmWarDeployer.mbeanNameFail=エンジン [{0}] とホスト [{1}] のMBeanオブジェクト名を構築できません
@@ -42,6 +43,7 @@ farmWarDeployer.started=クラスターの FarmWarDeployer を開始しました
farmWarDeployer.stopped=Cluster FarmWarDeployer が停止しました。
farmWarDeployer.undeployEnd=コンテキスト [{0}] の配備解除が完了しました。
farmWarDeployer.undeployLocal=ローカルコンテキスト [{0}] を配備解除します。
+farmWarDeployer.undeployMessageError=配備解除メッセージ処理中のエラー
farmWarDeployer.watchDir=クラスタ配備の監視[{0}]が変更されています。
fileMessageFactory.cannotRead=メッセージを読むことができません。このFactoryは書き込み中です。
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings_ko.properties
b/java/org/apache/catalina/ha/deploy/LocalStrings_ko.properties
index 0f816aaaab..512827bc11 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings_ko.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings_ko.properties
@@ -17,6 +17,7 @@ farmWarDeployer.alreadyDeployed=webapp [{0}](들)이 이미 배치되어 있습
farmWarDeployer.deleteFail=[{0}]을(를) 삭제하지 못했습니다.
farmWarDeployer.deployEnd=[{0}](으)로부터의 배치 작업이 완료됐습니다.
farmWarDeployer.fileCopyFail=[{0}](으)로부터 [{1}](으)로 복사할 수 없습니다.
+farmWarDeployer.fileMessageError=파일 메시지를 처리하는 중 오류 발생
farmWarDeployer.hostOnly=FarmWarDeployer는 오직 하위 엘리먼트인 호스트 클러스터 엘리먼트에서 존재해야 합니다.
farmWarDeployer.hostParentEngine=FarmWarDeployer는, 오직 [{0}]의 부모가 엔진일 때에만, 정상
동작할 수 있습니다!
farmWarDeployer.mbeanNameFail=엔진 [{0}]와(과) 호스트 [{1}]을(를) 위한 MBean 객체 이름을 구성할 수
없습니다.
@@ -41,6 +42,7 @@ farmWarDeployer.started=클러스터 FarmWarDeployer가 시작되었습니다.
farmWarDeployer.stopped=클러스터 FarmWarDeployer가 중지되었습니다.
farmWarDeployer.undeployEnd=컨텍스트 [{0}]의 배치를 제거했습니다.
farmWarDeployer.undeployLocal=로컬 컨텍스트 [{0}]의 배치를 제거합니다.
+farmWarDeployer.undeployMessageError=배치를 제거하라는 메시지를 처리 중 오류 발생
farmWarDeployer.watchDir=클러스터 배치관리자가 변경사항들을 탐지하기 위해 [{0}]을(를) 감시합니다.
fileMessageFactory.cannotRead=팩토리가 쓰고 있는 중이라서, 메시지를 읽을 수 없습니다.
diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings_zh_CN.properties
b/java/org/apache/catalina/ha/deploy/LocalStrings_zh_CN.properties
index 9cfb6491bd..c5f34cf597 100644
--- a/java/org/apache/catalina/ha/deploy/LocalStrings_zh_CN.properties
+++ b/java/org/apache/catalina/ha/deploy/LocalStrings_zh_CN.properties
@@ -17,6 +17,7 @@ farmWarDeployer.alreadyDeployed=webapp[{0}]已部署。
farmWarDeployer.deleteFail=无法删除 [{0}]
farmWarDeployer.deployEnd=[{0}]中的部署已完成。
farmWarDeployer.fileCopyFail=无法从[{0}]复制到[{1}]
+farmWarDeployer.fileMessageError=处理文件消息时出错
farmWarDeployer.hostOnly=FarmWarDeployer 只有做为 host cluster 的子元素是才生效
farmWarDeployer.hostParentEngine=FarmWarDeployer只能在[{0}]的父级是引擎时工作!
farmWarDeployer.mbeanNameFail=无法为引擎[{0}]和主机[{1}]构造MBean对象名
@@ -41,6 +42,7 @@ farmWarDeployer.started=集群FarmWarDeployer已启动。
farmWarDeployer.stopped=集群FarmWarDeployer已停止。
farmWarDeployer.undeployEnd=从[{0}]取消部署完成。
farmWarDeployer.undeployLocal=不能部署本地上下文[{0}]
+farmWarDeployer.undeployMessageError=处理取消部署消息时出错
farmWarDeployer.watchDir=集群部署正在监视[{0}]的更改
fileMessageFactory.cannotRead=无法读取消息,此工厂正在写入
diff --git a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
index 8683fdf24a..efaba44649 100644
--- a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
+++ b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
@@ -54,7 +54,7 @@ public class ClusterSessionListener extends ClusterListener {
if (myobj instanceof SessionMessage) {
SessionMessage msg = (SessionMessage) myobj;
String ctxname = msg.getContextName();
- // check if the message is a EVT_GET_ALL_SESSIONS,
+ // check if the message is an EVT_GET_ALL_SESSIONS,
// if so, wait until we are fully started up
Map<String,ClusterManager> managers = cluster.getManagers();
if (ctxname == null) {
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 979d36444c..4246d2c7c1 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -529,6 +529,13 @@ public class DeltaManager extends ClusterManagerBase {
changeSessionId(session, newId, true);
}
+ /**
+ * @param session The session
+ * @param notify Notify change
+ *
+ * @deprecated Will be removed in Tomcat 10
+ */
+ @Deprecated
protected void changeSessionId(Session session, boolean notify) {
String orgSessionID = session.getId();
super.changeSessionId(session);
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java
b/java/org/apache/catalina/ha/session/DeltaSession.java
index fd34e85435..d890a64c28 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -1071,7 +1071,7 @@ public class DeltaSession extends StandardSession
implements Externalizable, Clu
accessCount = new AtomicInteger();
}
if (accessCount != null) {
- super.accessCount.set(count);
+ accessCount.set(count);
}
}
}
diff --git a/java/org/apache/catalina/ha/tcp/LocalStrings_es.properties
b/java/org/apache/catalina/ha/tcp/LocalStrings_es.properties
index 19711c31b7..4e106ecdee 100644
--- a/java/org/apache/catalina/ha/tcp/LocalStrings_es.properties
+++ b/java/org/apache/catalina/ha/tcp/LocalStrings_es.properties
@@ -25,7 +25,6 @@ ReplicationValve.resetDeltaRequest=Cluster is standalone:
reset Session Request
ReplicationValve.send.failure=Unable to perform replication request.
ReplicationValve.send.invalid.failure=Unable to send session [id={0}] invalid
message over cluster.
ReplicationValve.session.found=Context [{0}]: Found session [{1}] but it
isn''t a ClusterSession.
-ReplicationValve.session.indicator=Context [{0}]: Primarity of session [{0}]
in request attribute [{1}] is [{2}].
ReplicationValve.session.invalid=Context [{0}]: Requested session [{1}] is
invalid, removed or not replicated at this node.
ReplicationValve.stats=Average request time= [{0}] ms for Cluster overhead
time=[{1}] ms for [{2}] requests [{3}] filter requests [{4}] send requests
[{5}] cross context requests (Request=[{6}] ms Cluster=[{7}] ms).
diff --git a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
index 5512b6858a..f2f07c172b 100644
--- a/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
+++ b/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
@@ -20,7 +20,6 @@ import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -54,6 +53,7 @@ import org.apache.catalina.tribes.group.GroupChannel;
import
org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor;
import org.apache.catalina.tribes.group.interceptors.TcpFailureDetector;
import org.apache.catalina.util.LifecycleMBeanBase;
+import org.apache.catalina.util.ToStringUtil;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
@@ -578,8 +578,8 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
*/
protected void registerClusterValve() {
if (container != null) {
- for (Iterator<Valve> iter = valves.iterator(); iter.hasNext();) {
- ClusterValve valve = (ClusterValve) iter.next();
+ for (Valve v : valves) {
+ ClusterValve valve = (ClusterValve) v;
if (log.isDebugEnabled()) {
log.debug("Invoking addValve on " + getContainer() + "
with class=" + valve.getClass().getName());
}
@@ -595,8 +595,8 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
* unregister all cluster valve to host or engine
*/
protected void unregisterClusterValve() {
- for (Iterator<Valve> iter = valves.iterator(); iter.hasNext();) {
- ClusterValve valve = (ClusterValve) iter.next();
+ for (Valve v : valves) {
+ ClusterValve valve = (ClusterValve) v;
if (log.isDebugEnabled()) {
log.debug("Invoking removeValve on " + getContainer() + " with
class=" + valve.getClass().getName());
}
@@ -653,15 +653,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
*/
@Override
public String toString() {
- StringBuilder sb = new StringBuilder(this.getClass().getName());
- sb.append('[');
- if (container == null) {
- sb.append("Container is null");
- } else {
- sb.append(container.getName());
- }
- sb.append(']');
- return sb.toString();
+ return ToStringUtil.toString(this);
}
@@ -794,8 +786,7 @@ public class SimpleTcpCluster extends LifecycleMBeanBase
// invoke all the listeners
boolean accepted = false;
if (message != null) {
- for (Iterator<ClusterListener> iter = clusterListeners.iterator();
iter.hasNext();) {
- ClusterListener listener = iter.next();
+ for (ClusterListener listener : clusterListeners) {
if (listener.accept(message)) {
accepted = true;
listener.messageReceived(message);
diff --git a/java/org/apache/catalina/util/ToStringUtil.java
b/java/org/apache/catalina/util/ToStringUtil.java
new file mode 100644
index 0000000000..d1602bf423
--- /dev/null
+++ b/java/org/apache/catalina/util/ToStringUtil.java
@@ -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.util;
+
+import org.apache.catalina.Contained;
+import org.apache.catalina.Container;
+import org.apache.catalina.Manager;
+
+/**
+ * Utility class used to help generate return values for calls to
+ * {@link Object#toString()}.
+ */
+public class ToStringUtil {
+
+ private ToStringUtil() {
+ // Utility class. Hide default constructor
+ }
+
+
+ public static final String toString(Contained contained) {
+ return toString(contained, contained.getContainer());
+ }
+
+
+ public static final String toString(Object obj, Container container) {
+ return containedToString(obj, container, "Container");
+ }
+
+
+ public static final String toString(Object obj, Manager manager) {
+ return containedToString(obj, manager, "Manager");
+ }
+
+
+ private static String containedToString(Object contained, Object container,
+ String containerTypeName) {
+ StringBuilder sb = new
StringBuilder(contained.getClass().getSimpleName());
+ sb.append('[');
+ if (container == null) {
+ sb.append(containerTypeName);
+ sb.append(" is null");
+ } else {
+ sb.append(container.toString());
+ }
+ sb.append(']');
+ return sb.toString();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]