From 9401f816dd0d9d550fe98a8507224bde51c4b847 Mon Sep 17 00:00:00 2001 From: hongbotian Date: Mon, 30 Nov 2015 02:41:33 -0500 Subject: upload tomcat JIRA: BOTTLENECK-7 Change-Id: I875d474869efd76ca203c30b60ebc0c3ee606d0e Signed-off-by: hongbotian --- .../jkstatus/build.properties.default | 22 + .../jkstatus/build.xml | 155 +++++ .../jkstatus/conf/jkstatus-tasks.xml | 41 ++ .../jkstatus/example/jkstatus.properties.default | 23 + .../jkstatus/example/jkstatus.xml | 111 ++++ .../jkstatus/example/show.txt | 25 + .../jkstatus/example/show.xml | 49 ++ .../org/apache/jk/status/AbstractJkStatusTask.java | 209 ++++++ .../src/share/org/apache/jk/status/JkBalancer.java | 335 ++++++++++ .../org/apache/jk/status/JkBalancerMapping.java | 98 +++ .../org/apache/jk/status/JkBalancerMember.java | 516 +++++++++++++++ .../src/share/org/apache/jk/status/JkResult.java | 54 ++ .../src/share/org/apache/jk/status/JkServer.java | 56 ++ .../src/share/org/apache/jk/status/JkSoftware.java | 54 ++ .../src/share/org/apache/jk/status/JkStatus.java | 90 +++ .../org/apache/jk/status/JkStatusAccessor.java | 133 ++++ .../share/org/apache/jk/status/JkStatusParser.java | 228 +++++++ .../org/apache/jk/status/JkStatusResetTask.java | 133 ++++ .../share/org/apache/jk/status/JkStatusTask.java | 735 +++++++++++++++++++++ .../jk/status/JkStatusUpdateLoadbalancerTask.java | 307 +++++++++ .../org/apache/jk/status/JkStatusUpdateTask.java | 529 +++++++++++++++ .../apache/jk/status/JkStatusUpdateWorkerTask.java | 291 ++++++++ .../org/apache/jk/status/LocalStrings.properties | 15 + .../src/share/org/apache/jk/status/antlib.xml | 34 + .../src/share/org/apache/jk/status/jkstatus.tasks | 22 + .../org/apache/jk/status/mbeans-descriptors.xml | 48 ++ .../src/share/org/apache/jk/status/package.html | 224 +++++++ .../jkstatus/test/build.xml | 120 ++++ .../jkstatus/test/conf/jkstatus.xml | 31 + .../jkstatus/test/conf/log4j.xml | 76 +++ .../org/apache/jk/status/JkStatusParserTest.java | 63 ++ 31 files changed, 4827 insertions(+) create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.properties.default create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/conf/jkstatus-tasks.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.properties.default create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.txt create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancer.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkResult.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkServer.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkSoftware.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatus.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/LocalStrings.properties create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/antlib.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/mbeans-descriptors.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/package.html create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/build.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/jkstatus.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/log4j.xml create mode 100644 rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/src/share/org/apache/jk/status/JkStatusParserTest.java (limited to 'rubbos/app/tomcat-connectors-1.2.32-src/jkstatus') diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.properties.default b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.properties.default new file mode 100644 index 00000000..d1d0b64e --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.properties.default @@ -0,0 +1,22 @@ +# ----------------------------------------------------------------------------- +# build.properties.default +# +# This is an example "build.properties" file, used to customize building Tomcat +# for your local environment. It defines the location of all external +# modules that Tomcat depends on. Copy this file to "build.properties" +# in the top-level source directory, and customize it as needed. +# +# $Id: build.properties.default 892628 2009-12-20 18:01:53Z markt $ +# ----------------------------------------------------------------------------- + +# ----- Compile Control Flags ----- +compile.debug=on +compile.deprecation=off +compile.optimize=off + +# ----- Path to Tomcat installation ----- +catalina.build=/usr/local/share/tomcat-5.5 + +# ----- Some version dependent jar file names ----- +commons-modeler.jar=commons-modeler-2.0.1.jar +commons-logging.jar=commons-logging-api-1.1.1.jar diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.xml new file mode 100644 index 00000000..33926615 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/build.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/conf/jkstatus-tasks.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/conf/jkstatus-tasks.xml new file mode 100644 index 00000000..36b5839a --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/conf/jkstatus-tasks.xml @@ -0,0 +1,41 @@ + + + + + + Apache mod_jk ant jkstatus Tasks + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.properties.default b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.properties.default new file mode 100644 index 00000000..4e3f0460 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.properties.default @@ -0,0 +1,23 @@ +# 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. + +jkstatus.host=localhost +jkstatus.port=2090 +jkstatus.username=manager +jkstatus.password=tomcat +jkstatus.url=http://${jkstatus.host}:${jkstatus.port}/jkstatus +jkstatus.testlb=loadbalancer +jkstatus.testworker=node01 +catalina.home=../../../../build/build \ No newline at end of file diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.xml new file mode 100644 index 00000000..7f4c1b4d --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/jkstatus.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.txt b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.txt new file mode 100644 index 00000000..9fffb7dd --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.txt @@ -0,0 +1,25 @@ + 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. + +How to use the show example: +ant -f show.xml +Configure mod_jk (httpd.conf and workers.properties): +JkMount /jkstatus jkstatus + +worker.list=jkstatus +worker.jkstatus.type=status + +Adjust jkstatus.properties.default: +jkstatus.port (for example). diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.xml new file mode 100644 index 00000000..897745a9 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/example/show.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java new file mode 100644 index 00000000..c94258ae --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/AbstractJkStatusTask.java @@ -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: 802231 $ + * @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; + } + + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancer.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancer.java new file mode 100644 index 00000000..f9e4f7ad --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancer.java @@ -0,0 +1,335 @@ +/* + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Peter Rossbach + * @version $Revision: 500555 $ $Date: 2007-01-27 16:59:41 +0100 (Sat, 27 Jan 2007) $ + * @see org.apache.jk.status.JkStatusParser + */ +public class JkBalancer implements Serializable { + + 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 ; + int time_to_maintenance_min = -1 ; + int time_to_maintenance_max = -1 ; + + List members = new ArrayList() ; + List mappings = new ArrayList() ; + + /** + * @return Returns the id. + */ + public int getId() { + return id; + } + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + /** + * @return Returns the mappings. + */ + public List getBalancerMappings() { + return mappings; + } + /** + * @param mappings The mappings to set. + */ + public void setBalancerMappings(List mappings) { + this.mappings = mappings; + } + public void addBalancerMapping(JkBalancerMapping mapping) { + mappings.add(mapping); + } + public void removeBalancerMapping(JkBalancerMapping mapping) { + mappings.remove(mapping); + } + /** + * @return Returns the members. + */ + public List getBalancerMembers() { + return members; + } + /** + * @param members The members to set. + */ + public void setBalancerMembers(List members) { + this.members = members; + } + public void addBalancerMember(JkBalancerMember member) { + members.add(member); + } + public void removeBalancerMember(JkBalancerMember member) { + members.remove(member); + } + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + /** + * @return Returns the recover. + */ + public int getRecover_time() { + return recover; + } + /** + * @param recover The recover to set. + */ + public void setRecover_time(int recover) { + this.recover = recover; + } + /** + * @return Returns the retries. + */ + public int getRetries() { + return retries; + } + /** + * @param retries The retries to set. + */ + public void setRetries(int retries) { + this.retries = retries; + } + /** + * @return Returns the sticky. + */ + public boolean isSticky_session() { + return sticky; + } + /** + * @param sticky The sticky to set. + */ + public void setSticky_session(boolean sticky) { + this.sticky = sticky; + } + /** + * @return Returns the stickyforce. + */ + public boolean isSticky_session_force() { + return stickyforce; + } + /** + * @param stickyforce The stickyforce to set. + */ + public void setSticky_session_force(boolean stickyforce) { + this.stickyforce = stickyforce; + } + /** + * @return Returns the type. + */ + public String getType() { + return type; + } + /** + * @param type The type to set. + */ + 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; + } + + /** + * @return the time_to_maintenance_min + * @since mod_jk 1.2.21 + */ + public int getTime_to_maintenance_min() { + return time_to_maintenance_min; + } + + /** + * @param time_to_maintenance_min the time_to_maintenance_min to set + * @since mod_jk 1.2.21 + */ + public void setTime_to_maintenance_min(int time_to_maintenance_min) { + this.time_to_maintenance_min = time_to_maintenance_min; + } + + /** + * @return the time_to_maintenance_max + * @since mod_jk 1.2.21 + */ + public int getTime_to_maintenance_max() { + return time_to_maintenance_max; + } + + /** + * @param time_to_maintenance_max the time_to_maintenance_max to set + * @since mod_jk 1.2.21 + */ + public void setTime_to_maintenance_max(int time_to_maintenance_max) { + this.time_to_maintenance_max = time_to_maintenance_max; + } + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java new file mode 100644 index 00000000..5d4ef836 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMapping.java @@ -0,0 +1,98 @@ +/* + * 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: 485242 $ $Date: 2006-12-10 20:45:39 +0100 (Sun, 10 Dec 2006) $ + * @see org.apache.jk.status.JkStatusParser + */ +public class JkBalancerMapping implements Serializable { + 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; + } + /** + * @return Returns the type. + */ + public String getType() { + return type; + } + /** + * @param type The type to set. + */ + public void setType(String type) { + this.type = type; + } + /** + * @return Returns the uri. + */ + public String getUri() { + return uri; + } + /** + * @param uri The uri to set. + */ + 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; + } + + } diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java new file mode 100644 index 00000000..6e884477 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkBalancerMember.java @@ -0,0 +1,516 @@ +/* + * 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: 500550 $ $Date: 2007-01-27 16:41:36 +0100 (Sat, 27 Jan 2007) $ + * @see org.apache.jk.status.JkStatusParser + */ +/** + * @author peter + * + */ +public class JkBalancerMember implements Serializable { + + int id = -1; + + String name; + + /* possible with >= 1.2.16 */ + String jvm_route; + + /* possible with >= 1.2.20 */ + String route; + + String type; + + String host; + + int port; + + String address; + + /* deprecated with mod_jk 1.2.16*/ + String status; + + /* possible with > 1.2.16 */ + String activation; + + /* possible with > 1.2.16 */ + String state; + + int lbfactor; + + long lbvalue; + + /* possible with > 1.2.16 */ + long lbmult = -1 ; + + int elected; + + long readed; + + long transferred; + + long errors; + + long clienterrors = -1; + + int busy; + + /* possible with > 1.2.16 */ + int maxbusy = -1; + + String redirect; + + String domain; + + /* possible with > 1.2.16 */ + int distance = -1; + + /* possible with > 1.2.20 */ + int time_to_recover = -1 ; + + /* possible with > 1.2.21 */ + int time_to_recover_max = -1 ; + + /* possible with > 1.2.21 */ + int time_to_recover_min = -1 ; + + /** + * @return Returns the jvm_route. + * @since mod_jk 1.2.16 + * @deprecated + */ + public String getJvm_route() { + return jvm_route; + } + + /** + * @param jvm_route The jvm_route to set. + * @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() { + return address; + } + + /** + * @param address + * The address to set. + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * @return Returns the busy. + */ + public int getBusy() { + return busy; + } + + /** + * @param busy + * The busy to set. + */ + public void setBusy(int busy) { + this.busy = busy; + } + + + /** + * @return Returns the maxbusy. + * @since mod_jk 1.2.18 + */ + public int getMax_busy() { + return maxbusy; + } + + /** + * @param maxbusy The maxbusy to set. + * @since mod_jk 1.2.18 + */ + public void setMax_busy(int maxbusy) { + this.maxbusy = maxbusy; + } + + /** + * @return Returns the elected. + */ + public int getElected() { + return elected; + } + + /** + * @param elected + * The elected to set. + */ + public void setElected(int elected) { + this.elected = elected; + } + + /** + * @return Returns the clienterrors. + * @since mod_jk 1.2.19 + */ + public long getClient_errors() { + return clienterrors; + } + + /** + * @param clienterrors The clienterrors to set. + * @since mod_jk 1.2.19 + */ + public void setClient_errors(long clienterrors) { + this.clienterrors = clienterrors; + } + + /** + * @return Returns the errors. + */ + public long getErrors() { + return errors; + } + + /** + * @param errors + * The errors to set. + */ + public void setErrors(long errors) { + this.errors = errors; + } + + /** + * @return Returns the host. + */ + public String getHost() { + return host; + } + + /** + * @param host + * The host to set. + */ + public void setHost(String host) { + this.host = host; + } + + /** + * @return Returns the id. + */ + public int getId() { + return id; + } + + /** + * @param id + * The id to set. + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return Returns the lbfactor. + */ + public int getLbfactor() { + return lbfactor; + } + + /** + * @param lbfactor + * The lbfactor to set. + */ + public void setLbfactor(int lbfactor) { + this.lbfactor = lbfactor; + } + + /** + * @return Returns the lbvalue. + */ + public long getLbvalue() { + return lbvalue; + } + + /** + * @param lbvalue + * The lbvalue to set. + */ + public void setLbvalue(long lbvalue) { + this.lbvalue = lbvalue; + } + + /** + * @return Returns the lbmult. + * @since mod_jk 1.2.19 + */ + public long getLbmult() { + return lbmult; + } + + /** + * @param lbmult The lbmult to set. + * @since mod_jk 1.2.19 + */ + public void setLbmult(long lbmult) { + this.lbmult = lbmult; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @param name + * The name to set. + */ + public void setName(String name) { + this.name = name; + } + + + /** + * @return Returns the port. + */ + public int getPort() { + return port; + } + + /** + * @param port + * The port to set. + */ + public void setPort(int port) { + this.port = port; + } + + /** + * @return Returns the readed. + */ + public long getReaded() { + return readed; + } + + /** + * @param readed + * The readed to set. + */ + public void setReaded(long readed) { + this.readed = readed; + } + + /** + * @return Returns the status. + * @deprecated since 1.2.16 + */ + public String getStatus() { + return status; + } + + /** + * @param status + * The status to set. + * @deprecated since 1.2.16 + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return Returns the activation. + * @since mod_jk 1.2.19 + */ + public String getActivation() { + return activation; + } + + /** + * @param activation The activation to set. + * @since mod_jk 1.2.19 + */ + public void setActivation(String activation) { + this.activation = activation; + } + + /** + * @return Returns the state. + * @since mod_jk 1.2.19 + */ + public String getState() { + return state; + } + + /** + * @param state The state to set. + * @since mod_jk 1.2.19 + */ + public void setState(String state) { + this.state = state; + } + + /** + * @return Returns the transferred. + */ + public long getTransferred() { + return transferred; + } + + /** + * @param transferred + * The transferred to set. + */ + public void setTransferred(long transferred) { + this.transferred = transferred; + } + + /** + * @return Returns the type. + */ + public String getType() { + return type; + } + + /** + * @param type + * The type to set. + */ + public void setType(String type) { + this.type = type; + } + + + /** + * @return Returns the domain. + */ + public String getDomain() { + return domain; + } + /** + * @param domain The domain to set. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return Returns the redirect. + */ + public String getRedirect() { + return redirect; + } + /** + * @param redirect The redirect to set. + */ + public void setRedirect(String redirect) { + this.redirect = redirect; + } + + /** + * @return Returns the distance. + * @since mod_jk 1.2.18 + */ + public int getDistance() { + return distance; + } + + /** + * @param distance The distance to set. + * @since mod_jk 1.2.18 + */ + 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; + } + + /** + * @return the time_to_recover_min + * @since mod_jk 1.2.21 + */ + public int getTime_to_recover_min() { + return time_to_recover_min; + } + + /** + * @param time_to_recover_min the time_to_recover_min to set + * @since mod_jk 1.2.21 + */ + public void setTime_to_recover_min(int time_to_recover_min) { + this.time_to_recover_min = time_to_recover_min; + } + + /** + * @return the time_to_recover_max + * @since mod_jk 1.2.21 + */ + public int getTime_to_recover_max() { + return time_to_recover_max; + } + + /** + * @param time_to_recover_max the time_to_recover_max to set + * @since mod_jk 1.2.21 + */ + public void setTime_to_recover_max(int time_to_recover_max) { + this.time_to_recover_max = time_to_recover_max; + } + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkResult.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkResult.java new file mode 100644 index 00000000..63c39d7f --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkResult.java @@ -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: 802231 $ $Date: 2009-08-07 23:43:52 +0200 (Fri, 07 Aug 2009) $ + * @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; + } + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkServer.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkServer.java new file mode 100644 index 00000000..88bc9ce6 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkServer.java @@ -0,0 +1,56 @@ +/* + * 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: 485242 $ $Date: 2006-12-10 20:45:39 +0100 (Sun, 10 Dec 2006) $ + * @see org.apache.jk.status.JkStatusParser + */ +public class JkServer implements Serializable { + String name ; + String port; + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + /** + * @return Returns the port. + */ + public String getPort() { + return port; + } + /** + * @param port The port to set. + */ + public void setPort(String port) { + this.port = port; + } + + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkSoftware.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkSoftware.java new file mode 100644 index 00000000..da220b06 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkSoftware.java @@ -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: 802231 $ $Date: 2009-08-07 23:43:52 +0200 (Fri, 07 Aug 2009) $ + * @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; + } +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatus.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatus.java new file mode 100644 index 00000000..df51ed1a --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatus.java @@ -0,0 +1,90 @@ +/* + * 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; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Peter Rossbach + * @version $Revision: 485242 $ $Date: 2006-12-10 20:45:39 +0100 (Sun, 10 Dec 2006) $ + * @see org.apache.jk.status.JkStatusParser + */ +public class JkStatus implements Serializable { + + JkServer server ; + JkSoftware software ; + JkResult result ; + List balancers = new ArrayList() ; + + /** + * @return Returns the balancers. + */ + public List getBalancers() { + return balancers; + } + /** + * @param balancers The balancers to set. + */ + public void setBalancers(List balancers) { + this.balancers = balancers; + } + + public void addBalancer(JkBalancer balancer) { + balancers.add(balancer); + } + + public void removeBalancer(JkBalancer balancer) { + balancers.remove(balancer); + } + + /** + * @return Returns the server. + */ + public JkServer getServer() { + return server; + } + 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; + } +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java new file mode 100644 index 00000000..e884f542 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java @@ -0,0 +1,133 @@ +/* + * 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.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.net.URLConnection; + +import org.apache.catalina.util.Base64; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.util.digester.Digester; + +/** + * Create connection to mod_jk jkstatus page. + * Optional you can use Http basic auth user and password. + * @author Peter Rossbach + * @version $Revision: 485242 $ $Date: 2006-12-10 20:45:39 +0100 (Sun, 10 Dec 2006) $ + * @see org.apache.jk.status.JkStatusParser + * @since 5.5.10 + */ +public class JkStatusAccessor { + + private static Log log = LogFactory.getLog(JkStatusAccessor.class); + /** + * The descriptive information about this implementation. + */ + protected static final String info = "org.apache.jk.status.JkStatusAccessor/1.0"; + + /** + * Parse Apache mod_jk Status from base url http://host:port/jkstatus) + * @param url + * @param username + * @param password + * + */ + public JkStatus status(String url, String username, String password) + throws Exception { + + if(url == null || "".equals(url)) + return null ; + HttpURLConnection hconn = null; + JkStatus status = null; + + try { + // 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()); + } + } catch (Throwable t) { + throw new Exception(t); + } finally { + if (hconn != null) { + try { + hconn.disconnect(); + } catch (Throwable u) { + ; + } + hconn = null; + } + } + return status; + } + + /** + * Create a auth http connection for this url + * + * @param url + * @param username + * @param password + * @return HttpConnection + * @throws IOException + * @throws MalformedURLException + * @throws ProtocolException + */ + protected HttpURLConnection openConnection(String url, String username, + String password) throws IOException, MalformedURLException, + ProtocolException { + URLConnection conn; + conn = (new URL(url)).openConnection(); + HttpURLConnection hconn = (HttpURLConnection) conn; + + // Set up standard connection characteristics + hconn.setAllowUserInteraction(false); + hconn.setDoInput(true); + hconn.setUseCaches(false); + hconn.setDoOutput(false); + hconn.setRequestMethod("GET"); + hconn.setRequestProperty("User-Agent", "JkStatus-Client/1.0"); + + if(username != null && password != null ) { + setAuthHeader(hconn, username, password); + } + // Establish the connection with the server + hconn.connect(); + return hconn; + } + + /** + * Set Basic Auth Header + * + * @param hconn + * @param username + * @param password + */ + protected void setAuthHeader(HttpURLConnection hconn, String username, + String password) { + // 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); + } + +} \ No newline at end of file diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java new file mode 100644 index 00000000..87595d99 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java @@ -0,0 +1,228 @@ +/* + * 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.util.digester.Digester; + +/** + * mod_jk 1.2.19 document:
+ * + * + * <?xml version="1.0" encoding="UTF-8" ?> + * <jk:status xmlns:jk="http://tomcat.apache.org"> + * <jk:server name="localhost" port="2010" software="Apache/2.0.58 (Unix) mod_jk/1.2.19-dev" version="1.2.19" /> + * <jk:balancers> + * <jk:balancer id="0" name="loadbalancer" type="lb" sticky="True" stickyforce="False" retries="2" recover="60" > + * <jk:member id="0" name="node01" type="ajp13" host="localhost" port="20012" address="127.0.0.1:20012" activation="ACT" state="N/A" distance="0" lbfactor="1" lbmult="1" lbvalue="0" elected="0" errors="0" transferred="0" readed="0" busy="0" maxbusy="0" jvm_route="node01" /> + * <jk:member id="1" name="node02" type="ajp13" host="localhost" port="20022" address="127.0.0.1:20022" activation="ACT" state="N/A" distance="0" lbfactor="1" lbmult="1" lbvalue="0" elected="0" errors="0" transferred="0" readed="0" busy="0" maxbusy="0" jvm_route="node02" /> + * <jk:map type="Wildchar" uri="/ClusterSession*" context="/ClusterSession*" /> + * <jk:map type="Wildchar" uri="/ClusterTest*" context="/ClusterTest*" /> + * <jk:map type="Wildchar" uri="/test*" context="/test*" /> + * </jk:balancer> + * </jk:balancers> + * </jk:status> + * + *
+ * mod_jk 1.2.20 document:
+ * + * <?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> + * + * + * + *
+ * mod_jk 1.2.24 runtime state N/A changed to OK/IDLE:
+ * + * state="OK/IDLE" + * + * @author Peter Rossbach + * @version $Revision: 753168 $ $Date: 2009-03-13 09:46:29 +0100 (Fri, 13 Mar 2009) $ + * @since 5.5.10 + */ +public class JkStatusParser { + private static Log log = LogFactory.getLog(JkStatusParser.class); + + /** + * The descriptive information about this implementation. + */ + private static final String info = "org.apache.jk.status.JkStatusParser/1.1"; + + /** + * Return descriptive information about this implementation and the + * corresponding version number, in the format + * <description>/<version>. + */ + public String getInfo() { + + return (info); + + } + + /** + * The Digester instance used to parse registry descriptors. + */ + public static final Digester digester = createDigester(); + + public static Digester getDigester() { + return digester; + } + + /** + * Create and configure the Digester we will be using for setup mod_jk jk status page. + */ + public static Digester createDigester() { + long t1 = System.currentTimeMillis(); + // Initialize the digester + Digester digester = new Digester(); + digester.setValidating(false); + digester.setClassLoader(JkStatus.class.getClassLoader()); + + // parse status + digester.addObjectCreate("jk:status", "org.apache.jk.status.JkStatus", + "className"); + digester.addSetProperties("jk:status"); + + digester.addObjectCreate("jk:status/jk:server", + "org.apache.jk.status.JkServer", "className"); + 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"); + digester.addSetProperties("jk:status/jk:balancers/jk:balancer"); + digester.addSetNext("jk:status/jk:balancers/jk:balancer", + "addBalancer", "org.apache.jk.status.JkBalancer"); + + digester.addObjectCreate( + "jk:status/jk:balancers/jk:balancer/jk:member", + "org.apache.jk.status.JkBalancerMember", "className"); + digester + .addSetProperties("jk:status/jk:balancers/jk:balancer/jk:member"); + digester.addSetNext("jk:status/jk:balancers/jk:balancer/jk:member", + "addBalancerMember", "org.apache.jk.status.JkBalancerMember"); + + digester.addObjectCreate("jk:status/jk:balancers/jk:balancer/jk:map", + "org.apache.jk.status.JkBalancerMapping", "className"); + digester.addSetProperties("jk:status/jk:balancers/jk:balancer/jk:map"); + digester.addSetNext("jk:status/jk:balancers/jk:balancer/jk:map", + "addBalancerMapping", "org.apache.jk.status.JkBalancerMapping"); + + long t2 = System.currentTimeMillis(); + if (log.isDebugEnabled()) + log.debug("Digester for apache mod_jk jkstatus page is created " + + (t2 - t1)); + return (digester); + + } + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java new file mode 100644 index 00000000..703f04bf --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusResetTask.java @@ -0,0 +1,133 @@ +/* + * 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 /jkstatus?cmd=reset&w=loadbalancer command, supported by the + * mod_jk status (1.2.20) application. + * + * @author Peter Rossbach + * @version $Revision: 485242 $ + * @since mod_jk 1.2.20 + */ +public class JkStatusResetTask extends AbstractJkStatusTask { + + /** + * The descriptive information about this implementation. + */ + private static final String info = "org.apache.jk.status.JkStatusResetTask/1.1"; + + private String worker; + private String loadbalancer; + + /** + * + */ + public JkStatusResetTask() { + super(); + setUrl("http://localhost/jkstatus"); + } + + /** + * Return descriptive information about this implementation and the + * corresponding version number, in the format + * <description>/<version>. + */ + public String getInfo() { + + return (info); + + } + + /** + * @return the loadbalancer + */ + public String getLoadbalancer() { + return loadbalancer; + } + + + /** + * @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 + * + * + * @return create jkstatus reset link + */ + protected StringBuffer createLink() { + // Building URL + StringBuffer sb = new StringBuffer(); + try { + sb.append("?cmd=reset"); + 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: " + + getCharset()); + } + return sb; + } + + /** + * check correct pararmeter + */ + protected void checkParameter() { + if (loadbalancer == null) { + throw new BuildException("Must specify 'loadbalanacer' attribute"); + } + } +} \ No newline at end of file diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java new file mode 100644 index 00000000..73d11eab --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java @@ -0,0 +1,735 @@ +/* + * 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.util.Iterator; +import java.util.List; + +import org.apache.catalina.ant.BaseRedirectorHelperTask; +import org.apache.tomcat.util.IntrospectionUtils; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; + +/** + * Ant task that implements the show /jkstatus command, supported + * by the mod_jk status (1.2.13) application. + * + * @author Peter Rossbach + * @version $Revision: 752644 $ + * @since 5.5.10 + */ +public class JkStatusTask extends BaseRedirectorHelperTask { + + /** + * The descriptive information about this implementation. + */ + private static final String info = "org.apache.jk.status.JkStatusTask/1.2"; + + /** + * Store status as resultProperty prefix. + */ + protected String resultproperty; + + /** + * Echo status at ant console + */ + protected boolean echo = false; + + /** + * The login password for the mod_jk status page. + */ + protected String password = null; + + /** + * The URL of the mod_jk status page to be used. + */ + protected String url = "http://localhost:80/jkstatus"; + + /** + * The login username for the mod_jk status page. + */ + protected String username = null; + + private String errorProperty; + + private String worker; + + private String loadbalancer; + + /** + * Return descriptive information about this implementation and the + * corresponding version number, in the format + * <description>/<version>. + */ + public String getInfo() { + + return (info); + + } + + public String getPassword() { + return (this.password); + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUrl() { + return (this.url); + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsername() { + return (this.username); + } + + public void setUsername(String username) { + this.username = username; + } + + /** + * @return Returns the echo. + */ + public boolean isEcho() { + return echo; + } + + /** + * @param echo + * The echo to set. + */ + public void setEcho(boolean echo) { + this.echo = echo; + } + + /** + * @return Returns the resultproperty. + */ + public String getResultproperty() { + return resultproperty; + } + + /** + * @param resultproperty + * The resultproperty to set. + */ + public void setResultproperty(String resultproperty) { + this.resultproperty = resultproperty; + } + + /** + * @return Returns the loadbalancer. + */ + public String getLoadbalancer() { + return loadbalancer; + } + /** + * @param loadbalancer The loadbalancer to set. + */ + public void setLoadbalancer(String loadbalancer) { + this.loadbalancer = loadbalancer; + } + /** + * @return Returns the worker. + */ + public String getWorker() { + return worker; + } + /** + * @param worker The worker to set. + */ + public void setWorker(String worker) { + this.worker = worker; + } + // --------------------------------------------------------- Public Methods + + /** + * Get jkstatus from server. + * + * @exception BuildException + * if a validation error occurs + */ + public void execute() throws BuildException { + + if (url == null) { + throw new BuildException("Must specify an 'url'"); + } + boolean isWorkerOnly = worker != null && !"".equals(worker); + boolean isLoadbalancerOnly = loadbalancer != null + && !"".equals(loadbalancer); + + StringBuffer error = new StringBuffer(); + 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, "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() + " - " + software.getWeb_server() + " - " + software.getJk_version()); + } + } + List balancers = status.getBalancers(); + for (Iterator iter = balancers.iterator(); iter.hasNext();) { + JkBalancer balancer = (JkBalancer) iter.next(); + String balancerIndex = null; + if (isLoadbalancerOnly) { + if (loadbalancer.equals(balancer.getName())) { + if (resultproperty != null) { + setPropertyBalancerOnly(balancer); + } + echoBalancer(balancer); + return; + } + } else { + if (!isWorkerOnly) { + if (resultproperty != null) { + if ( balancer.getId() >= 0) + balancerIndex = Integer.toString(balancer.getId()); + else + balancerIndex = balancer.getName() ; + + setPropertyBalancer(balancer,balancerIndex); + } + echoBalancer(balancer); + } + List members = balancer.getBalancerMembers(); + for (Iterator iterator = members.iterator(); iterator + .hasNext();) { + JkBalancerMember member = (JkBalancerMember) iterator + .next(); + if (isWorkerOnly) { + if (worker.equals(member.getName())) { + if (resultproperty != null) { + setPropertyWorkerOnly(balancer, member); + } + echoWorker(member); + return; + } + } else { + if (resultproperty != null) { + setPropertyWorker(null, member); + } + echoWorker(member); + if (member.getStatus() != null && !"OK".equals(member.getStatus())) { + error.append(" worker name=" + member.getName() + + " status=" + member.getStatus() + + " host=" + member.getAddress()); + } + if (member.getState() != null && + !("OK".equals(member.getState()) || + "N/A".equals(member.getState()) || + "OK/IDLE".equals(member.getState())) ){ + error.append(" worker name=" + member.getName() + + " state=" + member.getState() + + " host=" + member.getAddress()); + } + } + } + if (!isWorkerOnly) { + if (resultproperty != null && members.size() > 0) { + getProject().setNewProperty( + 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 ; + if( mapping.getId() >= 0) { + stringIndex2 = Integer.toString(mapping.getId()) ; + } else { + stringIndex2 = Integer.toString(j); + } + createProperty(mapping, mapIndex, + stringIndex2, "type"); + createProperty(mapping, mapIndex, + stringIndex2, "uri"); + createProperty(mapping, mapIndex, + stringIndex2, "context"); + createProperty(mapping, mapIndex, + stringIndex2, "source"); + } + if (isEcho()) { + 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() ; + } + handleOutput(mappingOut); + } + } + if (resultproperty != null && mappings.size() > 0) { + getProject().setNewProperty( + resultproperty + "." + + mapIndex + ".length", + Integer.toString(mappings.size())); + } + } + } + } + if (!isWorkerOnly && !isLoadbalancerOnly) { + if (resultproperty != null && balancers.size() > 0) { + getProject().setNewProperty( + resultproperty + ".length", + Integer.toString(balancers.size())); + } + } + } catch (Throwable t) { + error.append(t.getMessage()); + if (getErrorProperty() != null) { + getProject().setNewProperty(errorProperty, error.toString()); + } + if (isFailOnError()) { + throw new BuildException(t); + } else { + handleErrorOutput(t.getMessage()); + return; + } + } + if (error.length() != 0) { + if (getErrorProperty() != null) { + getProject().setNewProperty(errorProperty, error.toString()); + } + if (isFailOnError()) { + // exception should be thrown only if failOnError == true + // or error line will be logged twice + throw new BuildException(error.toString()); + } + } + + } + + /** + * @param member + */ + private void echoWorker(JkBalancerMember member) { + if (isEcho()) { + StringBuffer state = new StringBuffer("worker name=") ; + state.append( member.getName()) ; + if(member.getStatus() != null) { + state.append(" status="); + state.append(member.getStatus()); + } + if(member.getState() != null) { + state.append(" state="); + state.append(member.getState()) ; + } + state.append(" host="); + state.append(member.getAddress()); + handleOutput(state.toString()); + } + } + + /** + * @param balancer + */ + private void echoBalancer(JkBalancer balancer) { + if (isEcho()) { + handleOutput("balancer name=" + balancer.getName() + " type=" + + balancer.getType()); + } + } + + /** + * @param balancer + */ + private void setPropertyBalancerOnly(JkBalancer balancer) { + String prefix = resultproperty + "." + balancer.getName(); + if(balancer.getId() >= 0 ) { + getProject().setNewProperty(prefix + ".id", + Integer.toString(balancer.getId())); + } + getProject().setNewProperty(prefix + ".type", balancer.getType()); + 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_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 + ".time_to_maintenance_min", + Integer.toString(balancer.getTime_to_maintenance_min())); + getProject().setNewProperty(prefix + ".time_to_maintenance_max", + Integer.toString(balancer.getTime_to_maintenance_max())); + getProject().setNewProperty(prefix + ".lock", + balancer.getLock()); + + } + + /** + * @param balancer + * @param balancerIndex + */ + private void setPropertyBalancer(JkBalancer balancer,String balancerIndex) { + if(balancer.id >= 0) { + createProperty(balancer, balancerIndex, "id"); + } + + createProperty(balancer, balancerIndex, "name"); + createProperty(balancer, balancerIndex, "type"); + createProperty(balancer, balancerIndex, "sticky_session"); + createProperty(balancer, balancerIndex, "sticky_session_force"); + createProperty(balancer, balancerIndex, "retries"); + 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.getMap_count() >=0) { + createProperty(balancer, balancerIndex, "map_count"); + } + if(balancer.getTime_to_maintenance_min() >=0) { + createProperty(balancer, balancerIndex, "time_to_maintenance_min"); + } + if(balancer.getTime_to_maintenance_max() >=0) { + createProperty(balancer, balancerIndex, "time_to_maintenance_max"); + } + } + + /** + * @param balancerIndex + * @param member + */ + private void setPropertyWorker(String balancerIndex, JkBalancerMember member) { + 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"); + createProperty(member, balancerIndex, workerIndex, "address"); + 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"); + } + if(member.getActivation() != null) { + createProperty(member, balancerIndex, workerIndex, "activation"); + } + if(member.getState() != null) { + createProperty(member, balancerIndex, workerIndex, "state"); + } + createProperty(member, balancerIndex, workerIndex, "lbfactor"); + createProperty(member, balancerIndex, workerIndex, "lbvalue"); + if(member.getLbmult() >= 0) { + createProperty(member, balancerIndex, workerIndex, "lbmult"); + } + createProperty(member, balancerIndex, workerIndex, "elected"); + createProperty(member, balancerIndex, workerIndex, "readed"); + createProperty(member, balancerIndex, workerIndex, "busy"); + if(member.getMax_busy() >= 0) { + createProperty(member, balancerIndex, workerIndex, "max_busy"); + } + createProperty(member, balancerIndex, workerIndex, "transferred"); + createProperty(member, balancerIndex, workerIndex, "errors"); + if(member.getClient_errors() >= 0) { + createProperty(member, balancerIndex, workerIndex, "client_errors"); + } + if(member.getDistance() >= 0) { + createProperty(member, balancerIndex, workerIndex, "distance"); + } + if (member.getDomain() != null) { + createProperty(member, balancerIndex, workerIndex, "domain"); + } else { + getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex + + ".domain", ""); + } + if (member.getRedirect() != null) { + createProperty(member, balancerIndex, workerIndex, "redirect"); + } else { + getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex + + ".redirect", ""); + } + } + + /** + * @param balancer + * @param member + */ + private void setPropertyWorkerOnly(JkBalancer balancer, + JkBalancerMember member) { + //String prefix = resultproperty + "." + balancer.getName() + "." + member.getName(); + String prefix = resultproperty + "." + member.getName(); + Project currentProject = getProject(); + if ( balancer.getId() >= 0) { + currentProject.setNewProperty(prefix + ".lb.id", + Integer.toString(balancer.getId())); + } + //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) { + currentProject.setNewProperty(prefix + ".jvm_route", member.getJvm_route()); + } + if (member.getRoute() != null) { + currentProject.setNewProperty(prefix + ".route", member.getRoute()); + } + if (member.getStatus() != null) { + currentProject.setNewProperty(prefix + ".status", member.getStatus()); + } + if (member.getActivation() != null) { + currentProject.setNewProperty(prefix + ".activation", member.getActivation()); + } + if (member.getState() != null) { + currentProject.setNewProperty(prefix + ".state", member.getState()); + } + currentProject.setNewProperty(prefix + ".host", member.getHost()); + currentProject.setNewProperty(prefix + ".address", member.getAddress()); + currentProject.setNewProperty(prefix + ".port", + Integer.toString(member.getPort())); + currentProject.setNewProperty(prefix + ".lbfactor", + Integer.toString(member.getLbfactor())); + currentProject.setNewProperty(prefix + ".lbvalue", + Long.toString(member.getLbvalue())); + if(member.getLbmult() >= 0) { + currentProject.setNewProperty(prefix + ".lbmult", + Long.toString(member.getLbmult())); + } + currentProject.setNewProperty(prefix + ".elected", + Long.toString(member.getElected())); + currentProject.setNewProperty(prefix + ".readed", + Long.toString(member.getReaded())); + currentProject.setNewProperty(prefix + ".transferred", + Long.toString(member.getTransferred())); + currentProject.setNewProperty(prefix + ".busy", + Integer.toString(member.getBusy())); + 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.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) { + currentProject.setNewProperty(prefix + ".domain", member.getDomain()); + } else { + currentProject.setNewProperty(prefix + ".domain", ""); + } + if (member.getRedirect() != null) { + currentProject.setNewProperty(prefix + ".redirect", + member.getRedirect()); + } else { + currentProject.setNewProperty(prefix + ".redirect", ""); + } + if(member.getTime_to_recover() >= 0) { + currentProject.setNewProperty(prefix + ".time_to_recover", + Integer.toString(member.getTime_to_recover())); + } + if(member.getTime_to_recover_min() >= 0) { + currentProject.setNewProperty(prefix + ".time_to_recover_min", + Integer.toString(member.getTime_to_recover_min())); + } + if(member.getTime_to_recover_max() >= 0) { + currentProject.setNewProperty(prefix + ".time_to_recover_max", + Integer.toString(member.getTime_to_recover_max())); + currentProject.setNewProperty(prefix + ".time_to_recover", + (Integer.toString((member.getTime_to_recover_min() + + member.getTime_to_recover_max()) / 2))); + } + + } + + /* + * Set ant property for save error state + * + * @see org.apache.catalina.ant.BaseRedirectorHelperTask#setErrorProperty(java.lang.String) + */ + public void setErrorProperty(String arg0) { + errorProperty = arg0; + super.setErrorProperty(arg0); + } + + /** + * @return Returns the errorProperty. + */ + public String getErrorProperty() { + return errorProperty; + } + + protected void createProperty(Object result, String attribute) { + createProperty(result, null, null, attribute); + } + + protected void createProperty(Object result, String arraymark, + String attribute) { + createProperty(result, arraymark, null, attribute); + } + + /** + * create result as property with name from attribute resultproperty + */ + protected void createProperty(Object result, String arraymark, + String arraymark2, String attribute) { + if (resultproperty != null) { + Object value = IntrospectionUtils.getProperty(result, attribute); + if (value != null ) { + StringBuffer propertyname = new StringBuffer(resultproperty); + + 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) { + if (arraymark != null) { + propertyname.append("."); + propertyname.append(arraymark); + } + if (arraymark2 != null) { + propertyname.append("."); + propertyname.append(arraymark2); + } + } else if (result instanceof JkBalancerMapping) { + if (arraymark != null) { + propertyname.append("."); + propertyname.append(arraymark); + } + if (arraymark2 != null) { + propertyname.append("."); + propertyname.append(arraymark2); + } + } + propertyname.append("."); + propertyname.append(attribute); + getProject().setNewProperty(propertyname.toString(), + value.toString()); + } + } + } + +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java new file mode 100644 index 00000000..99e4c24d --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.java @@ -0,0 +1,307 @@ +/* + * 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 /status update loadbalancer command, supported by the + * mod_jk status (1.2.20) application. + * + * + * @author Peter Rossbach + * @version $Revision: 611693 $ + * @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; + protected int maxReplyTimeouts = -1; + + /** + * Return descriptive information about this implementation and the + * corresponding version number, in the format + * <description>/<version>. + */ + 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; + } + + /** + * @return the maxReplyTimeouts + */ + public int getMaxReplyTimeouts() { + return maxReplyTimeouts; + } + + /** + * @param maxReplyTimeouts the maxReplyTimeouts to set + */ + public void setMaxReplyTimeouts(int maxReplyTimeouts) { + this.maxReplyTimeouts = maxReplyTimeouts; + } + + /** + * Create JkStatus worker update link + *