Author: jfclere
Date: Thu Nov 29 09:14:27 2018
New Revision: 1847702
URL: http://svn.apache.org/viewvc?rev=1847702&view=rev
Log:
Add back the getters and setters and arrange the Listener so that it works in
tomcat9.
Modified:
tomcat/trunk/java/org/apache/catalina/ha/backend/CollectedInfo.java
tomcat/trunk/java/org/apache/catalina/ha/backend/HeartbeatListener.java
Modified: tomcat/trunk/java/org/apache/catalina/ha/backend/CollectedInfo.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/backend/CollectedInfo.java?rev=1847702&r1=1847701&r2=1847702&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/backend/CollectedInfo.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/ha/backend/CollectedInfo.java Thu Nov
29 09:14:27 2018
@@ -59,25 +59,36 @@ 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("\"", "");
/* Name are:
- * http-8080
- * jk-10.33.144.3-8009
- * jk-jfcpc%2F10.33.144.3-8009
+ * ajp-nio-8009
+ * ajp-nio-127.0.0.1-8009
+ * ajp-nio-0:0:0:0:0:0:0:1-8009
+ * ajp-nio-10.36.116.209-8009
*/
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; /* 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 */
+ break; /* Done: take the first one */
+ 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("Can't find connector for " + host + ":" +
port);
Modified:
tomcat/trunk/java/org/apache/catalina/ha/backend/HeartbeatListener.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/backend/HeartbeatListener.java?rev=1847702&r1=1847701&r2=1847702&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/backend/HeartbeatListener.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/ha/backend/HeartbeatListener.java Thu
Nov 29 09:14:27 2018
@@ -18,8 +18,6 @@
package org.apache.catalina.ha.backend;
-import org.apache.catalina.ContainerEvent;
-import org.apache.catalina.ContainerListener;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
@@ -33,45 +31,135 @@ import org.apache.juli.logging.LogFactor
* what about the bind(IP. port) only IP makes sense (for the moment).
* BTW:v = version :-)
*/
-public class HeartbeatListener implements LifecycleListener, ContainerListener
{
+public class HeartbeatListener implements LifecycleListener {
private static final Log log = LogFactory.getLog(HeartbeatListener.class);
/* To allow to select the connector */
- private int port = 0;
- private String host = null;
+ protected int port = 8009;
+ protected String host = null;
+
+ /**
+ * @return the host corresponding to the connector
+ * we want to proxy.
+ */
+ public String getHost() {
+ 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 */
- private final String ip = "224.0.1.105"; /* Multicast IP */
- private final int multiport = 23364; /* Multicast Port */
- private final int ttl = 16;
+ protected String ip = "224.0.1.105"; /* Multicast IP */
+ protected int multiport = 23364; /* Multicast Port */
+ protected int ttl = 16;
- public String getHost() { return host; }
+ /* 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 toogles
+ * 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
+ * <Location "/HeartbeatListener">
+ * SetHandler heartbeat
+ * </Location>
+ * 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;
@Override
- public void containerEvent(ContainerEvent event) {
- }
-
- @Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.PERIODIC_EVENT.equals(event.getType())) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]