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 d2c5336  Use StringManager. Better align with 10.0.x/9.0.x
d2c5336 is described below

commit d2c53367425154925307b7ba846b1c1253ce8630
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat May 22 10:45:24 2021 +0100

    Use StringManager. Better align with 10.0.x/9.0.x
---
 .../apache/catalina/ha/backend/CollectedInfo.java  | 13 ++++++---
 .../catalina/ha/backend/HeartbeatListener.java     | 10 ++++---
 .../catalina/ha/backend/LocalStrings.properties    | 33 ++++++++++++++++++++++
 .../catalina/ha/backend/LocalStrings_de.properties | 16 +++++++++++
 .../catalina/ha/backend/LocalStrings_fr.properties | 33 ++++++++++++++++++++++
 .../catalina/ha/backend/LocalStrings_ja.properties | 33 ++++++++++++++++++++++
 .../catalina/ha/backend/LocalStrings_ko.properties | 33 ++++++++++++++++++++++
 .../ha/backend/LocalStrings_zh_CN.properties       | 33 ++++++++++++++++++++++
 .../catalina/ha/backend/MultiCastSender.java       |  6 ++--
 java/org/apache/catalina/ha/backend/TcpSender.java | 21 ++++++++------
 10 files changed, 212 insertions(+), 19 deletions(-)

diff --git a/java/org/apache/catalina/ha/backend/CollectedInfo.java 
b/java/org/apache/catalina/ha/backend/CollectedInfo.java
index 6cb05c7..39bab9e 100644
--- a/java/org/apache/catalina/ha/backend/CollectedInfo.java
+++ b/java/org/apache/catalina/ha/backend/CollectedInfo.java
@@ -27,6 +27,7 @@ import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 
 import org.apache.tomcat.util.modeler.Registry;
