You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pe...@apache.org on 2006/12/10 20:45:41 UTC
svn commit: r485242 -
/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/
Author: pero
Date: Sun Dec 10 11:45:39 2006
New Revision: 485242
URL: http://svn.apache.org/viewvc?view=rev&rev=485242
Log:
Update status ant task to new mod_jk status xml format.
Add new update and reset tasks to handle new txt result message.
Added:
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkResult.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkSoftware.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java
Modified:
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancer.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkServer.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatus.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/antlib.xml
tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks
Added: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java?view=auto&rev=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java (added)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java Sun Dec 10 11:45:39 2006
@@ -0,0 +1,209 @@
+/*
+ * 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.jk.status;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.catalina.ant.AbstractCatalinaTask;
+import org.apache.catalina.util.Base64;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Ant task that implements mod_jk 1.2.20 result message string
+ *
+ * @author Peter Rossbach
+ * @version $Revision:$
+ * @since mod_jk 1.2.20
+ */
+public abstract class AbstractJkStatusTask extends AbstractCatalinaTask {
+
+ /**
+ * Execute the requested operation.
+ *
+ * @exception BuildException
+ * if an error occurs
+ */
+ public void execute() throws BuildException {
+
+ super.execute();
+ checkParameter();
+ StringBuffer sb = createLink();
+ execute(sb.toString(), null, null, -1);
+
+ }
+
+ protected abstract void checkParameter() ;
+ protected abstract StringBuffer createLink() ;
+
+ /**
+ * Execute the specified command, based on the configured properties.
+ * The input stream will be closed upon completion of this task, whether
+ * it was executed successfully or not.
+ *
+ * @param command Command to be executed
+ * @param istream InputStream to include in an HTTP PUT, if any
+ * @param contentType Content type to specify for the input, if any
+ * @param contentLength Content length to specify for the input, if any
+ *
+ * @exception BuildException if an error occurs
+ */
+ public void execute(String command, InputStream istream,
+ String contentType, int contentLength)
+ throws BuildException {
+
+ InputStreamReader reader = null;
+ try {
+
+ HttpURLConnection hconn = send(command, istream, contentType, contentLength);
+
+ // Process the response message
+ reader = new InputStreamReader(hconn.getInputStream(), "UTF-8");
+ String error = null;
+ error = handleResult(reader, error);
+ if (error != null && isFailOnError()) {
+ // exception should be thrown only if failOnError == true
+ // or error line will be logged twice
+ throw new BuildException(error);
+ }
+ } catch (Throwable t) {
+ if (isFailOnError()) {
+ throw new BuildException(t);
+ } else {
+ handleErrorOutput(t.getMessage());
+ }
+ } finally {
+ closeRedirector();
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (Throwable u) {
+ ;
+ }
+ reader = null;
+ }
+ if (istream != null) {
+ try {
+ istream.close();
+ } catch (Throwable u) {
+ ;
+ }
+ istream = null;
+ }
+ }
+
+ }
+
+ private String handleResult(InputStreamReader reader, String error) throws IOException {
+ StringBuffer buff = new StringBuffer();
+ int msgPriority = Project.MSG_INFO;
+ boolean first = true;
+ while (true) {
+ int ch = reader.read();
+ if (ch < 0) {
+ break;
+ } else if ((ch == '\r') || (ch == '\n')) {
+ // in Win \r\n would cause handleOutput() to be called
+ // twice, the second time with an empty string,
+ // producing blank lines
+ if (buff.length() > 0) {
+ String line = buff.toString();
+ buff.setLength(0);
+ if (first) {
+ if (!line.startsWith("Result: type=OK")) {
+ error = line;
+ msgPriority = Project.MSG_ERR;
+ }
+ first = false;
+ }
+ handleOutput(line, msgPriority);
+ }
+ } else {
+ buff.append((char) ch);
+ }
+ }
+ if (buff.length() > 0) {
+ handleOutput(buff.toString(), msgPriority);
+ }
+ return error;
+ }
+
+ protected HttpURLConnection send(String command, InputStream istream, String contentType, int contentLength) throws IOException, MalformedURLException, ProtocolException {
+ URLConnection conn;
+ // Create a connection for this command
+ conn = (new URL(url + command)).openConnection();
+ HttpURLConnection hconn = (HttpURLConnection) conn;
+
+ // Set up standard connection characteristics
+ hconn.setAllowUserInteraction(false);
+ hconn.setDoInput(true);
+ hconn.setUseCaches(false);
+ if (istream != null) {
+ hconn.setDoOutput(true);
+ hconn.setRequestMethod("PUT");
+ if (contentType != null) {
+ hconn.setRequestProperty("Content-Type", contentType);
+ }
+ if (contentLength >= 0) {
+ hconn.setRequestProperty("Content-Length",
+ "" + contentLength);
+ }
+ } else {
+ hconn.setDoOutput(false);
+ hconn.setRequestMethod("GET");
+ }
+ hconn.setRequestProperty("User-Agent",
+ "JkStatus-Ant-Task/1.1");
+
+ // Set up an authorization header with our credentials
+ String input = username + ":" + password;
+ String output = new String(Base64.encode(input.getBytes()));
+ hconn.setRequestProperty("Authorization",
+ "Basic " + output);
+
+ // Establish the connection with the server
+ hconn.connect();
+ // Send the request data (if any)
+ if (istream != null) {
+ BufferedOutputStream ostream =
+ new BufferedOutputStream(hconn.getOutputStream(), 1024);
+ byte buffer[] = new byte[1024];
+ while (true) {
+ int n = istream.read(buffer);
+ if (n < 0) {
+ break;
+ }
+ ostream.write(buffer, 0, n);
+ }
+ ostream.flush();
+ ostream.close();
+ istream.close();
+ }
+ return hconn;
+ }
+
+
+}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancer.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancer.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancer.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancer.java Sun Dec 10 11:45:39 2006
@@ -27,14 +27,23 @@
*/
public class JkBalancer implements Serializable {
- int id ;
+ int id =-1;
String name ;
String type ;
boolean sticky ;
boolean stickyforce;
int retries ;
int recover ;
-
+ String method ;
+ String lock ;
+ int good = -1 ;
+ int degraded = -1;
+ int bad = -1 ;
+ int busy = -1;
+ int max_busy = -1 ;
+ int member_count = -1 ;
+ int map_count = -1 ;
+
List members = new ArrayList() ;
List mappings = new ArrayList() ;
@@ -101,13 +110,13 @@
/**
* @return Returns the recover.
*/
- public int getRecover() {
+ public int getRecover_time() {
return recover;
}
/**
* @param recover The recover to set.
*/
- public void setRecover(int recover) {
+ public void setRecover_time(int recover) {
this.recover = recover;
}
/**
@@ -125,25 +134,25 @@
/**
* @return Returns the sticky.
*/
- public boolean isSticky() {
+ public boolean isSticky_session() {
return sticky;
}
/**
* @param sticky The sticky to set.
*/
- public void setSticky(boolean sticky) {
+ public void setSticky_session(boolean sticky) {
this.sticky = sticky;
}
/**
* @return Returns the stickyforce.
*/
- public boolean isStickyforce() {
+ public boolean isSticky_session_force() {
return stickyforce;
}
/**
* @param stickyforce The stickyforce to set.
*/
- public void setStickyforce(boolean stickyforce) {
+ public void setSticky_session_force(boolean stickyforce) {
this.stickyforce = stickyforce;
}
/**
@@ -158,5 +167,135 @@
public void setType(String type) {
this.type = type;
}
+ /**
+ * @return the bad
+ * @since mod_jk 1.2.20
+ */
+ public int getBad() {
+ return bad;
+ }
+ /**
+ * @param bad the bad to set
+ * @since mod_jk 1.2.20
+ */
+ public void setBad(int bad) {
+ this.bad = bad;
+ }
+ /**
+ * @return the busy
+ * @since mod_jk 1.2.20
+ */
+ public int getBusy() {
+ return busy;
+ }
+ /**
+ * @param busy the busy to set
+ * @since mod_jk 1.2.20
+ */
+ public void setBusy(int busy) {
+ this.busy = busy;
+ }
+ /**
+ * @return the degraded
+ * @since mod_jk 1.2.20
+ */
+ public int getDegraded() {
+ return degraded;
+ }
+ /**
+ * @param degraded the degraded to set
+ * @since mod_jk 1.2.20
+ */
+ public void setDegraded(int degraded) {
+ this.degraded = degraded;
+ }
+ /**
+ * @return the good
+ * @since mod_jk 1.2.20
+ */
+ public int getGood() {
+ return good;
+ }
+ /**
+ * @param good the good to set
+ * @since mod_jk 1.2.20
+ */
+ public void setGood(int good) {
+ this.good = good;
+ }
+ /**
+ * @return the lock
+ * @since mod_jk 1.2.20
+ */
+ public String getLock() {
+ return lock;
+ }
+ /**
+ * @param lock the lock to set
+ * @since mod_jk 1.2.20
+ */
+ public void setLock(String lock) {
+ this.lock = lock;
+ }
+ /**
+ * @return the max_busy
+ * @since mod_jk 1.2.20
+ */
+ public int getMax_busy() {
+ return max_busy;
+ }
+ /**
+ * @param max_busy the max_busy to set
+ * @since mod_jk 1.2.20
+ */
+ public void setMax_busy(int max_busy) {
+ this.max_busy = max_busy;
+ }
+ /**
+ * @return the method
+ * @since mod_jk 1.2.20
+ */
+ public String getMethod() {
+ return method;
+ }
+ /**
+ * @param method the method to set
+ * @since mod_jk 1.2.20
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ /**
+ * @return the member_count
+ * @since mod_jk 1.2.20
+ */
+ public int getMember_count() {
+ return member_count;
+ }
+
+ /**
+ * @param member_count the member_count to set
+ * @since mod_jk 1.2.20
+ */
+ public void setMember_count(int member_count) {
+ this.member_count = member_count;
+ }
+
+ /**
+ * @return the map_count
+ * @since mod_jk 1.2.20
+ */
+ public int getMap_count() {
+ return map_count;
+ }
+ /**
+ * @param map_count the map_count to set
+ * @since mod_jk 1.2.20
+ */
+ public void setMap_count(int map_count) {
+ this.map_count = map_count;
+ }
+
}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java Sun Dec 10 11:45:39 2006
@@ -24,18 +24,34 @@
* @see org.apache.jk.status.JkStatusParser
*/
public class JkBalancerMapping implements Serializable {
- String type ;
+ int id =-1 ;
+ String type ;
String uri;
String context ;
+ String source ;
/**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+ /**
+ * @param id the id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ /**
* @return Returns the context.
+ * @deprecated mod_jk 1.2.20
*/
public String getContext() {
return context;
}
/**
* @param context The context to set.
+ * @deprecated mod_jk 1.2.20
*/
public void setContext(String context) {
this.context = context;
@@ -64,4 +80,19 @@
public void setUri(String uri) {
this.uri = uri;
}
+ /**
+ * @return the source
+ * @since mod_jk 1.2.20
+ */
+ public String getSource() {
+ return source;
+ }
+ /**
+ * @param source the source to set
+ * @since mod_jk 1.2.20
+ */
+ public void setSource(String source) {
+ this.source = source;
+ }
+
}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java Sun Dec 10 11:45:39 2006
@@ -29,13 +29,16 @@
*/
public class JkBalancerMember implements Serializable {
- int id;
+ int id = -1;
String name;
- /* possible with > 1.2.16 */
+ /* possible with >= 1.2.16 */
String jvm_route;
+ /* possible with >= 1.2.20 */
+ String route;
+
String type;
String host;
@@ -82,9 +85,13 @@
/* possible with > 1.2.16 */
int distance = -1;
+ /* possible with > 1.2.20 */
+ int time_to_recover = -1 ;
+
/**
* @return Returns the jvm_route.
- * @since mod_jk 1.2.19
+ * @since mod_jk 1.2.16
+ * @deprecated
*/
public String getJvm_route() {
return jvm_route;
@@ -92,13 +99,30 @@
/**
* @param jvm_route The jvm_route to set.
- * @since mod_jk 1.2.19
+ * @since mod_jk 1.2.16
+ * @deprecated
*/
public void setJvm_route(String jvm_route) {
this.jvm_route = jvm_route;
}
/**
+ * @return the route
+ * @since mod_jk 1.2.20
+ */
+ public String getRoute() {
+ return route;
+ }
+
+ /**
+ * @param route the route to set
+ * @since mod_jk 1.2.20
+ */
+ public void setRoute(String route) {
+ this.route = route;
+ }
+
+ /**
* @return Returns the address.
*/
public String getAddress() {
@@ -133,7 +157,7 @@
* @return Returns the maxbusy.
* @since mod_jk 1.2.18
*/
- public int getMaxbusy() {
+ public int getMax_busy() {
return maxbusy;
}
@@ -141,7 +165,7 @@
* @param maxbusy The maxbusy to set.
* @since mod_jk 1.2.18
*/
- public void setMaxbusy(int maxbusy) {
+ public void setMax_busy(int maxbusy) {
this.maxbusy = maxbusy;
}
@@ -164,7 +188,7 @@
* @return Returns the clienterrors.
* @since mod_jk 1.2.19
*/
- public long getClienterrors() {
+ public long getClient_errors() {
return clienterrors;
}
@@ -172,7 +196,7 @@
* @param clienterrors The clienterrors to set.
* @since mod_jk 1.2.19
*/
- public void setClienterrors(long clienterrors) {
+ public void setClient_errors(long clienterrors) {
this.clienterrors = clienterrors;
}
@@ -434,6 +458,22 @@
public void setDistance(int distance) {
this.distance = distance;
}
+
+ /**
+ * @return the time_to_recover
+ * @since mod_jk 1.2.20
+ */
+ public int getTime_to_recover() {
+ return time_to_recover;
+ }
+
+ /**
+ * @param time_to_recover the time_to_recover to set
+ * @since mod_jk 1.2.20
+ */
+ public void setTime_to_recover(int time_to_recover) {
+ this.time_to_recover = time_to_recover;
+ }
}
Added: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkResult.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkResult.java?view=auto&rev=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkResult.java (added)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkResult.java Sun Dec 10 11:45:39 2006
@@ -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.jk.status;
+
+import java.io.Serializable;
+
+/**
+ * @author Peter Rossbach
+ * @version $Revision:$ $Date:$
+ * @see org.apache.jk.status.JkStatusParser
+ */
+public class JkResult implements Serializable {
+ String type ;
+ String message;
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+ /**
+ * @param message the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkServer.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkServer.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkServer.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkServer.java Sun Dec 10 11:45:39 2006
@@ -26,9 +26,7 @@
public class JkServer implements Serializable {
String name ;
String port;
- String software;
- String version ;
-
+
/**
* @return Returns the name.
*/
@@ -53,28 +51,6 @@
public void setPort(String port) {
this.port = port;
}
- /**
- * @return Returns the software.
- */
- public String getSoftware() {
- return software;
- }
- /**
- * @param software The software to set.
- */
- public void setSoftware(String software) {
- this.software = software;
- }
- /**
- * @return Returns the version.
- */
- public String getVersion() {
- return version;
- }
- /**
- * @param version The version to set.
- */
- public void setVersion(String version) {
- this.version = version;
- }
+
+
}
Added: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkSoftware.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkSoftware.java?view=auto&rev=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkSoftware.java (added)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkSoftware.java Sun Dec 10 11:45:39 2006
@@ -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.jk.status;
+
+import java.io.Serializable;
+
+/**
+ * @author Peter Rossbach
+ * @version $Revision:$ $Date:$
+ * @see org.apache.jk.status.JkStatusParser
+ */
+public class JkSoftware implements Serializable {
+ String web_server;
+ String jk_version ;
+
+ /**
+ * @return Returns the software.
+ */
+ public String getWeb_server() {
+ return web_server;
+ }
+ /**
+ * @param software The software to set.
+ */
+ public void setWeb_server(String software) {
+ this.web_server = software;
+ }
+ /**
+ * @return Returns the version.
+ */
+ public String getJk_version() {
+ return jk_version;
+ }
+ /**
+ * @param version The version to set.
+ */
+ public void setJk_version(String version) {
+ this.jk_version = version;
+ }
+}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatus.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatus.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatus.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatus.java Sun Dec 10 11:45:39 2006
@@ -28,8 +28,10 @@
public class JkStatus implements Serializable {
JkServer server ;
+ JkSoftware software ;
+ JkResult result ;
List balancers = new ArrayList() ;
-
+
/**
* @return Returns the balancers.
*/
@@ -60,5 +62,29 @@
public void setServer(JkServer server) {
this.server = server ;
}
+ /**
+ * @return the result
+ */
+ public JkResult getResult() {
+ return result;
+ }
+ /**
+ * @param result the result to set
+ */
+ public void setResult(JkResult result) {
+ this.result = result;
+ }
+ /**
+ * @return Returns the software.
+ */
+ public JkSoftware getSoftware() {
+ return software;
+ }
+ /**
+ * @param software The software to set.
+ */
+ public void setSoftware(JkSoftware software) {
+ this.software = software;
+ }
}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java Sun Dec 10 11:45:39 2006
@@ -60,7 +60,8 @@
JkStatus status = null;
try {
- hconn = openConnection(url + "?cmd=show&mime=xml", username, password);
+ // FIXME: use cmd show for older mod_jk versions
+ hconn = openConnection(url + "?cmd=list&mime=xml", username, password);
Digester digester = JkStatusParser.getDigester();
synchronized (digester) {
status = (JkStatus) digester.parse(hconn.getInputStream());
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java Sun Dec 10 11:45:39 2006
@@ -21,6 +21,7 @@
import org.apache.tomcat.util.digester.Digester;
/**
+ * mod_jk 1.2.19 document:<br/>
* <code>
*
* <?xml version="1.0" encoding="UTF-8" ?>
@@ -36,6 +37,94 @@
* </jk:balancer>
* </jk:balancers>
* </jk:status>
+ * </code>
+ * <br/>
+ * mod_jk 1.2.20 document:<br/>
+ * <code>
+ * <?xml version="1.0" encoding="UTF-8" ?>
+ * <jk:status xmlns:jk="http://tomcat.apache.org">
+ * <jk:server
+ * name="127.0.0.1"
+ * port="2080"
+ * software="Apache/2.0.59 (Unix) mod_jk/1.2.20-dev"
+ * version="1.2.20"/>
+ * <jk:balancers>
+ * <jk:balancer
+ * name="loadbalancer"
+ * type="lb"
+ * sticky="True"
+ * stickyforce="False"
+ * retries="2"
+ * recover="60"
+ * method="Request"
+ * lock="Optimistic"
+ * good="2"
+ * degraded="0"
+ * bad="0"
+ * busy="0"
+ * max_busy="0">
+ * <jk:member
+ * name="node01"
+ * type="ajp13"
+ * host="localhost"
+ * port="7309"
+ * address="127.0.0.1:7309"
+ * activation="ACT"
+ * lbfactor="1"
+ * jvm_route="node01"
+ * redirect=""
+ * domain=""
+ * distance="0"
+ * state="N/A"
+ * lbmult="1"
+ * lbvalue="0"
+ * elected="0"
+ * errors="0"
+ * clienterrors="0"
+ * transferred="0"
+ * readed="0"
+ * busy="0"
+ * maxbusy="0"
+ * time-to-recover="0"/>
+ * <jk:member
+ * name="node02"
+ * type="ajp13"
+ * host="localhost"
+ * port="7409"
+ * address="127.0.0.1:7409"
+ * activation="ACT"
+ * lbfactor="1"
+ * jvm_route="node02"
+ * redirect=""
+ * domain=""
+ * distance="0"
+ * state="N/A"
+ * lbmult="1"
+ * lbvalue="0"
+ * elected="0"
+ * errors="0"
+ * clienterrors="0"
+ * transferred="0"
+ * readed="0"
+ * busy="0"
+ * maxbusy="0"
+ * time-to-recover="0"/>
+ * <jk:map
+ * type="Wildchar"
+ * uri="/ClusterTest*"
+ * source="JkMount"/>
+ * <jk:map
+ * type="Wildchar"
+ * uri="/myapps*"
+ * source="JkMount"/>
+ * <jk:map
+ * type="Wildchar"
+ * uri="/last*"
+ * source="JkMount"/>
+ * </jk:balancer>
+ * </jk:balancers>
+ * </jk:status>
+ *
*
* </code>
* @author Peter Rossbach
@@ -90,6 +179,18 @@
digester.addSetProperties("jk:status/jk:server");
digester.addSetNext("jk:status/jk:server", "setServer",
"org.apache.jk.status.JkServer");
+
+ digester.addObjectCreate("jk:status/jk:software",
+ "org.apache.jk.status.JkSoftware", "className");
+ digester.addSetProperties("jk:status/jk:software");
+ digester.addSetNext("jk:status/jk:software", "setSoftware",
+ "org.apache.jk.status.JkSoftware");
+
+ digester.addObjectCreate("jk:status/jk:result",
+ "org.apache.jk.status.JkResult", "className");
+ digester.addSetProperties("jk:status/jk:result");
+ digester.addSetNext("jk:status/jk:result", "setResult",
+ "org.apache.jk.status.JkResult");
digester.addObjectCreate("jk:status/jk:balancers/jk:balancer",
"org.apache.jk.status.JkBalancer", "className");
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java Sun Dec 10 11:45:39 2006
@@ -20,20 +20,25 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import org.apache.catalina.ant.AbstractCatalinaTask;
import org.apache.tools.ant.BuildException;
/**
* Ant task that implements the <code>/jkstatus?cmd=reset&w=loadbalancer</code> command, supported by the
- * mod_jk status (1.2.15) application.
+ * mod_jk status (1.2.20) application.
*
* @author Peter Rossbach
* @version $Revision$
- * @since 5.5.13
+ * @since mod_jk 1.2.20
*/
-public class JkStatusResetTask extends AbstractCatalinaTask {
+public class JkStatusResetTask extends AbstractJkStatusTask {
- private String workerLb;
+ /**
+ * The descriptive information about this implementation.
+ */
+ private static final String info = "org.apache.jk.status.JkStatusResetTask/1.1";
+
+ private String worker;
+ private String loadbalancer;
/**
*
@@ -44,52 +49,71 @@
}
/**
- * @return Returns the workerLb.
+ * Return descriptive information about this implementation and the
+ * corresponding version number, in the format
+ * <code><description>/<version></code>.
*/
- public String getWorkerLb() {
- return workerLb;
- }
+ public String getInfo() {
- /**
- * @param workerLb
- * The workerLb to set.
- */
- public void setWorkerLb(String workerLb) {
- this.workerLb = workerLb;
- }
+ return (info);
+ }
+
/**
- * Execute the requested operation.
- *
- * @exception BuildException
- * if an error occurs
- */
- public void execute() throws BuildException {
+ * @return the loadbalancer
+ */
+ public String getLoadbalancer() {
+ return loadbalancer;
+ }
- super.execute();
- checkParameter();
- StringBuffer sb = createLink();
- execute(sb.toString(), null, null, -1);
- }
+ /**
+ * @param loadbalancer the loadbalancer to set
+ */
+ public void setLoadbalancer(String loadbalancer) {
+ this.loadbalancer = loadbalancer;
+ }
- /**
+
+ /**
+ * @return the worker
+ */
+ public String getWorker() {
+ return worker;
+ }
+
+
+ /**
+ * @param worker the worker to set
+ */
+ public void setWorker(String worker) {
+ this.worker = worker;
+ }
+
+
+ /**
* Create jkstatus reset link
* <ul>
- * <li><b>load balance example:
- * </b>http://localhost/jkstatus?cmd=reset&w=loadbalancer&mime=txt</li>
+ * <li><b>loadbalancer example:
+ * </b>http://localhost/jkstatus?cmd=reset&mime=txt&w=loadbalancer</li>
+ * <li><b>loadbalancer + sub worker example:
+ * </b>http://localhost/jkstatus?cmd=reset&mime=txt&w=loadbalancer&sw=node01</li>
* </ul>
*
- * @return create jkstatus link
+ * @return create jkstatus reset link
*/
- private StringBuffer createLink() {
+ protected StringBuffer createLink() {
// Building URL
StringBuffer sb = new StringBuffer();
try {
sb.append("?cmd=reset");
- sb.append("&w=");
- sb.append(URLEncoder.encode(workerLb, getCharset()));
sb.append("&mime=txt");
+ sb.append("&w=");
+ sb.append(URLEncoder.encode(loadbalancer, getCharset()));
+ if(worker != null) {
+ sb.append("&sw=");
+ sb.append(URLEncoder.encode(worker, getCharset()));
+ }
} catch (UnsupportedEncodingException e) {
throw new BuildException("Invalid 'charset' attribute: "
@@ -99,11 +123,11 @@
}
/**
- * check correct lb and worker pararmeter
+ * check correct pararmeter
*/
protected void checkParameter() {
- if (workerLb == null) {
- throw new BuildException("Must specify 'workerLb' attribute");
+ if (loadbalancer == null) {
+ throw new BuildException("Must specify 'loadbalanacer' attribute");
}
}
}
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java Sun Dec 10 11:45:39 2006
@@ -38,7 +38,7 @@
/**
* The descriptive information about this implementation.
*/
- private static final String info = "org.apache.jk.status.JkStatusTask/1.1";
+ private static final String info = "org.apache.jk.status.JkStatusTask/1.2";
/**
* Store status as <code>resultProperty</code> prefix.
@@ -181,17 +181,34 @@
try {
JkStatusAccessor accessor = new JkStatusAccessor();
JkStatus status = accessor.status(url, username, password);
+ if (status.result != null && !"OK".equals(status.result.type) ) {
+ if (getErrorProperty() != null) {
+ getProject().setNewProperty(errorProperty, status.result.message);
+ }
+ if (isFailOnError()) {
+ throw new BuildException(status.result.message);
+ } else {
+ handleErrorOutput(status.result.message);
+ return;
+ }
+
+ }
+
if (!isWorkerOnly && !isLoadbalancerOnly) {
JkServer server = status.getServer();
+ JkSoftware software = status.getSoftware();
+ JkResult result = status.getResult();
if (resultproperty != null) {
- createProperty(server, "name");
- createProperty(server, "port");
- createProperty(server, "version");
- createProperty(server, "software");
+ createProperty(server, "server", "name");
+ createProperty(server, "server", "port");
+ createProperty(software, "web_server");
+ createProperty(software, "jk_version");
+ createProperty(result, "result", "type");
+ createProperty(result, "result", "message");
}
if (isEcho()) {
- handleOutput("server name=" + server.getName() + "."
- + server.getPort() + " - " + server.getSoftware());
+ handleOutput("server name=" + server.getName() + ":"
+ + server.getPort() + " - " + software.getWeb_server() + " - " + software.getJk_version());
}
}
List balancers = status.getBalancers();
@@ -208,9 +225,13 @@
}
} else {
if (!isWorkerOnly) {
- if (resultproperty != null) {
- balancerIndex = Integer.toString(balancer.getId());
- setPropertyBalancer(balancer,balancerIndex);
+ if (resultproperty != null) {
+ if ( balancer.getId() >= 0)
+ balancerIndex = Integer.toString(balancer.getId());
+ else
+ balancerIndex = balancer.getName() ;
+
+ setPropertyBalancer(balancer,balancerIndex);
}
echoBalancer(balancer);
}
@@ -229,7 +250,7 @@
}
} else {
if (resultproperty != null) {
- setPropertyWorker(balancerIndex, member);
+ setPropertyWorker(null, member);
}
echoWorker(member);
if (member.getStatus() != null && !"OK".equals(member.getStatus())) {
@@ -247,37 +268,61 @@
if (!isWorkerOnly) {
if (resultproperty != null && members.size() > 0) {
getProject().setNewProperty(
- resultproperty + ".balancer."
- + balancerIndex + ".member.length",
+ resultproperty + "."
+ + balancer.getName() + ".length",
Integer.toString(members.size()));
}
List mappings = balancer.getBalancerMappings();
int j = 0;
+ String mapIndex ;
+ if( balancerIndex != null )
+ mapIndex = balancerIndex + ".map" ;
+ else
+ mapIndex = "map" ;
for (Iterator iterator = mappings.iterator(); iterator
.hasNext(); j++) {
JkBalancerMapping mapping = (JkBalancerMapping) iterator
.next();
if (resultproperty != null) {
- String stringIndex2 = Integer.toString(j);
- createProperty(mapping, balancerIndex,
+ String stringIndex2 ;
+ if( mapping.getId() >= 0) {
+ stringIndex2 = Integer.toString(mapping.getId()) ;
+ } else {
+ stringIndex2 = Integer.toString(j);
+ }
+ createProperty(mapping, mapIndex,
stringIndex2, "type");
- createProperty(mapping, balancerIndex,
+ createProperty(mapping, mapIndex,
stringIndex2, "uri");
- createProperty(mapping, balancerIndex,
+ createProperty(mapping, mapIndex,
stringIndex2, "context");
+ createProperty(mapping, mapIndex,
+ stringIndex2, "source");
}
if (isEcho()) {
- handleOutput("balancer name="
+ String mappingOut ;
+
+ if(mapping.source != null) {
+ mappingOut =
+ "balancer name="
+ + balancer.getName() + " mappingtype="
+ + mapping.getType() + " uri="
+ + mapping.getUri() + " source="
+ + mapping.getSource() ;
+ } else {
+ mappingOut = "balancer name="
+ balancer.getName() + " mappingtype="
+ mapping.getType() + " uri="
+ mapping.getUri() + " context="
- + mapping.getContext());
+ + mapping.getContext() ;
+ }
+ handleOutput(mappingOut);
}
}
if (resultproperty != null && mappings.size() > 0) {
getProject().setNewProperty(
- resultproperty + ".balancer."
- + balancerIndex + ".map.length",
+ resultproperty + "."
+ + mapIndex + ".length",
Integer.toString(mappings.size()));
}
}
@@ -286,7 +331,7 @@
if (!isWorkerOnly && !isLoadbalancerOnly) {
if (resultproperty != null && balancers.size() > 0) {
getProject().setNewProperty(
- resultproperty + ".balancer.length",
+ resultproperty + ".length",
Integer.toString(balancers.size()));
}
}
@@ -351,17 +396,38 @@
*/
private void setPropertyBalancerOnly(JkBalancer balancer) {
String prefix = resultproperty + "." + balancer.getName();
- getProject().setNewProperty(prefix + ".id",
+ if(balancer.getId() >= 0 ) {
+ getProject().setNewProperty(prefix + ".id",
Integer.toString(balancer.getId()));
+ }
getProject().setNewProperty(prefix + ".type", balancer.getType());
- getProject().setNewProperty(prefix + ".sticky",
- Boolean.toString(balancer.isSticky()));
- getProject().setNewProperty(prefix + ".stickyforce",
- Boolean.toString(balancer.isStickyforce()));
+ getProject().setNewProperty(prefix + ".stick_session",
+ Boolean.toString(balancer.isSticky_session()));
+ getProject().setNewProperty(prefix + ".sticky_session_force",
+ Boolean.toString(balancer.isSticky_session_force()));
getProject().setNewProperty(prefix + ".retries",
Integer.toString(balancer.getRetries()));
- getProject().setNewProperty(prefix + ".recover",
- Integer.toString(balancer.getRecover()));
+ getProject().setNewProperty(prefix + ".recover_time",
+ Integer.toString(balancer.getRecover_time()));
+ getProject().setNewProperty(prefix + ".method",
+ balancer.getMethod());
+ getProject().setNewProperty(prefix + ".good",
+ Integer.toString(balancer.getGood()));
+ getProject().setNewProperty(prefix + ".degraded",
+ Integer.toString(balancer.getDegraded()));
+ getProject().setNewProperty(prefix + ".bad",
+ Integer.toString(balancer.getBad()));
+ getProject().setNewProperty(prefix + ".busy",
+ Integer.toString(balancer.getBusy()));
+ getProject().setNewProperty(prefix + ".map_count",
+ Integer.toString(balancer.getMap_count()));
+ getProject().setNewProperty(prefix + ".member_count",
+ Integer.toString(balancer.getMember_count()));
+ getProject().setNewProperty(prefix + ".max_busy",
+ Integer.toString(balancer.getMax_busy()));
+ getProject().setNewProperty(prefix + ".lock",
+ balancer.getLock());
+
}
/**
@@ -369,23 +435,58 @@
* @return
*/
private void setPropertyBalancer(JkBalancer balancer,String balancerIndex) {
- createProperty(balancer, balancerIndex, "id");
+ if(balancer.id >= 0) {
+ createProperty(balancer, balancerIndex, "id");
+ }
+
createProperty(balancer, balancerIndex, "name");
createProperty(balancer, balancerIndex, "type");
- createProperty(balancer, balancerIndex, "sticky");
- createProperty(balancer, balancerIndex, "stickyforce");
+ createProperty(balancer, balancerIndex, "sticky_session");
+ createProperty(balancer, balancerIndex, "sticky_session_force");
createProperty(balancer, balancerIndex, "retries");
- createProperty(balancer, balancerIndex, "recover");
- }
+ createProperty(balancer, balancerIndex, "recover_time");
+ if(balancer.getMethod() != null) {
+ createProperty(balancer, balancerIndex, "method");
+ }
+ if(balancer.getLock() != null) {
+ createProperty(balancer, balancerIndex, "lock");
+ }
+ if(balancer.getGood() >= 0) {
+ createProperty(balancer, balancerIndex, "good");
+ }
+ if(balancer.getDegraded() >= 0) {
+ createProperty(balancer, balancerIndex, "degraded");
+ }
+ if(balancer.getBad() >= 0) {
+ createProperty(balancer, balancerIndex, "bad");
+ }
+ if(balancer.getBusy() >= 0) {
+ createProperty(balancer, balancerIndex, "busy");
+ }
+ if(balancer.getMax_busy() >= 0) {
+ createProperty(balancer, balancerIndex, "max_busy");
+ }
+ if(balancer.getMember_count() >=0) {
+ createProperty(balancer, balancerIndex, "member_count");
+ }
+ if(balancer.getMember_count() >=0) {
+ createProperty(balancer, balancerIndex, "map_count");
+ }
+ }
/**
* @param balancerIndex
* @param member
*/
private void setPropertyWorker(String balancerIndex, JkBalancerMember member) {
- String workerIndex = Integer.toString(member.getId());
- createProperty(member, balancerIndex, workerIndex, "id");
- createProperty(member, balancerIndex, workerIndex, "name");
+ String workerIndex ;
+ if(member.getId() >= 0) {
+ workerIndex = Integer.toString(member.getId());
+ createProperty(member, balancerIndex, workerIndex, "id");
+ createProperty(member, balancerIndex, workerIndex, "name");
+ } else {
+ workerIndex = member.getName();
+ }
createProperty(member, balancerIndex, workerIndex, "type");
createProperty(member, balancerIndex, workerIndex, "host");
createProperty(member, balancerIndex, workerIndex, "port");
@@ -393,6 +494,9 @@
if(member.getJvm_route() != null) {
createProperty(member, balancerIndex, workerIndex, "jvm_route");
}
+ if(member.getRoute() != null) {
+ createProperty(member, balancerIndex, workerIndex, "route");
+ }
if(member.getStatus() != null) {
createProperty(member, balancerIndex, workerIndex, "status");
}
@@ -410,13 +514,13 @@
createProperty(member, balancerIndex, workerIndex, "elected");
createProperty(member, balancerIndex, workerIndex, "readed");
createProperty(member, balancerIndex, workerIndex, "busy");
- if(member.getMaxbusy() >= 0) {
- createProperty(member, balancerIndex, workerIndex, "maxbusy");
+ if(member.getMax_busy() >= 0) {
+ createProperty(member, balancerIndex, workerIndex, "max_busy");
}
createProperty(member, balancerIndex, workerIndex, "transferred");
createProperty(member, balancerIndex, workerIndex, "errors");
- if(member.getClienterrors() >= 0) {
- createProperty(member, balancerIndex, workerIndex, "clienterrors");
+ if(member.getClient_errors() >= 0) {
+ createProperty(member, balancerIndex, workerIndex, "client_errors");
}
if(member.getDistance() >= 0) {
createProperty(member, balancerIndex, workerIndex, "distance");
@@ -424,13 +528,13 @@
if (member.getDomain() != null) {
createProperty(member, balancerIndex, workerIndex, "domain");
} else {
- getProject().setNewProperty(resultproperty + ".balancer." + balancerIndex + ".member." + workerIndex +
+ getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex +
".domain", "");
}
if (member.getRedirect() != null) {
createProperty(member, balancerIndex, workerIndex, "redirect");
} else {
- getProject().setNewProperty(resultproperty + ".balancer." + balancerIndex + ".member." + workerIndex +
+ getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex +
".redirect", "");
}
}
@@ -441,25 +545,32 @@
*/
private void setPropertyWorkerOnly(JkBalancer balancer,
JkBalancerMember member) {
+ //String prefix = resultproperty + "." + balancer.getName() + "." + member.getName();
String prefix = resultproperty + "." + member.getName();
- Project currentProject = getProject();
-
- currentProject.setNewProperty(prefix + ".lb.id",
+ Project currentProject = getProject();
+ if ( balancer.getId() >= 0) {
+ currentProject.setNewProperty(prefix + ".lb.id",
Integer.toString(balancer.getId()));
- currentProject.setNewProperty(prefix + ".lb.name", balancer.getName());
- currentProject.setNewProperty(prefix + ".id",
+ }
+ //currentProject.setNewProperty(prefix + ".lb.name", balancer.getName());
+ if( member.getId() >= 0) {
+ currentProject.setNewProperty(prefix + ".id",
Integer.toString(member.getId()));
+ }
currentProject.setNewProperty(prefix + ".type", member.getType());
- if(member.getJvm_route() != null) {
+ if (member.getJvm_route() != null) {
currentProject.setNewProperty(prefix + ".jvm_route", member.getJvm_route());
}
- if(member.getStatus() != null) {
+ if (member.getRoute() != null) {
+ currentProject.setNewProperty(prefix + ".route", member.getRoute());
+ }
+ if (member.getStatus() != null) {
currentProject.setNewProperty(prefix + ".status", member.getStatus());
}
- if(member.getActivation() != null) {
+ if (member.getActivation() != null) {
currentProject.setNewProperty(prefix + ".activation", member.getActivation());
}
- if(member.getState() != null) {
+ if (member.getState() != null) {
currentProject.setNewProperty(prefix + ".state", member.getState());
}
currentProject.setNewProperty(prefix + ".host", member.getHost());
@@ -482,29 +593,35 @@
Long.toString(member.getTransferred()));
currentProject.setNewProperty(prefix + ".busy",
Integer.toString(member.getBusy()));
- if(member.getMaxbusy() >= 0) {
- currentProject.setNewProperty(prefix + ".maxbusy",
- Long.toString(member.getMaxbusy()));
+ if(member.getMax_busy() >= 0) {
+ currentProject.setNewProperty(prefix + ".max_busy",
+ Long.toString(member.getMax_busy()));
}
currentProject.setNewProperty(prefix + ".errors",
Long.toString(member.getErrors()));
- if(member.getClienterrors() >= 0) {
- currentProject.setNewProperty(prefix + ".clienterrors",
- Long.toString(member.getClienterrors()));
+ if(member.getClient_errors() >= 0) {
+ currentProject.setNewProperty(prefix + ".client_errors",
+ Long.toString(member.getClient_errors()));
}
if(member.getDistance() >= 0) {
currentProject.setNewProperty(prefix + ".distance",
Integer.toString(member.getDistance()));
}
- if (member.getDomain() != null)
+ if (member.getDomain() != null) {
currentProject.setNewProperty(prefix + ".domain", member.getDomain());
- else
+ } else {
currentProject.setNewProperty(prefix + ".domain", "");
- if (member.getRedirect() != null)
+ }
+ if (member.getRedirect() != null) {
currentProject.setNewProperty(prefix + ".redirect",
member.getRedirect());
- else
+ } else {
currentProject.setNewProperty(prefix + ".redirect", "");
+ }
+ if(member.getTime_to_recover() >= 0) {
+ currentProject.setNewProperty(prefix + ".time_to_recover",
+ Integer.toString(member.getTime_to_recover()));
+ }
}
@@ -541,36 +658,43 @@
String arraymark2, String attribute) {
if (resultproperty != null) {
Object value = IntrospectionUtils.getProperty(result, attribute);
- if (value != null) {
+ if (value != null ) {
StringBuffer propertyname = new StringBuffer(resultproperty);
- if (result instanceof JkServer) {
- propertyname.append(".server");
- } else if (result instanceof JkBalancer) {
- propertyname.append(".balancer");
+ if (result instanceof JkBalancer) {
if (arraymark != null) {
propertyname.append(".");
propertyname.append(arraymark);
}
+ } else if (result instanceof JkServer) {
+ if (arraymark != null) {
+ propertyname.append(".");
+ propertyname.append(arraymark);
+ }
+ } else if (result instanceof JkSoftware) {
+ if (arraymark != null) {
+ propertyname.append(".");
+ propertyname.append(arraymark);
+ }
+ } else if (result instanceof JkResult) {
+ if (arraymark != null) {
+ propertyname.append(".");
+ propertyname.append(arraymark);
+ }
} else if (result instanceof JkBalancerMember) {
- propertyname.append(".balancer");
if (arraymark != null) {
propertyname.append(".");
propertyname.append(arraymark);
}
- propertyname.append(".member");
if (arraymark2 != null) {
propertyname.append(".");
propertyname.append(arraymark2);
}
-
} else if (result instanceof JkBalancerMapping) {
- propertyname.append(".balancer");
if (arraymark != null) {
propertyname.append(".");
propertyname.append(arraymark);
}
- propertyname.append(".map");
if (arraymark2 != null) {
propertyname.append(".");
propertyname.append(arraymark2);
Added: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java?view=auto&rev=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java (added)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java Sun Dec 10 11:45:39 2006
@@ -0,0 +1,287 @@
+/*
+ * 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.jk.status;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Ant task that implements the <code>/status</code> update loadbalancer command, supported by the
+ * mod_jk status (1.2.20) application.
+ *
+ *
+ * @author Peter Rossbach
+ * @version $Revision:$
+ * @since mod_jk 1.2.20
+ */
+public class JkStatusUpdateLoadbalancerTask extends AbstractJkStatusTask {
+
+ /**
+ * The descriptive information about this implementation.
+ */
+ private static final String info = "org.apache.jk.status.JkStatusUpdateLoadbalancerTask/1.0";
+
+ protected String loadbalancer ;
+
+ protected int retries = -1;
+ protected int recoverWaitTime = -1;
+ protected int methodCode = -1;
+ protected String method;
+
+ protected Boolean stickySession ;
+
+ protected Boolean forceStickySession ;
+
+ protected int lockCode = -1;
+ protected String lock;
+
+ /**
+ * Return descriptive information about this implementation and the
+ * corresponding version number, in the format
+ * <code><description>/<version></code>.
+ */
+ public String getInfo() {
+
+ return (info);
+
+ }
+
+ /**
+ *
+ */
+ public JkStatusUpdateLoadbalancerTask() {
+ super();
+ setUrl("http://localhost/jkstatus");
+ }
+
+ /**
+ * @return the forceStickySession
+ */
+ public Boolean getForceStickySession() {
+ return forceStickySession;
+ }
+
+ /**
+ * @param forceStickySession the forceStickySession to set
+ */
+ public void setForceStickySession(Boolean forceStickySession) {
+ this.forceStickySession = forceStickySession;
+ }
+
+ /**
+ * @return the loadbalancer
+ */
+ public String getLoadbalancer() {
+ return loadbalancer;
+ }
+
+ /**
+ * @param loadbalancer the loadbalancer to set
+ */
+ public void setLoadbalancer(String loadbalancer) {
+ this.loadbalancer = loadbalancer;
+ }
+
+
+ /**
+ * @return the locking
+ */
+ public String getLock() {
+ return lock;
+ }
+
+ /**
+ * @param locking the locking to set
+ */
+ public void setLock(String locking) {
+ this.lock = locking;
+ }
+
+ /**
+ * @return the lockingCode
+ */
+ public int getLockCode() {
+ return lockCode;
+ }
+
+ /**
+ * @param lockingCode the lockingCode to set
+ */
+ public void setLockCode(int lockingCode) {
+ this.lockCode = lockingCode;
+ }
+
+ /**
+ * @return the method
+ */
+ public String getMethod() {
+ return method;
+ }
+
+ /**
+ * @param method the method to set
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ /**
+ * @return the methodCode
+ */
+ public int getMethodCode() {
+ return methodCode;
+ }
+
+ /**
+ * @param methodCode the methodCode to set
+ */
+ public void setMethodCode(int methodCode) {
+ this.methodCode = methodCode;
+ }
+
+ /**
+ * @return the recoverWaitTime
+ */
+ public int getRecoverWaitTime() {
+ return recoverWaitTime;
+ }
+
+ /**
+ * @param recoverWaitTime the recoverWaitTime to set
+ */
+ public void setRecoverWaitTime(int recoverWaitTime) {
+ this.recoverWaitTime = recoverWaitTime;
+ }
+
+ /**
+ * @return the retries
+ */
+ public int getRetries() {
+ return retries;
+ }
+
+ /**
+ * @param retries the retries to set
+ */
+ public void setRetries(int retries) {
+ this.retries = retries;
+ }
+
+ /**
+ * @return the stickySession
+ */
+ public Boolean getStickySession() {
+ return stickySession;
+ }
+
+ /**
+ * @param stickySession the stickySession to set
+ */
+ public void setStickySession(Boolean stickySession) {
+ this.stickySession = stickySession;
+ }
+
+ /**
+ * Create JkStatus worker update link
+ * <ul>
+ * </b>http://localhost/jkstatus?cmd=update&mime=txt&w=loadbalancer&lm=1&ll=1&lr=2<=60&ls=true&lf=false
+ * <br/>
+ *
+ *
+ * <br/>Tcp worker parameter:
+ * <br/>
+ * <ul>
+ * <li><b>w:<b/> name loadbalancer</li>
+ * <li><b>lm:<b/> method (lb strategy)</li>
+ * <li><b>ll:<b/> lock</li>
+ * <li><b>lr:<b/> retries</li>
+ * <li><b>lt:<b/> recover wait timeout</li>
+ * <li><b>ls:<b/> sticky session</li>
+ * <li><b>lf:<b/> force sticky session</li>
+ * </ul>
+ * <ul>
+ * <li>lm=1 or Requests</li>
+ * <li>lm=2 or Traffic</li>
+ * <li>lm=3 or Busyness</li>
+ * <li>lm=4 or Sessions</li>
+ * </ul>
+ * <ul>
+ * <li>ll=1 or Optimistic</li>
+ * <li>ll=2 or Pessimistic</li>
+ * </ul>
+ *
+ * @return create jkstatus update worker link
+ */
+ protected StringBuffer createLink() {
+ // Building URL
+ StringBuffer sb = new StringBuffer();
+ try {
+ sb.append("?cmd=update&mime=txt");
+ sb.append("&w=");
+ sb.append(URLEncoder.encode(loadbalancer, getCharset()));
+ if (stickySession != null) {
+ sb.append("&ls=");
+ sb.append(stickySession);
+ }
+ if (forceStickySession != null) {
+ sb.append("&lf=");
+ sb.append(forceStickySession);
+ }
+ if (retries >= 0) {
+ sb.append("&lr=");
+ sb.append(retries);
+ }
+ if (recoverWaitTime >= 0) {
+ sb.append("<=");
+ sb.append(recoverWaitTime);
+ }
+ if (method == null && methodCode > 0 && methodCode < 5) {
+ sb.append("&lm=");
+ sb.append(methodCode);
+ }
+ if (method != null) {
+ sb.append("&lm=");
+ sb.append(method);
+ }
+ if (lock == null && lockCode > 0 && lockCode < 3) {
+ sb.append("&ll=");
+ sb.append(lockCode);
+ }
+ if (lock != null) {
+ sb.append("&ll=");
+ sb.append(lock);
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ throw new BuildException("Invalid 'charset' attribute: "
+ + getCharset());
+ }
+ return sb;
+ }
+
+ /**
+ * check correct lb and worker pararmeter
+ */
+ protected void checkParameter() {
+ if (loadbalancer == null) {
+ throw new BuildException("Must specify 'loadbalancer' attribute");
+ }
+ }
+}
\ No newline at end of file
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java Sun Dec 10 11:45:39 2006
@@ -31,6 +31,7 @@
* @author Peter Rossbach
* @version $Revision$
* @since 5.5.10
+ * @deprecated
*/
public class JkStatusUpdateTask extends AbstractCatalinaTask {
Added: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java?view=auto&rev=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java (added)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java Sun Dec 10 11:45:39 2006
@@ -0,0 +1,291 @@
+/*
+ * 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.jk.status;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Ant task that implements the <code>/status</code> update worker command, supported by the
+ * mod_jk status (1.2.20) application.
+ *
+ *
+ * @author Peter Rossbach
+ * @version $Revision:$
+ * @since mod_jk 1.2.20
+ */
+public class JkStatusUpdateWorkerTask extends AbstractJkStatusTask {
+
+ /**
+ * The descriptive information about this implementation.
+ */
+ private static final String info = "org.apache.jk.status.JkStatusUpdateWorkerTask/1.0";
+
+ protected String loadbalancer ;
+
+ protected String worker ;
+
+ protected int loadfactor =-1;
+
+ protected String route ;
+
+ protected int distance = -1;
+
+ protected String redirect;
+
+ protected String domain;
+
+ protected int activationCode = -1;
+
+ protected String activation ;
+
+ /**
+ * Return descriptive information about this implementation and the
+ * corresponding version number, in the format
+ * <code><description>/<version></code>.
+ */
+ public String getInfo() {
+
+ return (info);
+
+ }
+
+ /**
+ *
+ */
+ public JkStatusUpdateWorkerTask() {
+ super();
+ setUrl("http://localhost/jkstatus");
+ }
+
+ /**
+ * @return the activation
+ */
+ public String getActivation() {
+ return activation;
+ }
+
+ /**
+ * @param activation the activation to set
+ */
+ public void setActivation(String activation) {
+ this.activation = activation;
+ }
+
+ /**
+ * @return the activationCode
+ */
+ public int getActivationCode() {
+ return activationCode;
+ }
+
+ /**
+ * @param activationCode the activationCode to set
+ */
+ public void setActivationCode(int activationCode) {
+ this.activationCode = activationCode;
+ }
+
+ /**
+ * @return the distance
+ */
+ public int getDistance() {
+ return distance;
+ }
+
+ /**
+ * @param distance the distance to set
+ */
+ public void setDistance(int distance) {
+ this.distance = distance;
+ }
+
+ /**
+ * @return the domain
+ */
+ public String getDomain() {
+ return domain;
+ }
+
+ /**
+ * @param domain the domain to set
+ */
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ /**
+ * @return the loadbalancer
+ */
+ public String getLoadbalancer() {
+ return loadbalancer;
+ }
+
+ /**
+ * @param loadbalancer the loadbalaner to set
+ */
+ public void setLoadbalancer(String loadbalancer) {
+ this.loadbalancer = loadbalancer;
+ }
+
+ /**
+ * @return the loadfactor
+ */
+ public int getLoadfactor() {
+ return loadfactor;
+ }
+
+ /**
+ * @param loadfactor the loadfactor to set
+ */
+ public void setLoadfactor(int loadfactor) {
+ this.loadfactor = loadfactor;
+ }
+
+ /**
+ * @return the redirect
+ */
+ public String getRedirect() {
+ return redirect;
+ }
+
+ /**
+ * @param redirect the redirect to set
+ */
+ public void setRedirect(String redirect) {
+ this.redirect = redirect;
+ }
+
+ /**
+ * @return the route
+ */
+ public String getRoute() {
+ return route;
+ }
+
+ /**
+ * @param route the route to set
+ */
+ public void setRoute(String route) {
+ this.route = route;
+ }
+
+ /**
+ * @return the worker
+ */
+ public String getWorker() {
+ return worker;
+ }
+
+ /**
+ * @param worker the worker to set
+ */
+ public void setWorker(String worker) {
+ this.worker = worker;
+ }
+
+
+
+ /**
+ * Create JkStatus worker update link
+ * <ul>
+ * </b>http://localhost/jkstatus?cmd=update&mime=txt&w=loadbalancer&sw=node01&wn=node01&l=lb&wf=1&wa=1&wd=0
+ * <br/>
+ *
+ *
+ * <br/>Tcp worker parameter:
+ * <br/>
+ * <ul>
+ * <li><b>w:<b/> name loadbalancer</li>
+ * <li><b>sw:<b/> name tcp worker node</li>
+ * <li><b>wf:<b/> load factor</li>
+ * <li><b>wn:<b/> route</li>
+ * <li><b>wd:<b/> distance</li>
+ * <li><b>wa:<b/> activation state</li>
+ * <li><b>wr:<b/> redirect route</li>
+ * <li><b>wc:<b/> cluster domain</li>
+ * </ul>
+ * <ul>
+ * <li>wa=1 active</li>
+ * <li>wa=2 disabled</li>
+ * <li>wa=3 stopped</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @return create jkstatus update worker link
+ */
+ protected StringBuffer createLink() {
+ // Building URL
+ StringBuffer sb = new StringBuffer();
+ try {
+ sb.append("?cmd=update&mime=txt");
+ sb.append("&w=");
+ sb.append(URLEncoder.encode(loadbalancer, getCharset()));
+ sb.append("&sw=");
+ sb.append(URLEncoder.encode(worker, getCharset()));
+ if (loadfactor >= 0) {
+ sb.append("&wf=");
+ sb.append(loadfactor);
+ }
+ if (route != null) {
+ sb.append("&wn=");
+ sb.append(URLEncoder.encode(route, getCharset()));
+ }
+ if (activation == null && activationCode > 0 && activationCode < 4) {
+ sb.append("&wa=");
+ sb.append(activation);
+ }
+ if (activation != null) {
+ sb.append("&wa=");
+ sb.append(URLEncoder.encode(activation, getCharset()));
+ }
+ if (distance >= 0) {
+ sb.append("&wd=");
+ sb.append(distance);
+ }
+ if (redirect != null) { // other worker conrecte lb's
+ sb.append("&wr=");
+ sb.append(URLEncoder.encode(redirect, getCharset()));
+ }
+ if (domain != null) {
+ sb.append("&wc=");
+ sb.append(URLEncoder.encode(domain, getCharset()));
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ throw new BuildException("Invalid 'charset' attribute: "
+ + getCharset());
+ }
+ return sb;
+ }
+
+ /**
+ * check correct lb and worker pararmeter
+ */
+ protected void checkParameter() {
+ if (worker == null) {
+ throw new BuildException("Must specify 'worker' attribute");
+ }
+ if (loadbalancer == null) {
+ throw new BuildException("Must specify 'loadbalancer' attribute");
+ }
+ }
+}
\ No newline at end of file
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/antlib.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/antlib.xml?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/antlib.xml (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/antlib.xml Sun Dec 10 11:45:39 2006
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<antlib>
<typedef
+ name="updateworker"
+ classname="org.apache.jk.status.JkStatusUpdateWorkerTask" />
+ <typedef
+ name="updateloadbalancer"
+ classname="org.apache.jk.status.JkStatusUpdateLoadbalancerTask" />
+ <typedef
name="update"
classname="org.apache.jk.status.JkStatusUpdateTask" />
<typedef
Modified: tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks?view=diff&rev=485242&r1=485241&r2=485242
==============================================================================
--- tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks (original)
+++ tomcat/connectors/trunk/jk/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks Sun Dec 10 11:45:39 2006
@@ -1,4 +1,6 @@
# Apache mod_jk jk status tasks
+jkUpdateWorker=org.apache.jk.status.JkStatusUpdateWorkerTask
+jkUpdateLoadbalancer=org.apache.jk.status.JkStatusUpdateLoadbalancerTask
jkUpdate=org.apache.jk.status.JkStatusUpdateTask
jkReset=org.apache.jk.status.JkStatusResetTask
jkStatus=org.apache.jk.status.JkStatusTask
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org