diff options
Diffstat (limited to 'rubbos/app/tomcat-connectors-1.2.32-src/jkstatus')
31 files changed, 4827 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project name="JkStatus" default="dist" basedir="."> + + + <!-- ===================== Initialize Property Values =================== --> + + <property file="build.properties" /> + <property file="build.properties.default" /> + + <!-- Build Defaults --> + <property name="jk.build" value="build"/> + <property name="jk.dist" value="dist"/> + + <!-- Construct Catalina classpath --> + <path id="jtc.classpath"> + <pathelement location="${catalina.build}/server/lib/catalina.jar"/> + <pathelement location="${catalina.build}/server/lib/catalina-ant.jar"/> + <pathelement location="${catalina.build}/server/lib/tomcat-util.jar"/> + <pathelement location="${catalina.build}/server/lib/${commons-modeler.jar}"/> + <pathelement location="${catalina.build}/bin/${commons-logging.jar}"/> + <pathelement location="${jmx.jar}"/> + <pathelement location="${ant.home}/lib/ant.jar"/> + <pathelement location="${catalina.build}/common/lib/servlet-api.jar"/> + </path> + + <!-- Source path --> + <path id="javadoc.sourcepath"> + <pathelement location="src/share"/> + </path> + + + <!-- =================== BUILD: Set compile flags ======================= --> + <target name="flags"> + <!-- JDK flags --> + <available property="jdk.1.3.present" + classname="java.lang.reflect.Proxy" /> + <available property="jdk.1.4.present" classname="java.nio.Buffer" /> + </target> + + + <!-- =================== BUILD: Set compile flags ======================= --> + <target name="flags.display" depends="flags" unless="flags.hide"> + + <echo message="--- Build environment for Catalina ---" /> + + <echo message="If ${property_name} is displayed, then the property is not set)" /> + + <echo message="--- Build options ---" /> + <echo message="full.dist=${full.dist}" /> + <echo message="build.sysclasspath=${build.sysclasspath}" /> + <echo message="compile.debug=${compile.debug}" /> + <echo message="compile.deprecation=${compile.deprecation}" /> + <echo message="compile.optimize=${compile.optimize}" /> + + <echo message="--- Ant Flags ---" /> + <echo message="<style> task available (required)=${style.available}" /> + + <echo message="--- JDK ---" /> + <echo message="jdk.1.3.present=${jdk.1.3.present}" /> + <echo message="jdk.1.4.present=${jdk.1.4.present}" /> + + </target> + + <!-- =================== BUILD: Create Directories ====================== --> + <target name="build-prepare"> + <mkdir dir="${catalina.build}"/> + <mkdir dir="${catalina.build}/classes"/> + <mkdir dir="${jk.dist}"/> + <mkdir dir="${jk.build}"/> + <mkdir dir="${jk.build}/classes"/> + </target> + + <!-- ================ BUILD: Compile Catalina Components ================ --> + + <target name="build-jk-status" depends="build-prepare"> + <!-- Compile internal server components --> + <javac srcdir="${basedir}/src/share" destdir="${jk.build}/classes" + debug="${compile.debug}" deprecation="${compile.deprecation}" + optimize="${compile.optimize}" + excludes="**/.svn/**" + encoding="ISO-8859-1"> + <classpath refid="jtc.classpath" /> + </javac> + <copy file="${basedir}/src/share/org/apache/jk/status/LocalStrings.properties" + tofile="${jk.build}/classes/org/apache/jk/status/LocalStrings.properties"/> + <copy file="${basedir}/src/share/org/apache/jk/status/mbeans-descriptors.xml" + tofile="${jk.build}/classes/org/apache/jk/status/mbeans-descriptors.xml"/> + <copy file="${basedir}/src/share/org/apache/jk/status/antlib.xml" + tofile="${jk.build}/classes/org/apache/jk/status/antlib.xml"/> + <copy file="${basedir}/src/share/org/apache/jk/status/jkstatus.tasks" + tofile="${jk.build}/classes/org/apache/jk/status/jkstatus.tasks"/> + </target> + + + <!-- ================ BUILD: Create Catalina Javadocs =================== --> + <target name="javadoc"> + <delete dir="${jk.build}/javadoc"/> + <mkdir dir="${jk.build}/javadoc"/> + <javadoc packagenames="org.apache.jk.status.*" + classpathref="jtc.classpath" + sourcepathref="javadoc.sourcepath" + destdir="${jk.build}/javadoc" + author="true" + version="true" + windowtitle="Jk Status Internal API Documentation" + doctitle="Jk Status API" + bottom="Copyright &#169; 2000-2011 Apache Software Foundation. All Rights Reserved." + /> + </target> + + <!-- ======================= BUILD: Clean Directory ===================== --> + <target name="build-clean"> + <delete dir="${jk.build}"/> + </target> + + <!-- ==================== BUILD: Rebuild Everything ===================== --> + + + <!-- ================ DIST: Create Distribution ========================= --> + <target name="dist" depends="build-jk-status"> + + <jar destfile="${jk.dist}/tomcat-jkstatus-ant.jar" + basedir="${jk.build}/classes"> + <include name="org/apache/jk/status/**" /> + <exclude name="**/package.html" /> + <exclude name="**/LocalStrings_*" /> + </jar> + </target> + + <target name="copy" depends="dist" > + <copy file="${jk.dist}/tomcat-jkstatus-ant.jar" todir="${catalina.build}/server/lib" /> + <copy file="conf/jkstatus-tasks.xml" todir="${catalina.build}/bin" /> + </target> + + <!-- ======================== DIST: Clean Directory ===================== --> + + <!-- ====================== Convenient Synonyms ========================= --> + +</project> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!-- + XML file for importing apache jk status ant tasks. + <import file="${jkstatus.home}/lib/jkstatus-tasks.xml"/> +--> + +<project name="jkstatus-tasks" > + <description>Apache mod_jk ant jkstatus Tasks</description> + <!-- set jkstatus.home if it's not already set --> + <dirname property="jkstatus.home.bin.dir" file="${ant.file.jkstatus-tasks}"/> + <property name="jkstatus.home" value="${jkstatus.home.bin.dir}/.."/> + <path id="jkstatus.path"> + <fileset dir="${jkstatus.home}/bin"> + <include name="commons-logging-api-*.jar"/> + </fileset> + <pathelement location="${jkstatus.home}/lib/catalina-ant.jar"/> + <pathelement location="${jkstatus.home}/lib/tomcat-jkstatus-ant.jar"/> + <pathelement location="${jkstatus.home}/lib/tomcat-util.jar"/> + </path> + + <taskdef resource="org/apache/jk/status/jkstatus.tasks"> + <classpath refid="jkstatus.path"/> + </taskdef> + +</project>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!-- @author Peter Rossbach --> + +<project name="status" + default="status" basedir="."> + + <property name="profile" value=""/> + <property file="jkstatus${profile}.properties"/> + <property file="jkstatus${profile}.properties.default"/> + + <path id="jkstatus.path"> + <fileset dir="${catalina.home}/bin"> + <include name="commons-logging-api-*.jar"/> + </fileset> + <pathelement location="${catalina.home}/server/lib/catalina-ant.jar"/> + <pathelement location="../dist/tomcat-jkstatus-ant.jar"/> + <pathelement location="${catalina.home}/server/lib/tomcat-util.jar"/> + </path> + + <taskdef resource="org/apache/jk/status/jkstatus.tasks"> + <classpath refid="jkstatus.path"/> + </taskdef> + + <!-- + ######################################################################################################## + public + ######################################################################################################## + --> + <target name="status" + depends="-status-modjk-access" + description="got jk status" /> + + <target name="reset" + depends="-status-modjk-reset" + description="reset jk status" /> + + <!-- + ######################################################################################################## + private + ######################################################################################################## + --> + <target name="-status-modjk-access"> + <jkStatus url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + resultproperty="jkstatus.before" + echo="on" + failOnError="off"/> + <echoproperties prefix="jkstatus" /> + <jkUpdateWorker url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + loadbalancer="${jkstatus.testlb}" + worker="${jkstatus.testworker}" + domain="d20" + /> + <jkUpdateLoadbalancer url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + loadbalancer="${jkstatus.testlb}" + method="Sessions" + /> + <jkStatus url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + resultproperty="workerafter" + failOnError="false"/> + <echoproperties prefix="jkstatus.after" /> + </target> + + <target name="-status-modjk-reset"> + <jkStatus url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + resultproperty="jkstatus.before" + failOnError="false"/> + <echoproperties prefix="jkstatus.before" /> + + <jkReset url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + loadbalancer="${jkstatus.testlb}" + worker="${jkstatus.testworker}" + /> + + <jkStatus url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + resultproperty="jkstatus.after" + failOnError="false"/> + <echoproperties prefix="jkstatus.after" /> + </target> + + +</project> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<project name="modjk-status" + xmlns:jk="urn:org-apache-jk-status" + default="status" basedir="."> + + <property name="profile" value=""/> + <property file="jkstatus${profile}.properties"/> + <property file="jkstatus.properties.default"/> + + <path id="jkstatus.classpath"> + <fileset dir="${catalina.home}/bin"> + <include name="commons-logging-api-*.jar"/> + </fileset> + <pathelement location="${catalina.home}/server/lib/catalina-ant.jar"/> + <!--<pathelement location="${catalina.home}/server/lib/tomcat-jkstatus-ant.jar"/>--> + <pathelement location="../dist/tomcat-jkstatus-ant.jar"/> + <pathelement location="${catalina.home}/server/lib/tomcat-util.jar"/> + </path> + + <typedef resource="org/apache/jk/status/antlib.xml" + uri="urn:org-apache-jk-status" classpathref="jkstatus.classpath"/> + + <target name="status" > + <jk:status url="${jkstatus.url}" + username="${jkstatus.username}" + password="${jkstatus.password}" + resultproperty="worker" + echo="off" + failOnError="off"/> + <echoproperties prefix="worker" /> + </target> +</project> 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:<br/> + * <code> + * + * <?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> + * </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> + * <br/> + * mod_jk 1.2.24 runtime state N/A changed to OK/IDLE:<br/> + * <code> + * state="OK/IDLE" + * </code> + * @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 + * <code><description>/<version></code>. + */ + public String getInfo() { + + return (info); + + } + + /** + * The <code>Digester</code> 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 <code>/jkstatus?cmd=reset&w=loadbalancer</code> 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 + * <code><description>/<version></code>. + */ + 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 + * <ul> + * <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 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 <code>/jkstatus</code> 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 <code>resultProperty</code> prefix. + */ + protected String resultproperty; + + /** + * Echo status at ant console + */ + protected boolean echo = false; + + /** + * The login password for the <code>mod_jk status</code> page. + */ + protected String password = null; + + /** + * The URL of the <code>mod_jk status</code> page to be used. + */ + protected String url = "http://localhost:80/jkstatus"; + + /** + * The login username for the <code>mod_jk status</code> 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 + * <code><description>/<version></code>. + */ + 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 <code>/status</code> 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 + * <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; + } + + /** + * @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 + * <ul> + * </b>http://localhost/jkstatus?cmd=update&mime=txt&w=loadbalancer&vlm=1&vll=1&vlr=2&vlt=60&vls=true&vlf=false&vlx=0 + * <br/> + * + * + * <br/>Tcp worker parameter: + * <br/> + * <ul> + * <li><b>w:<b/> name loadbalancer</li> + * <li><b>vlm:<b/> method (lb strategy)</li> + * <li><b>vll:<b/> lock</li> + * <li><b>vlr:<b/> retries</li> + * <li><b>vlt:<b/> recover wait timeout</li> + * <li><b>vls:<b/> sticky session</li> + * <li><b>vlf:<b/> force sticky session</li> + * <li><b>vlx:<b/> max reply timeouts</li> + * </ul> + * <ul> + * <li>vlm=0 or Requests</li> + * <li>vlm=1 or Traffic</li> + * <li>vlm=2 or Busyness</li> + * <li>vlm=3 or Sessions</li> + * </ul> + * <ul> + * <li>vll=0 or Optimistic</li> + * <li>vll=1 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("&vls="); + sb.append(stickySession); + } + if (forceStickySession != null) { + sb.append("&vlf="); + sb.append(forceStickySession); + } + if (retries >= 0) { + sb.append("&vlr="); + sb.append(retries); + } + if (recoverWaitTime >= 0) { + sb.append("&vlt="); + sb.append(recoverWaitTime); + } + if (method == null && methodCode >= 0 && methodCode < 4) { + sb.append("&vlm="); + sb.append(methodCode); + } + if (method != null) { + sb.append("&vlm="); + sb.append(method); + } + if (lock == null && lockCode >= 0 && lockCode < 2) { + sb.append("&vll="); + sb.append(lockCode); + } + if (lock != null) { + sb.append("&vll="); + sb.append(lock); + } + if (maxReplyTimeouts >= 0) { + sb.append("&vlx="); + sb.append(maxReplyTimeouts); + } + + } 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"); + } + } +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java new file mode 100644 index 00000000..d43c6c9d --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java @@ -0,0 +1,529 @@ +/* + * 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.catalina.ant.AbstractCatalinaTask; +import org.apache.tools.ant.BuildException; + +/** + * Ant task that implements the <code>/status</code> command, supported by the + * mod_jk status (1.2.13) application. + * + * + * @author Peter Rossbach + * @version $Revision: 611693 $ + * @since 5.5.10 + * @deprecated + */ +public class JkStatusUpdateTask extends AbstractCatalinaTask { + + /** + * The descriptive information about this implementation. + */ + private static final String info = "org.apache.jk.status.JkStatusUpdateTask/1.1"; + + private String worker = "lb"; + + private String workerType = "lb"; + + private int internalid = 0; + + private Integer lbRetries; + + private Integer lbRecovertime; + + private Boolean lbStickySession = Boolean.TRUE; + + private Boolean lbForceSession = Boolean.FALSE; + + private Integer workerLoadFactor; + + private String workerJvmRoute ; + + private int workerDistance = -1; + + private String workerRedirect; + + private String workerClusterDomain; + + private Boolean workerDisabled ; + + private Boolean workerStopped ; + + private int workerActivation = -1; + + private boolean isLBMode = true; + + + + private String workerLb; + + /** + * Return descriptive information about this implementation and the + * corresponding version number, in the format + * <code><description>/<version></code>. + */ + public String getInfo() { + + return (info); + + } + + /** + * + */ + public JkStatusUpdateTask() { + super(); + setUrl("http://localhost/jkstatus"); + } + + /** + * @return Returns the workerDistance. + */ + public int getWorkerDistance() { + return workerDistance; + } + + /** + * @param workerDistance The workerDistance to set. + */ + public void setWorkerDistance(int workerDistance) { + this.workerDistance = workerDistance; + } + + /** + * @return Returns the workerJvmRoute. + */ + public String getWorkerJvmRoute() { + return workerJvmRoute; + } + + /** + * @param workerJvmRoute The workerJvmRoute to set. + */ + public void setWorkerJvmRoute(String workerJvmRoute) { + this.workerJvmRoute = workerJvmRoute; + } + + /** + * @return Returns the internalid. + */ + public int getInternalid() { + return internalid; + } + + /** + * @param internalid + * The internalid to set. + */ + public void setInternalid(int internalid) { + this.internalid = internalid; + } + + /** + * @return Returns the lbForceSession. + */ + public Boolean getLbForceSession() { + return lbForceSession; + } + + /** + * @param lbForceSession + * The lbForceSession to set. + */ + public void setLbForceSession(Boolean lbForceSession) { + this.lbForceSession = lbForceSession; + } + + /** + * @return Returns the lbRecovertime. + */ + public Integer getLbRecovertime() { + return lbRecovertime; + } + + /** + * @param lbRecovertime + * The lbRecovertime to set. + */ + public void setLbRecovertime(Integer lbRecovertime) { + this.lbRecovertime = lbRecovertime; + } + + /** + * @return Returns the lbRetries. + */ + public Integer getLbRetries() { + return lbRetries; + } + + /** + * @param lbRetries + * The lbRetries to set. + */ + public void setLbRetries(Integer lbRetries) { + this.lbRetries = lbRetries; + } + + /** + * @return Returns the lbStickySession. + */ + public Boolean getLbStickySession() { + return lbStickySession; + } + + /** + * @param lbStickySession + * The lbStickySession to set. + */ + public void setLbStickySession(Boolean lbStickySession) { + this.lbStickySession = lbStickySession; + } + + /** + * @return Returns the worker. + */ + public String getWorker() { + return worker; + } + + /** + * @param worker + * The worker to set. + */ + public void setWorker(String worker) { + this.worker = worker; + } + + /** + * @return Returns the workerType. + */ + public String getWorkerType() { + return workerType; + } + + /** + * @param workerType + * The workerType to set. + */ + public void setWorkerType(String workerType) { + this.workerType = workerType; + } + + /** + * @return Returns the workerLb. + */ + public String getWorkerLb() { + return workerLb; + } + + /** + * @param workerLb + * The workerLb to set. + */ + public void setWorkerLb(String workerLb) { + this.workerLb = workerLb; + } + + /** + * @return Returns the workerClusterDomain. + */ + public String getWorkerClusterDomain() { + return workerClusterDomain; + } + + /** + * @param workerClusterDomain + * The workerClusterDomain to set. + */ + public void setWorkerClusterDomain(String workerClusterDomain) { + this.workerClusterDomain = workerClusterDomain; + } + + /** + * @return Returns the workerDisabled. + */ + public Boolean getWorkerDisabled() { + return workerDisabled; + } + + /** + * @param workerDisabled + * The workerDisabled to set. + */ + public void setWorkerDisabled(Boolean workerDisabled) { + this.workerDisabled = workerDisabled; + } + + /** + * @return Returns the workerActivation. + */ + public int getWorkerActivation() { + return workerActivation; + } + + /** + * <ul> + * <li>0 active</li> + * <li>1 disabled</li> + * <li>2 stopped</li> + * </ul> + * @param workerActivation The workerActivation to set. + * + */ + public void setWorkerActivation(int workerActivation) { + this.workerActivation = workerActivation; + } + + /** + * @return Returns the workerStopped. + */ + public Boolean getWorkerStopped() { + return workerStopped; + } + + /** + * @param workerStopped The workerStopped to set. + */ + public void setWorkerStopped(Boolean workerStopped) { + this.workerStopped = workerStopped; + } + + /** + * @return Returns the workerLoadFactor. + */ + public Integer getWorkerLoadFactor() { + return workerLoadFactor; + } + + /** + * @param workerLoadFactor + * The workerLoadFactor to set. + */ + public void setWorkerLoadFactor(Integer workerLoadFactor) { + this.workerLoadFactor = workerLoadFactor; + } + + /** + * @return Returns the workerRedirect. + */ + public String getWorkerRedirect() { + return workerRedirect; + } + + /** + * @param workerRedirect + * The workerRedirect to set. + */ + public void setWorkerRedirect(String workerRedirect) { + this.workerRedirect = workerRedirect; + } + + /** + * 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); + + } + + /** + * Create JkStatus link + * <ul> + * <li><b>load balance example: + * </b>http://localhost/jkstatus?cmd=update&mime=txt&w=lb&vlf=false&vls=true</li> + * <li><b>worker example: + * </b>http://localhost/jkstatus?cmd=update&mime=txt&w=lb&sw=node1&vwn=node01&vwf=1&vwa=2&vwx=0 + * <br/> + * <ul> + * <li>vwa=0 active</li> + * <li>vwa=1 disabled</li> + * <li>vwa=2 stopped</li> + * </ul> + * </li> + * </ul> + * + * <br/>Loadbalacing parameter: + * <br/> + * <ul> + * <li><b>w:<b/> name lb worker</li> + * <li><b>vlr:<b/> Number of Retries</li> + * <li><b>vlt:<b/> recover wait time</li> + * <li><b>vlf:<b/> Force Sticky Session</li> + * <li><b>vls:<b/> Sticky session</li> + * </ul> + * + * <br/>Tcp worker parameter: + * <br/> + * <ul> + * <li><b>w:<b/> name worker</li> + * <li><b>sw:<b/> name lb sub worker</li> + * <li><b>vwf:<b/> load factor</li> + * <li><b>vwn:<b/> jvm route</li> + * <li><b>vwx:<b/> distance</li> + * <li><b>vwa:<b/> activation state</li> + * <li><b>vwr:<b/> redirect route</li> + * <li><b>vwd:<b/> cluster domain</li> + * <li><b>ws:<b/> stopped deprecated 1.2.16</li> + * <li><b>wd:<b/> disabled deprecated 1.2.16</li> + * </ul> + * + * @return create jkstatus link + */ + private StringBuffer createLink() { + // Building URL + StringBuffer sb = new StringBuffer(); + try { + sb.append("?cmd=update&mime=txt"); + sb.append("&w="); + + if (isLBMode) { + sb.append(URLEncoder.encode(worker, getCharset())); + //http://localhost/jkstatus?cmd=update&mime=txt&w=lb&vlf=false&vls=true + if ((lbRetries != null)) { // > 0 + sb.append("&vlr="); + sb.append(lbRetries); + } + if ((lbRecovertime != null)) { // > 59 + sb.append("&vlt="); + sb.append(lbRecovertime); + } + if ((lbStickySession != null)) { + sb.append("&vls="); + sb.append(lbStickySession); + } + if ((lbForceSession != null)) { + sb.append("&vlf="); + sb.append(lbForceSession); + } + } else { + //http://localhost/status?cmd=update&mime=txt&sw=node1&w=lb&vwf=1&wd=false&ws=false + if (workerLb != null) { // must be configured + sb.append(URLEncoder.encode(workerLb, getCharset())); + } + sb.append("&sw="); + sb.append(URLEncoder.encode(worker, getCharset())); + if (workerLoadFactor != null) { // >= 1 + sb.append("&vwf="); + sb.append(workerLoadFactor); + } + if (workerJvmRoute != null) { + sb.append("&vwn="); + sb.append(URLEncoder.encode(workerJvmRoute, getCharset())); + } + if (workerDisabled != null) { + sb.append("&vwd="); + sb.append(workerDisabled); + } + if (workerStopped != null) { + sb.append("&vws="); + sb.append(workerStopped); + } + if (workerActivation >= 0 && workerActivation < 3) { + sb.append("&vwa="); + sb.append(workerActivation); + } + if (workerDistance >= 0) { + sb.append("&vwx="); + sb.append(workerDistance); + } + if (workerRedirect != null) { // other worker conrecte lb's + sb.append("&vwr="); + sb.append(URLEncoder.encode(workerRedirect, + getCharset())); + } + if (workerClusterDomain != null) { + sb.append("&vwc="); + sb.append(URLEncoder.encode(workerClusterDomain, + 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 (workerType == null) { + throw new BuildException("Must specify 'workerType' attribute"); + } + if ("lb".equals(workerType)) { + if (lbRecovertime == null && lbRetries == null) { + throw new BuildException( + "Must specify at a lb worker either 'lbRecovertime' or" + + "'lbRetries' attribute"); + } + if (lbStickySession == null || lbForceSession == null) { + throw new BuildException("Must specify at a lb worker either" + + "'lbStickySession' and 'lbForceSession' attribute"); + } + if (null != lbRecovertime && 60 < lbRecovertime.intValue()) { + throw new BuildException( + "The 'lbRecovertime' must be greater than 59"); + } + if (null != lbRetries && 1 < lbRetries.intValue()) { + throw new BuildException( + "The 'lbRetries' must be greater than 1"); + } + isLBMode = true; + } else if ("worker".equals(workerType)) { + if (workerLoadFactor == null ) { + throw new BuildException( + "Must specify at a node worker 'workerLoadFactor' attribute"); + } + if (workerClusterDomain == null) { + throw new BuildException( + "Must specify at a node worker 'workerClusterDomain' attribute"); + } + if (workerRedirect == null) { + throw new BuildException( + "Must specify at a node worker 'workerRedirect' attribute"); + } + if (workerLb == null) { + throw new BuildException("Must specify 'workerLb' attribute"); + } + if (workerLoadFactor.intValue() < 1) { + throw new BuildException( + "The 'workerLoadFactor' must be greater or equal 1"); + } + isLBMode = false; + } else { + throw new BuildException( + "Only 'lb' and 'worker' supported as workerType attribute"); + } + } +} diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java new file mode 100644 index 00000000..e150e53a --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateWorkerTask.java @@ -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: 802231 $ + * @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 diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/LocalStrings.properties b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/LocalStrings.properties new file mode 100644 index 00000000..09697dce --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/LocalStrings.properties @@ -0,0 +1,15 @@ +# 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. + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/antlib.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/antlib.xml new file mode 100644 index 00000000..f9516026 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/antlib.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<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 + name="reset" + classname="org.apache.jk.status.JkStatusResetTask" /> + <typedef + name="status" + classname="org.apache.jk.status.JkStatusTask" /> +</antlib>
\ No newline at end of file diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks new file mode 100644 index 00000000..d7dea055 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks @@ -0,0 +1,22 @@ +# 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. + +# 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 + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/mbeans-descriptors.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/mbeans-descriptors.xml new file mode 100644 index 00000000..0ce42418 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/mbeans-descriptors.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<mbeans-descriptors> + +<!-- + <mbean name="JkStatus" + description="represent the apache mod_jk status" + domain="Jk" + group="Status" + type="org.apache.jk.status.JkStatusMbean"> + + <attribute name="className" + description="Fully qualified class name of the managed object" + type="java.lang.String" + writeable="false"/> + + <attribute name="info" + description="The base directory for Context configuration files" + type="java.lang.String" + writeable="false" /> + + <operation name="check" + description="Check a web application name for updates" + impact="ACTION" + returnType="void"> + <parameter name="name" + description="Application name" + type="java.lang.String"/> + </operation> + + </mbean> +--> +</mbeans-descriptors> diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/package.html b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/package.html new file mode 100644 index 00000000..b390e7f6 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/src/share/org/apache/jk/status/package.html @@ -0,0 +1,224 @@ +<!-- + 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. +--> +<body> + +<p>This package contains a set of <code>Task</code> implementations for +<em>Ant (version 1.6.x or later)</em> that can be used to interact with the +Apaache mod_jk status page to show, update, disable and stop mod_jk worker. +For more information, see +<a href="http://tomcat.apache.org/connectors-doc/index.html"><strong>JK Documenation</strong></a>.</p> + +<p>The attributes of each task element correspond +exactly to the request parameters that are included with an HTTP request +sent directly to jk status page. They are summarized as follows: +</p> + +<b>General parameter</b><br/> +<table> + <tr> + <th align="center" width="15%">Attribute</th> + <th align="center" width="85%">Description</th> + </tr> + <tr> + <td align="center">url</td> + <td> + The URL of the jk status page you will use to + perform the requested operations. If not specified, defaults to + <code>http://localhost:80/jkstatus</code> (which corresponds + to a standard installation of Apache mod_jk). + </td> + </tr> + <tr> + <td align="center">username</td> + <td> + The username of a mod_jk status user that has been configured with the + <code>Allow user</code> Apache Location constraint. This attribute is optional. + </td> + </tr> + <tr> + <td align="center">password</td> + <td> + The password of a mod_jk status user that has been configured with the + <code>Allow user</code> Apache Location constraint. This attribute is optional. + </td> + </tr> + <tr> + <td align="center">resultProperty</td> + <td> + Bind all show results with this prefix property name. This attribute is optional. + </td> + </tr> + <tr> + <td align="center">echo</td> + <td> + show result at ant console. (default false) + </td> + </tr> + <tr> + <td align="center">errorProperty</td> + <td> + set this property, as a failure detected. This attribute is optional. + </td> + </tr> +</table> + +<b>Command show parameter</b><br/> +<table> + <tr> + <th align="center" width="15%">Attribute</th> + <th align="center" width="85%">Description</th> + </tr> + <tr> + <td align="center">worker</td> + <td> + only bind properties from this balancer tcp worker (node) + </td> + </tr> + <tr> + <td align="center">loadbalancer</td> + <td> + only bind properties from this loadbalancer worker + </td> + </tr> +</table> + +<b>Command reset parameter</b><br/> +<table> + <tr> + <th align="center" width="15%">Attribute</th> + <th align="center" width="85%">Description</th> + </tr> + <tr> + <td align="center">workerLb</td> + <td> + name of loadbalancer worker. + </td> + </tr> +</table> + +<b>Command update loadbalancer parameter</b><br/> +<table> + <tr> + <th align="center" width="15%">Attribute</th> + <th align="center" width="85%">Description</th> + </tr> + <tr> + <td align="center">workerType=loadbalancer</td> + <td> + type of update + </td> + </tr> + <tr> + <td align="center">workerLb</td> + <td> + name of loadbalancer worker. + </td> + </tr> + <tr> + <td align="center">lbForceSession</td> + <td> + Force Sticky Session. (true/false) + </td> + </tr> + <tr> + <td align="center">lbStickySession</td> + <td> + Sticky Session. (true/false) + </td> + </tr> + <tr> + <td align="center">lbRetries</td> + <td> + loadbalancer retries after worker connection failure (int) + </td> + </tr> + <tr> + <td align="center">lbRecovertime</td> + <td> + Recover timeout after a worker set to "error" state (int sec's) + </td> + </tr> +</table> + +<b>Command update worker parameter</b><br/> +<table> + <tr> + <th align="center" width="15%">Attribute</th> + <th align="center" width="85%">Description</th> + </tr> + <tr> + <td align="center">workerType=worker</td> + <td> + type of update + </td> + </tr> + <tr> + <td align="center">worker</td> + <td> + name of tcp worker. + </td> + </tr> + <tr> + <td align="center">workerActivation (>=1.2.19</td> + <td> + set worker activation (1 Active, 2 Disabled, 3 Stopped) + </td> + </tr> + <tr> + <td align="center">workerDisabled (< 1.2.19)</td> + <td> + set disable state. (true/false) + </td> + </tr> + <tr> + <td align="center">workerStoppend (< 1.2.19)</td> + <td> + set stopped state. (true/false) + </td> + </tr> + <tr> + <td align="center">workerJvmRoute</td> + <td> + set jvm route + </td> + </tr> + <tr> + <td align="center">workerLaodFactor</td> + <td> + set load factor (int) + </td> + </tr> + <tr> + <td align="center">workerDistance</td> + <td> + set worker distance (int) + </td> + <tr> + <td align="center">workerRedirect</td> + <td> + other worker name to redirect after failure + </td> + </tr> + <tr> + <td align="center">workerClusterDomain</td> + <td> + cluster domain name, group of worker at a repliation cluster. + </td> + </tr> +</table> + +</body> diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/build.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/build.xml new file mode 100644 index 00000000..8725ba19 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/build.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!-- @author Peter Rossbach --> +<project name="JkStatusTestcases" basedir="." default="test"> + <property file="../../../../build/build.properties" /> + <property file="../../../../build/build.properties.default" /> + <property name="test.report.logs" value="logs/reports" /> + <property name="test.results" value="logs/test-results" /> + + <property name="compile.optimize" value="true" /> + <property name="compile.debug" value="true" /> + <property name="compile.source" value="1.4" /> + <property name="compile.deprecation" value="true" /> + <property name="compile.nowarn" value="off" /> + <property name="compile.encoding" value="ISO-8859-1" /> + <property name="build.dir" value="build/test" /> + <property name="src.dir" value="src/share" /> + <property name="catalina.home" value="../../../../build/build" /> + + <!-- Build the classpath --> + <path id="project.classpath"> + <pathelement location="../build/classes" /> + <pathelement location="${jmx.jar}" /> + <pathelement location="${commons-logging.jar}" /> + <pathelement location="${log4j.jar}" /> + <fileset dir="${catalina.home}/common/endorsed"> + <include name="*.jar" /> + </fileset> + <fileset dir="${catalina.home}/common/lib"> + <include name="*.jar" /> + </fileset> + <fileset dir="${catalina.home}/server/lib"> + <include name="*.jar" /> + </fileset> + </path> + + <target name="build-prepare"> + <mkdir dir="${build.dir}" /> + </target> + + <target name="info" description="Shows a information about this ant script"> + <echo> + This ant script implements some testcases to verify the key functions of tomcat apache mod_jk jkstatus module. + You find this script at: ${ant.file} + </echo> + </target> + + <!-- This target compiles all sources out of the + projects source tree --> + <target name="compile" depends="build-prepare" description="This target compiles all sources out of the projects source tree"> + + <!-- Copies the static resources out of the src tree + to the build/classes dir --> + <copy todir="${build.dir}/classes"> + <fileset dir="${src.dir}"> + <include name="**" /> + <exclude name="**/*.java" /> + </fileset> + </copy> + + <!-- Compiles all sources --> + <javac destdir="${build.dir}/classes" srcdir="${src.dir}" includes="**/*.java" excludes="**/.svn/**" deprecation="${compile.deprecation}" debug="${compile.debug}" source="${compile.source}" optimize="${compile.optimize}" nowarn="${compile.nowarn}" encoding="${compile.encoding}"> + <classpath> + <path refid="project.classpath" /> + </classpath> + </javac> + </target> + + <target name="test" depends="compile" description="Run unit tests"> + <delete dir="${test.results}" /> + <mkdir dir="${test.results}" /> + <junit fork="yes" failureProperty="test.failure"> + <jvmarg value="-Dcatalina.base=${basedir}" /> + <jvmarg value="-Dcatalina.home=${catalina.home}" /> + <jvmarg value="-Dlog4j.configuration=file:conf/log4j.xml" /> + <classpath> + <pathelement location="${build.dir}/classes" /> + <path refid="project.classpath" /> + </classpath> + <formatter type="plain" usefile="false" /> + <formatter type="xml" /> + <batchtest todir="${test.results}"> + <fileset dir="${build.dir}/classes" includes="**/*Test.class" /> + </batchtest> + </junit> + <mkdir dir="${test.report.logs}" /> + <junitreport todir="${test.report.logs}"> + <fileset dir="${test.results}" /> + <report format="frames" todir="${test.report.logs}" /> + </junitreport> + <antcall target="checktest" /> + </target> + + <target name="checktest" if="test.failure"> + <fail message="some test failed" /> + </target> + + <target name="clean"> + <delete dir="${build}/dir" /> + <delete dir="build" /> + <delete dir="${test.report.logs}" /> + <delete dir="${test.results}" /> + <delete dir="logs" /> + </target> +</project> diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/jkstatus.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/jkstatus.xml new file mode 100644 index 00000000..e658b76d --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/jkstatus.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + 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. +--> +<jk:status xmlns:jk="http://jakarta.apache.org"> + <jk:server name="localhost" port="80" software="Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g mod_jk/1.2.15" version="1.2.15" /> + <jk:balancers> + <jk:balancer id="0" name="lb" type="lb" sticky="True" stickyforce="False" retries="3" recover="60" > + <jk:member id="0" name="node1" type="ajp13" host="localhost" port="9012" address="127.0.0.1:9012" status="OK" lbfactor="1" lbvalue="1" elected="0" readed="0" transferred="0" errors="0" busy="0" /> + <jk:member id="1" name="node2" type="ajp13" host="localhost" port="9022" address="127.0.0.1:9022" status="OK" lbfactor="1" lbvalue="1" elected="0" readed="0" transferred="0" errors="0" busy="0" /> + <jk:map type="Wildchar" uri="/ClusterTest/*" context="/ClusterTest/*" /> + <jk:map type="Exact" uri="/ClusterTest" context="/ClusterTest" /> + <jk:map type="Wildchar" uri="/myapps/*" context="/myapps/*" /> + <jk:map type="Exact" uri="/myapps" context="/myapps" /> + </jk:balancer> + </jk:balancers> +</jk:status> + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/log4j.xml b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/log4j.xml new file mode 100644 index 00000000..c31ba8ee --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/conf/log4j.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> +<!-- ===================================================================== --> +<!-- --> +<!-- Log4j Configuration --> +<!-- --> +<!-- ===================================================================== --> +<!-- $Id: log4j.xml 572120 2007-09-02 19:32:11Z markt $ --> +<!-- +| For more configuration infromation and examples see the Jakarta Log4j +| owebsite: http://jakarta.apache.org/log4j +--> +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> + +<!-- ============================== --> +<!-- Append messages to the console --> +<!-- ==============================--> + +<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> +<param name="Target" value="System.out"/> +<layout class="org.apache.log4j.PatternLayout"> +<!--The default pattern: Date Priority [Category] Message\n--> +<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> +</layout> +</appender> + + +<category name="org.apache.jk.status" + additivity="false"> + <priority value="info" /> + <appender-ref ref="CONSOLE" /> +</category> + +<category name="org.apache.catalina" + additivity="false"> + <priority value="info" /> + <appender-ref ref="CONSOLE" /> +</category> +<category name="org.apache.tomcat" + additivity="false"> + <priority value="error" /> + <appender-ref ref="CONSOLE" /> +</category> +<category name="org.apache.naming" + additivity="false"> + <priority value="info" /> + <appender-ref ref="CONSOLE" /> +</category> +<category name="org.apache.commons" + additivity="false"> + <priority value="info" /> + <appender-ref ref="CONSOLE" /> +</category> + +<!-- Setup the Root c --> +<root> +<appender-ref ref="CONSOLE"/> +</root> +</log4j:configuration> + diff --git a/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/src/share/org/apache/jk/status/JkStatusParserTest.java b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/src/share/org/apache/jk/status/JkStatusParserTest.java new file mode 100644 index 00000000..3f7fc081 --- /dev/null +++ b/rubbos/app/tomcat-connectors-1.2.32-src/jkstatus/test/src/share/org/apache/jk/status/JkStatusParserTest.java @@ -0,0 +1,63 @@ +/* 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.io.StringReader; + +import junit.framework.TestCase; + +import org.apache.tomcat.util.digester.Digester; +import org.xml.sax.SAXException; + +/** + * @author Peter Rossbach + * + */ +public class JkStatusParserTest extends TestCase { + + public void testDigester() throws IOException, SAXException { + Digester digester = JkStatusParser.createDigester(); + String example = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + + "<jk:status xmlns:jk=\"http://tomcat.apache.org\">" + + "<jk:server name=\"localhost\" port=\"80\" software=\"Apache/2.0.58 (Unix) mod_jk/1.2.19\" 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=\"node1\" type=\"ajp13\" host=\"localhost\" port=\"9012\" address=\"127.0.0.1:9012\" activation=\"ACT\" state=\"OK/IDLE\" distance=\"0\" lbfactor=\"1\" lbmult=\"1\" lbvalue=\"0\" elected=\"0\" errors=\"0\" transferred=\"0\" readed=\"0\" busy=\"0\" maxbusy=\"0\" jvm_route=\"node1\" />" + + "<jk:member id=\"0\" name=\"node2\" type=\"ajp13\" host=\"localhost\" port=\"9022\" address=\"127.0.0.1:9022\" activation=\"ACT\" state=\"OK/IDLE\" distance=\"0\" lbfactor=\"1\" lbmult=\"1\" lbvalue=\"0\" elected=\"0\" errors=\"0\" transferred=\"0\" readed=\"0\" busy=\"0\" maxbusy=\"0\" jvm_route=\"node2\" />" + + "<jk:map type=\"Wildchar\" uri=\"/ClusterTest/*\" context=\"/ClusterTest/*\" />" + + "<jk:map type=\"Exact\" uri=\"/ClusterTest\" context=\"/ClusterTest\" />" + + "<jk:map type=\"Wildchar\" uri=\"/myapps/*\" context=\"/myapps/*\" />" + + "<jk:map type=\"Exact\" uri=\"/myapps\" context=\"/myapps\" />" + + "</jk:balancer>" + + "</jk:balancers>" + + "</jk:status>" ; + + StringReader reader = new StringReader(example); + JkStatus status = (JkStatus) digester + .parse(reader); + assertNotNull(status); + assertNotNull(status.getServer()); + assertEquals(1,status.getBalancers().size()); + JkBalancer balancer = (JkBalancer)status.getBalancers().get(0); + assertEquals(2,balancer.getBalancerMembers().size()); + assertEquals("node1",((JkBalancerMember)balancer.getBalancerMembers().get(0)).getName()); + assertEquals("node2",((JkBalancerMember)balancer.getBalancerMembers().get(1)).getName()); + assertEquals(4,balancer.getBalancerMappings().size()); + } + +} |