+import org.apache.tomcat.util.res.StringManager;
 
 /*
  * Listener to provider informations to mod_heartbeat.c
@@ -37,6 +38,8 @@ import org.apache.tomcat.util.modeler.Registry;
  */
 public class CollectedInfo {
 
+    private static final StringManager sm = 
StringManager.getManager(CollectedInfo.class);
+
     /* Collect info via JMX */
     protected MBeanServer mBeanServer = null;
     protected ObjectName objName = null;
@@ -73,14 +76,16 @@ public class CollectedInfo {
             shost = shosts[0];
 
             if (port==0 && host==null)
-                  break; /* Take the first one */
+                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 (objName == null)
-            throw new Exception("Can't find connector for " + host + ":" + 
port);
+        if (objName == null) {
+            throw new Exception(sm.getString("collectedInfo.noConnector",
+                    host, Integer.valueOf(port)));
+        }
         this.port = iport;
         this.host = shost;
 
@@ -88,7 +93,7 @@ public class CollectedInfo {
 
     public void refresh() throws Exception {
         if (mBeanServer == null || objName == null) {
-            throw new Exception("Not initialized!!!");
+            throw new Exception(sm.getString("collectedInfo.notInitialized"));
         }
         Integer imax = (Integer) mBeanServer.getAttribute(objName, 
"maxThreads");
 
diff --git a/java/org/apache/catalina/ha/backend/HeartbeatListener.java 
b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
index 9f9ee60..235b88a 100644
--- a/java/org/apache/catalina/ha/backend/HeartbeatListener.java
+++ b/java/org/apache/catalina/ha/backend/HeartbeatListener.java
@@ -25,6 +25,7 @@ import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
 
 /*
  * Listener to provider informations to mod_heartbeat.c
@@ -36,6 +37,7 @@ import org.apache.juli.logging.LogFactory;
 public class HeartbeatListener implements LifecycleListener, ContainerListener 
{
 
     private static final Log log = LogFactory.getLog(HeartbeatListener.class);
+    private static final StringManager sm = 
StringManager.getManager(HeartbeatListener.class);
 
     /* To allow to select the connector */
     private int port = 0;
@@ -89,7 +91,7 @@ public class HeartbeatListener implements LifecycleListener, 
ContainerListener {
                     this.port = coll.port;
                     this.host = coll.host;
                 } catch (Exception ex) {
-                    log.error("Unable to initialize info collection: " + ex);
+                    
log.error(sm.getString("heartbeatListener.errorCollectingInfo"), ex);
                     coll = null;
                     return;
                 }
@@ -99,7 +101,7 @@ public class HeartbeatListener implements LifecycleListener, 
ContainerListener {
             try {
                 sender.init(this);
             } catch (Exception ex) {
-                log.error("Unable to initialize Sender: " + ex);
+                log.error(sm.getString("heartbeatListener.senderInitError"), 
ex);
                 sender = null;
                 return;
             }
@@ -108,7 +110,7 @@ public class HeartbeatListener implements 
LifecycleListener, ContainerListener {
             try {
                 coll.refresh();
             } catch (Exception ex) {
-                log.error("Unable to collect load information: " + ex);
+                log.error(sm.getString("heartbeatListener.refreshError"), ex);
                 coll = null;
                 return;
             }
@@ -117,7 +119,7 @@ public class HeartbeatListener implements 
LifecycleListener, ContainerListener {
             try {
                 sender.send(output);
             } catch (Exception ex) {
-                log.error("Unable to send collected load information: " + ex);
+                log.error(sm.getString("heartbeatListener.sendError"), ex);
             }
         }
     }
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings.properties
new file mode 100644
index 0000000..3bba325
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings.properties
@@ -0,0 +1,33 @@
+# 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.
+
+collectedInfo.noConnector=Cannot find connector for [{0}]:[{1}]
+collectedInfo.notInitialized=Not initialized
+
+heartbeatListener.errorCollectingInfo=Unable to initialize info collection
+heartbeatListener.refreshError=Unable to collect load information
+heartbeatListener.sendError=Unable to send collected load information
+heartbeatListener.senderInitError=Unable to initialize Sender
+
+multiCastSender.multiCastFailed=Unable to use multicast
+multiCastSender.sendFailed=Unable to send multicast message
+
+tcpSender.connectionFailed=Unable to connect to proxy
+tcpSender.invalidProxyList=Invalid proxy list
+tcpSender.notInitialized=Not initialized
+tcpSender.readError=Error reading response content
+tcpSender.responseError=Unable to read response from proxy
+tcpSender.responseErrorCode=Response error with code [{0}]
+tcpSender.sendFailed=Unable to send collected load information to proxy
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings_de.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings_de.properties
new file mode 100644
index 0000000..8806d96
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings_de.properties
@@ -0,0 +1,16 @@
+# 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.
+
+multiCastSender.sendFailed=Kann Multitcast Nachricht nicht senden
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings_fr.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings_fr.properties
new file mode 100644
index 0000000..103245e
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings_fr.properties
@@ -0,0 +1,33 @@
+# 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.
+
+collectedInfo.noConnector=Impossible de trouver le connecteur pour [{0}] : 
[{1}]
+collectedInfo.notInitialized=Non initialisé
+
+heartbeatListener.errorCollectingInfo=Impossible d’initialiser la collection 
d'informations de charge
+heartbeatListener.refreshError=Impossible de collecter les informations sur la 
charge
+heartbeatListener.sendError=Impossible d'envoyer les informations de charge 
collectées
+heartbeatListener.senderInitError=Impossible d'initialiser l'expéditeur
+
+multiCastSender.multiCastFailed=Impossible d'utiliser le multicast
+multiCastSender.sendFailed=Impossible d'envoyer le message multicast
+
+tcpSender.connectionFailed=Impossible de se connecter au proxy
+tcpSender.invalidProxyList=Liste de proxies invalide
+tcpSender.notInitialized=Non initialisé
+tcpSender.readError=Erreur en lisant le contenu de la réponse
+tcpSender.responseError=Impossible de lire la réponse du proxy
+tcpSender.responseErrorCode=Erreur de réponse avec le code [{0}]
+tcpSender.sendFailed=Impossible d'envoyer les informations de charge 
collectées au proxy
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings_ja.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings_ja.properties
new file mode 100644
index 0000000..85ef216
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings_ja.properties
@@ -0,0 +1,33 @@
+# 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.
+
+collectedInfo.noConnector=[{0}]:[{1}]のコネクタが見つかりません。
+collectedInfo.notInitialized=初期化されていません
+
+heartbeatListener.errorCollectingInfo=情報収集を初期化できません。
+heartbeatListener.refreshError=負荷情報を収集できません
+heartbeatListener.sendError=収集された負荷情報を送信できません。
+heartbeatListener.senderInitError=Sender を初期化できません。
+
+multiCastSender.multiCastFailed=マルチキャストを利用できません。
+multiCastSender.sendFailed=マルチキャストメッセージを送信できません。
+
+tcpSender.connectionFailed=プロキシサーバーに接続できません。
+tcpSender.invalidProxyList=不正なプロキシリスト
+tcpSender.notInitialized=初期化されていません
+tcpSender.readError=レスポンス読み取り中のエラー
+tcpSender.responseError=プロキシサーバーからレスポンスを読み取ることができません。
+tcpSender.responseErrorCode=コード[{0}]によるレスポンスエラー
+tcpSender.sendFailed=収集した負荷情報をプロキシに送信できません。
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings_ko.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings_ko.properties
new file mode 100644
index 0000000..8cf4622
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings_ko.properties
@@ -0,0 +1,33 @@
+# 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.
+
+collectedInfo.noConnector=[{0}]:[{1}]을(를) 위한 connector를 찾을 수 없습니다.
+collectedInfo.notInitialized=초기화 안됨
+
+heartbeatListener.errorCollectingInfo=시스템 정보를 취합할 수 없습니다.
+heartbeatListener.refreshError=시스템 부하 정보를 취합할 수 없습니다.
+heartbeatListener.sendError=취합된 시스템 부하 정보를 보낼 수 없습니다.
+heartbeatListener.senderInitError=Sender를 초기화할 수 없습니다.
+
+multiCastSender.multiCastFailed=멀티캐스트를 사용할 수 없습니다.
+multiCastSender.sendFailed=멀티캐스트 메시지를 전송할 수 없습니다.
+
+tcpSender.connectionFailed=프록시에 연결할 수 없습니다.
+tcpSender.invalidProxyList=유효하지 않은 프록시 목록
+tcpSender.notInitialized=초기화되지 않았음
+tcpSender.readError=응답 컨텐트를 읽는 중 오류 발생
+tcpSender.responseError=프록시로부터 응답을 읽을 수 없습니다.
+tcpSender.responseErrorCode=코드 [{0}]와(과) 함께 응답 오류 발생
+tcpSender.sendFailed=취합된 시스템 부하 정보를 프록시에 전송할 수 없습니다.
diff --git a/java/org/apache/catalina/ha/backend/LocalStrings_zh_CN.properties 
b/java/org/apache/catalina/ha/backend/LocalStrings_zh_CN.properties
new file mode 100644
index 0000000..517f5b3
--- /dev/null
+++ b/java/org/apache/catalina/ha/backend/LocalStrings_zh_CN.properties
@@ -0,0 +1,33 @@
+# 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.
+
+collectedInfo.noConnector=找不到[{0}]的连接器:[{1}]
+collectedInfo.notInitialized=未初始化
+
+heartbeatListener.errorCollectingInfo=无法初始化信息收集
+heartbeatListener.refreshError=无法收集加载信息
+heartbeatListener.sendError=无法发送收集的加载信息
+heartbeatListener.senderInitError=无法初始化发件人
+
+multiCastSender.multiCastFailed=无法使用多播
+multiCastSender.sendFailed=无法发送多播信息
+
+tcpSender.connectionFailed=无法连接到代理
+tcpSender.invalidProxyList=无效的代理列表
+tcpSender.notInitialized=未初始化
+tcpSender.readError=读取响应内容时出错
+tcpSender.responseError=无法从代理读取响应
+tcpSender.responseErrorCode=代码为[{0}]的响应错误
+tcpSender.sendFailed=无法将收集的加载信息发送到代理
diff --git a/java/org/apache/catalina/ha/backend/MultiCastSender.java 
b/java/org/apache/catalina/ha/backend/MultiCastSender.java
index b955eee..50edc0a 100644
--- a/java/org/apache/catalina/ha/backend/MultiCastSender.java
+++ b/java/org/apache/catalina/ha/backend/MultiCastSender.java
@@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
 
 /*
  * Sender to proxies using multicast socket.
@@ -32,6 +33,7 @@ public class MultiCastSender
     implements Sender {
 
     private static final Log log = LogFactory.getLog(HeartbeatListener.class);
+    private static final StringManager sm = 
StringManager.getManager(MultiCastSender.class);
 
     HeartbeatListener config = null;
 
@@ -59,7 +61,7 @@ public class MultiCastSender
                 s.setTimeToLive(config.getTtl());
                 s.joinGroup(group);
             } catch (Exception ex) {
-                log.error("Unable to use multicast: " + ex);
+                log.error(sm.getString("multiCastSender.multiCastFailed"), ex);
                 s = null;
                 return -1;
             }
@@ -71,7 +73,7 @@ public class MultiCastSender
         try {
             s.send(data);
         } catch (Exception ex) {
-            log.error("Unable to send collected load information: " + ex);
+            log.error(sm.getString("multiCastSender.sendFailed"), ex);
             s.close();
             s = null;
             return -1;
diff --git a/java/org/apache/catalina/ha/backend/TcpSender.java 
b/java/org/apache/catalina/ha/backend/TcpSender.java
index 67873ab..7e1bda9 100644
--- a/java/org/apache/catalina/ha/backend/TcpSender.java
+++ b/java/org/apache/catalina/ha/backend/TcpSender.java
@@ -30,6 +30,7 @@ import java.util.StringTokenizer;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
 
 /*
  * Sender to proxies using multicast socket.
@@ -38,6 +39,7 @@ public class TcpSender
     implements Sender {
 
     private static final Log log = LogFactory.getLog(HeartbeatListener.class);
+    private static final StringManager sm = 
StringManager.getManager(TcpSender.class);
 
     HeartbeatListener config = null;
 
@@ -65,14 +67,15 @@ public class TcpSender
         while (tok.hasMoreTokens()) {
             String token = tok.nextToken().trim();
             int pos = token.indexOf(':');
-            if (pos <=0)
-                throw new Exception("bad ProxyList");
+            if (pos <= 0) {
+                throw new 
Exception(sm.getString("tcpSender.invalidProxyList"));
+            }
             proxies[i] = new Proxy();
             proxies[i].port = Integer.parseInt(token.substring(pos + 1));
             try {
                  proxies[i].address = InetAddress.getByName(token.substring(0, 
pos));
             } catch (Exception e) {
-                throw new Exception("bad ProxyList");
+                throw new 
Exception(sm.getString("tcpSender.invalidProxyList"));
             }
             i++;
         }
@@ -85,7 +88,7 @@ public class TcpSender
     @Override
     public int send(String mess) throws Exception {
         if (connections == null) {
-            log.error("Not initialized");
+            log.error(sm.getString("tcpSender.notInitialized"));
             return -1;
         }
         String requestLine = "POST " + config.getProxyURL() + " HTTP/1.0";
@@ -106,7 +109,7 @@ public class TcpSender
                     connectionReaders[i] = new BufferedReader(new 
InputStreamReader(connections[i].getInputStream()));
                     connectionWriters[i] = new BufferedWriter(new 
OutputStreamWriter(connections[i].getOutputStream()));
                 } catch (Exception ex) {
-                    log.error("Unable to connect to proxy: " + ex);
+                    log.error(sm.getString("tcpSender.connectionFailed"), ex);
                     close(i);
                 }
             }
@@ -124,7 +127,7 @@ public class TcpSender
                 writer.write("\r\n");
                 writer.flush();
             } catch (Exception ex) {
-                log.error("Unable to send collected load information to proxy: 
" + ex);
+                log.error(sm.getString("tcpSender.sendFailed"), ex);
                 close(i);
             }
             if (connections[i] == null)
@@ -133,14 +136,14 @@ public class TcpSender
             /* Read httpd answer */
             String responseStatus = connectionReaders[i].readLine();
             if (responseStatus == null) {
-                log.error("Unable to read response from proxy");
+                log.error(sm.getString("tcpSender.responseError"));
                 close(i);
                 continue;
             } else {
                 responseStatus = 
responseStatus.substring(responseStatus.indexOf(' ') + 1, 
responseStatus.indexOf(' ', responseStatus.indexOf(' ') + 1));
                 int status = Integer.parseInt(responseStatus);
                 if (status != 200) {
-                    log.error("Status is " + status);
+                    log.error(sm.getString("tcpSender.responseErrorCode", 
Integer.valueOf(status)));
                     close(i);
                     continue;
                 }
@@ -163,7 +166,7 @@ public class TcpSender
                         int thisTime = (contentLength > buf.length) ? 
buf.length : contentLength;
                         int n = connectionReaders[i].read(buf, 0, thisTime);
                         if (n <= 0) {
-                            log.error("Read content failed");
+                            log.error(sm.getString("tcpSender.readError"));
                             close(i);
                             break;
                         } else {

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to