tomcat-connectors-1.2.48-src/0000755000000000000020000000000013623533444014331 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/0000755000000000000020000000000013623533443016200 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/.gitignore0000644000000000000020000000001313623533443020162 0ustar rootbinbuild dist tomcat-connectors-1.2.48-src/jkstatus/build.xml0000644000000000000020000001405413623533443020025 0ustar rootbin tomcat-connectors-1.2.48-src/jkstatus/conf/0000755000000000000020000000000013623533443017125 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/conf/jkstatus-tasks.xml0000644000000000000020000000331613623533443022645 0ustar rootbin Apache mod_jk ant jkstatus Tasks tomcat-connectors-1.2.48-src/jkstatus/src/0000755000000000000020000000000013623533443016767 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/0000755000000000000020000000000013623533443020071 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/org/0000755000000000000020000000000013623533443020660 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/0000755000000000000020000000000013623533443022101 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/0000755000000000000020000000000013623533443022505 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/0000755000000000000020000000000013623533443024030 5ustar rootbintomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/jkstatus.tasks0000644000000000000020000000210013623533443026740 0ustar rootbin# 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 tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusParser.java0000644000000000000020000001775513623533443027637 0ustar rootbin/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jk.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tomcat.util.digester.Digester; /** * mod_jk 1.2.19 document:
* * * <?xml version="1.0" encoding="UTF-8" ?> * <jk:status xmlns:jk="http://tomcat.apache.org"> * <jk:server name="localhost" port="2010" software="Apache/2.0.58 (Unix) mod_jk/1.2.19-dev" version="1.2.19" /> * <jk:balancers> * <jk:balancer id="0" name="loadbalancer" type="lb" sticky="True" stickyforce="False" retries="2" recover="60" > * <jk:member id="0" name="node01" type="ajp13" host="localhost" port="20012" address="127.0.0.1:20012" activation="ACT" state="N/A" distance="0" lbfactor="1" lbmult="1" lbvalue="0" elected="0" errors="0" transferred="0" readed="0" busy="0" maxbusy="0" jvm_route="node01" /> * <jk:member id="1" name="node02" type="ajp13" host="localhost" port="20022" address="127.0.0.1:20022" activation="ACT" state="N/A" distance="0" lbfactor="1" lbmult="1" lbvalue="0" elected="0" errors="0" transferred="0" readed="0" busy="0" maxbusy="0" jvm_route="node02" /> * <jk:map type="Wildchar" uri="/ClusterSession*" context="/ClusterSession*" /> * <jk:map type="Wildchar" uri="/ClusterTest*" context="/ClusterTest*" /> * <jk:map type="Wildchar" uri="/test*" context="/test*" /> * </jk:balancer> * </jk:balancers> * </jk:status> * *
* mod_jk 1.2.20 document:
* * <?xml version="1.0" encoding="UTF-8" ?> * <jk:status xmlns:jk="http://tomcat.apache.org"> * <jk:server * name="127.0.0.1" * port="2080" * software="Apache/2.0.59 (Unix) mod_jk/1.2.20-dev" * version="1.2.20"/> * <jk:balancers> * <jk:balancer * name="loadbalancer" * type="lb" * sticky="True" * stickyforce="False" * retries="2" * recover="60" * method="Request" * lock="Optimistic" * good="2" * degraded="0" * bad="0" * busy="0" * max_busy="0"> * <jk:member * name="node01" * type="ajp13" * host="localhost" * port="7309" * address="127.0.0.1:7309" * activation="ACT" * lbfactor="1" * jvm_route="node01" * redirect="" * domain="" * distance="0" * state="N/A" * lbmult="1" * lbvalue="0" * elected="0" * errors="0" * clienterrors="0" * transferred="0" * readed="0" * busy="0" * maxbusy="0" * time-to-recover="0"/> * <jk:member * name="node02" * type="ajp13" * host="localhost" * port="7409" * address="127.0.0.1:7409" * activation="ACT" * lbfactor="1" * jvm_route="node02" * redirect="" * domain="" * distance="0" * state="N/A" * lbmult="1" * lbvalue="0" * elected="0" * errors="0" * clienterrors="0" * transferred="0" * readed="0" * busy="0" * maxbusy="0" * time-to-recover="0"/> * <jk:map * type="Wildchar" * uri="/ClusterTest*" * source="JkMount"/> * <jk:map * type="Wildchar" * uri="/myapps*" * source="JkMount"/> * <jk:map * type="Wildchar" * uri="/last*" * source="JkMount"/> * </jk:balancer> * </jk:balancers> * </jk:status> * * * *
* mod_jk 1.2.24 runtime state N/A changed to OK/IDLE:
* * state="OK/IDLE" * * @author Peter Rossbach * @since 5.5.10 */ public class JkStatusParser { private static Log log = LogFactory.getLog(JkStatusParser.class); /** * The descriptive information about this implementation. */ private static final String info = "org.apache.jk.status.JkStatusParser/1.1"; /** * Return descriptive information about this implementation and the * corresponding version number, in the format * <description>/<version>. */ public String getInfo() { return (info); } /** * The Digester instance used to parse registry descriptors. */ public static final Digester digester = createDigester(); public static Digester getDigester() { return digester; } /** * Create and configure the Digester we will be using for setup mod_jk jk status page. */ public static Digester createDigester() { long t1 = System.currentTimeMillis(); // Initialize the digester Digester digester = new Digester(); digester.setValidating(false); digester.setClassLoader(JkStatus.class.getClassLoader()); // parse status digester.addObjectCreate("jk:status", "org.apache.jk.status.JkStatus", "className"); digester.addSetProperties("jk:status"); digester.addObjectCreate("jk:status/jk:server", "org.apache.jk.status.JkServer", "className"); digester.addSetProperties("jk:status/jk:server"); digester.addSetNext("jk:status/jk:server", "setServer", "org.apache.jk.status.JkServer"); digester.addObjectCreate("jk:status/jk:software", "org.apache.jk.status.JkSoftware", "className"); digester.addSetProperties("jk:status/jk:software"); digester.addSetNext("jk:status/jk:software", "setSoftware", "org.apache.jk.status.JkSoftware"); digester.addObjectCreate("jk:status/jk:result", "org.apache.jk.status.JkResult", "className"); digester.addSetProperties("jk:status/jk:result"); digester.addSetNext("jk:status/jk:result", "setResult", "org.apache.jk.status.JkResult"); digester.addObjectCreate("jk:status/jk:balancers/jk:balancer", "org.apache.jk.status.JkBalancer", "className"); digester.addSetProperties("jk:status/jk:balancers/jk:balancer"); digester.addSetNext("jk:status/jk:balancers/jk:balancer", "addBalancer", "org.apache.jk.status.JkBalancer"); digester.addObjectCreate( "jk:status/jk:balancers/jk:balancer/jk:member", "org.apache.jk.status.JkBalancerMember", "className"); digester .addSetProperties("jk:status/jk:balancers/jk:balancer/jk:member"); digester.addSetNext("jk:status/jk:balancers/jk:balancer/jk:member", "addBalancerMember", "org.apache.jk.status.JkBalancerMember"); digester.addObjectCreate("jk:status/jk:balancers/jk:balancer/jk:map", "org.apache.jk.status.JkBalancerMapping", "className"); digester.addSetProperties("jk:status/jk:balancers/jk:balancer/jk:map"); digester.addSetNext("jk:status/jk:balancers/jk:balancer/jk:map", "addBalancerMapping", "org.apache.jk.status.JkBalancerMapping"); long t2 = System.currentTimeMillis(); if (log.isDebugEnabled()) log.debug("Digester for apache mod_jk jkstatus page is created " + (t2 - t1)); return (digester); } } tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusTask.java0000644000000000000020000007130113623533443027270 0ustar rootbin/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jk.status; import java.util.Iterator; import java.util.List; import org.apache.catalina.ant.BaseRedirectorHelperTask; import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; /** * Ant task that implements the show /jkstatus command, supported * by the mod_jk status (1.2.13) application. * * @author Peter Rossbach * @since 5.5.10 */ public class JkStatusTask extends BaseRedirectorHelperTask { /** * The descriptive information about this implementation. */ private static final String info = "org.apache.jk.status.JkStatusTask/1.2"; /** * Store status as resultProperty prefix. */ protected String resultproperty; /** * Echo status at ant console */ protected boolean echo = false; /** * The login password for the mod_jk status page. */ protected String password = null; /** * The URL of the mod_jk status page to be used. */ protected String url = "http://localhost:80/jkstatus"; /** * The login username for the mod_jk status page. */ protected String username = null; private String errorProperty; private String worker; private String loadbalancer; /** * Return descriptive information about this implementation and the * corresponding version number, in the format * <description>/<version>. */ public String getInfo() { return (info); } public String getPassword() { return (this.password); } public void setPassword(String password) { this.password = password; } public String getUrl() { return (this.url); } public void setUrl(String url) { this.url = url; } public String getUsername() { return (this.username); } public void setUsername(String username) { this.username = username; } /** * @return Returns the echo. */ public boolean isEcho() { return echo; } /** * @param echo * The echo to set. */ public void setEcho(boolean echo) { this.echo = echo; } /** * @return Returns the resultproperty. */ public String getResultproperty() { return resultproperty; } /** * @param resultproperty * The resultproperty to set. */ public void setResultproperty(String resultproperty) { this.resultproperty = resultproperty; } /** * @return Returns the loadbalancer. */ public String getLoadbalancer() { return loadbalancer; } /** * @param loadbalancer The loadbalancer to set. */ public void setLoadbalancer(String loadbalancer) { this.loadbalancer = loadbalancer; } /** * @return Returns the worker. */ public String getWorker() { return worker; } /** * @param worker The worker to set. */ public void setWorker(String worker) { this.worker = worker; } // --------------------------------------------------------- Public Methods /** * Get jkstatus from server. * * @exception BuildException * if a validation error occurs */ public void execute() throws BuildException { if (url == null) { throw new BuildException("Must specify an 'url'"); } boolean isWorkerOnly = worker != null && !"".equals(worker); boolean isLoadbalancerOnly = loadbalancer != null && !"".equals(loadbalancer); StringBuffer error = new StringBuffer(); try { JkStatusAccessor accessor = new JkStatusAccessor(); JkStatus status = accessor.status(url, username, password); if (status.result != null && !"OK".equals(status.result.type) ) { if (getErrorProperty() != null) { getProject().setNewProperty(errorProperty, status.result.message); } if (isFailOnError()) { throw new BuildException(status.result.message); } else { handleErrorOutput(status.result.message); return; } } if (!isWorkerOnly && !isLoadbalancerOnly) { JkServer server = status.getServer(); JkSoftware software = status.getSoftware(); JkResult result = status.getResult(); if (resultproperty != null) { createProperty(server, "server", "name"); createProperty(server, "server", "port"); createProperty(software, "web_server"); createProperty(software, "jk_version"); createProperty(result, "result", "type"); createProperty(result, "result", "message"); } if (isEcho()) { handleOutput("server name=" + server.getName() + ":" + server.getPort() + " - " + software.getWeb_server() + " - " + software.getJk_version()); } } List balancers = status.getBalancers(); for (Iterator iter = balancers.iterator(); iter.hasNext();) { JkBalancer balancer = (JkBalancer) iter.next(); String balancerIndex = null; if (isLoadbalancerOnly) { if (loadbalancer.equals(balancer.getName())) { if (resultproperty != null) { setPropertyBalancerOnly(balancer); } echoBalancer(balancer); return; } } else { if (!isWorkerOnly) { if (resultproperty != null) { if ( balancer.getId() >= 0) balancerIndex = Integer.toString(balancer.getId()); else balancerIndex = balancer.getName() ; setPropertyBalancer(balancer,balancerIndex); } echoBalancer(balancer); } List members = balancer.getBalancerMembers(); for (Iterator iterator = members.iterator(); iterator .hasNext();) { JkBalancerMember member = (JkBalancerMember) iterator .next(); if (isWorkerOnly) { if (worker.equals(member.getName())) { if (resultproperty != null) { setPropertyWorkerOnly(balancer, member); } echoWorker(member); return; } } else { if (resultproperty != null) { setPropertyWorker(null, member); } echoWorker(member); if (member.getStatus() != null && !"OK".equals(member.getStatus())) { error.append(" worker name=" + member.getName() + " status=" + member.getStatus() + " host=" + member.getAddress()); } if (member.getState() != null && !("OK".equals(member.getState()) || "N/A".equals(member.getState()) || "OK/IDLE".equals(member.getState())) ){ error.append(" worker name=" + member.getName() + " state=" + member.getState() + " host=" + member.getAddress()); } } } if (!isWorkerOnly) { if (resultproperty != null && members.size() > 0) { getProject().setNewProperty( resultproperty + "." + balancer.getName() + ".length", Integer.toString(members.size())); } List mappings = balancer.getBalancerMappings(); int j = 0; String mapIndex ; if( balancerIndex != null ) mapIndex = balancerIndex + ".map" ; else mapIndex = "map" ; for (Iterator iterator = mappings.iterator(); iterator .hasNext(); j++) { JkBalancerMapping mapping = (JkBalancerMapping) iterator .next(); if (resultproperty != null) { String stringIndex2 ; if( mapping.getId() >= 0) { stringIndex2 = Integer.toString(mapping.getId()) ; } else { stringIndex2 = Integer.toString(j); } createProperty(mapping, mapIndex, stringIndex2, "type"); createProperty(mapping, mapIndex, stringIndex2, "uri"); createProperty(mapping, mapIndex, stringIndex2, "context"); createProperty(mapping, mapIndex, stringIndex2, "source"); } if (isEcho()) { String mappingOut ; if(mapping.source != null) { mappingOut = "balancer name=" + balancer.getName() + " mappingtype=" + mapping.getType() + " uri=" + mapping.getUri() + " source=" + mapping.getSource() ; } else { mappingOut = "balancer name=" + balancer.getName() + " mappingtype=" + mapping.getType() + " uri=" + mapping.getUri() + " context=" + mapping.getContext() ; } handleOutput(mappingOut); } } if (resultproperty != null && mappings.size() > 0) { getProject().setNewProperty( resultproperty + "." + mapIndex + ".length", Integer.toString(mappings.size())); } } } } if (!isWorkerOnly && !isLoadbalancerOnly) { if (resultproperty != null && balancers.size() > 0) { getProject().setNewProperty( resultproperty + ".length", Integer.toString(balancers.size())); } } } catch (Throwable t) { error.append(t.getMessage()); if (getErrorProperty() != null) { getProject().setNewProperty(errorProperty, error.toString()); } if (isFailOnError()) { throw new BuildException(t); } else { handleErrorOutput(t.getMessage()); return; } } if (error.length() != 0) { if (getErrorProperty() != null) { getProject().setNewProperty(errorProperty, error.toString()); } if (isFailOnError()) { // exception should be thrown only if failOnError == true // or error line will be logged twice throw new BuildException(error.toString()); } } } /** * @param member */ private void echoWorker(JkBalancerMember member) { if (isEcho()) { StringBuffer state = new StringBuffer("worker name=") ; state.append( member.getName()) ; if(member.getStatus() != null) { state.append(" status="); state.append(member.getStatus()); } if(member.getState() != null) { state.append(" state="); state.append(member.getState()) ; } state.append(" host="); state.append(member.getAddress()); handleOutput(state.toString()); } } /** * @param balancer */ private void echoBalancer(JkBalancer balancer) { if (isEcho()) { handleOutput("balancer name=" + balancer.getName() + " type=" + balancer.getType()); } } /** * @param balancer */ private void setPropertyBalancerOnly(JkBalancer balancer) { String prefix = resultproperty + "." + balancer.getName(); if(balancer.getId() >= 0 ) { getProject().setNewProperty(prefix + ".id", Integer.toString(balancer.getId())); } getProject().setNewProperty(prefix + ".type", balancer.getType()); getProject().setNewProperty(prefix + ".stick_session", Boolean.toString(balancer.isSticky_session())); getProject().setNewProperty(prefix + ".sticky_session_force", Boolean.toString(balancer.isSticky_session_force())); getProject().setNewProperty(prefix + ".retries", Integer.toString(balancer.getRetries())); getProject().setNewProperty(prefix + ".recover_time", Integer.toString(balancer.getRecover_time())); getProject().setNewProperty(prefix + ".method", balancer.getMethod()); getProject().setNewProperty(prefix + ".good", Integer.toString(balancer.getGood())); getProject().setNewProperty(prefix + ".degraded", Integer.toString(balancer.getDegraded())); getProject().setNewProperty(prefix + ".bad", Integer.toString(balancer.getBad())); getProject().setNewProperty(prefix + ".busy", Integer.toString(balancer.getBusy())); getProject().setNewProperty(prefix + ".map_count", Integer.toString(balancer.getMap_count())); getProject().setNewProperty(prefix + ".member_count", Integer.toString(balancer.getMember_count())); getProject().setNewProperty(prefix + ".max_busy", Integer.toString(balancer.getMax_busy())); getProject().setNewProperty(prefix + ".time_to_maintenance_min", Integer.toString(balancer.getTime_to_maintenance_min())); getProject().setNewProperty(prefix + ".time_to_maintenance_max", Integer.toString(balancer.getTime_to_maintenance_max())); getProject().setNewProperty(prefix + ".lock", balancer.getLock()); } /** * @param balancer * @param balancerIndex */ private void setPropertyBalancer(JkBalancer balancer,String balancerIndex) { if(balancer.id >= 0) { createProperty(balancer, balancerIndex, "id"); } createProperty(balancer, balancerIndex, "name"); createProperty(balancer, balancerIndex, "type"); createProperty(balancer, balancerIndex, "sticky_session"); createProperty(balancer, balancerIndex, "sticky_session_force"); createProperty(balancer, balancerIndex, "retries"); createProperty(balancer, balancerIndex, "recover_time"); if(balancer.getMethod() != null) { createProperty(balancer, balancerIndex, "method"); } if(balancer.getLock() != null) { createProperty(balancer, balancerIndex, "lock"); } if(balancer.getGood() >= 0) { createProperty(balancer, balancerIndex, "good"); } if(balancer.getDegraded() >= 0) { createProperty(balancer, balancerIndex, "degraded"); } if(balancer.getBad() >= 0) { createProperty(balancer, balancerIndex, "bad"); } if(balancer.getBusy() >= 0) { createProperty(balancer, balancerIndex, "busy"); } if(balancer.getMax_busy() >= 0) { createProperty(balancer, balancerIndex, "max_busy"); } if(balancer.getMember_count() >=0) { createProperty(balancer, balancerIndex, "member_count"); } if(balancer.getMap_count() >=0) { createProperty(balancer, balancerIndex, "map_count"); } if(balancer.getTime_to_maintenance_min() >=0) { createProperty(balancer, balancerIndex, "time_to_maintenance_min"); } if(balancer.getTime_to_maintenance_max() >=0) { createProperty(balancer, balancerIndex, "time_to_maintenance_max"); } } /** * @param balancerIndex * @param member */ private void setPropertyWorker(String balancerIndex, JkBalancerMember member) { String workerIndex ; if(member.getId() >= 0) { workerIndex = Integer.toString(member.getId()); createProperty(member, balancerIndex, workerIndex, "id"); createProperty(member, balancerIndex, workerIndex, "name"); } else { workerIndex = member.getName(); } createProperty(member, balancerIndex, workerIndex, "type"); createProperty(member, balancerIndex, workerIndex, "host"); createProperty(member, balancerIndex, workerIndex, "port"); createProperty(member, balancerIndex, workerIndex, "address"); if(member.getJvm_route() != null) { createProperty(member, balancerIndex, workerIndex, "jvm_route"); } if(member.getRoute() != null) { createProperty(member, balancerIndex, workerIndex, "route"); } if(member.getStatus() != null) { createProperty(member, balancerIndex, workerIndex, "status"); } if(member.getActivation() != null) { createProperty(member, balancerIndex, workerIndex, "activation"); } if(member.getState() != null) { createProperty(member, balancerIndex, workerIndex, "state"); } createProperty(member, balancerIndex, workerIndex, "lbfactor"); createProperty(member, balancerIndex, workerIndex, "lbvalue"); if(member.getLbmult() >= 0) { createProperty(member, balancerIndex, workerIndex, "lbmult"); } createProperty(member, balancerIndex, workerIndex, "elected"); createProperty(member, balancerIndex, workerIndex, "readed"); createProperty(member, balancerIndex, workerIndex, "busy"); if(member.getMax_busy() >= 0) { createProperty(member, balancerIndex, workerIndex, "max_busy"); } createProperty(member, balancerIndex, workerIndex, "transferred"); createProperty(member, balancerIndex, workerIndex, "errors"); if(member.getClient_errors() >= 0) { createProperty(member, balancerIndex, workerIndex, "client_errors"); } if(member.getDistance() >= 0) { createProperty(member, balancerIndex, workerIndex, "distance"); } if (member.getDomain() != null) { createProperty(member, balancerIndex, workerIndex, "domain"); } else { getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex + ".domain", ""); } if (member.getRedirect() != null) { createProperty(member, balancerIndex, workerIndex, "redirect"); } else { getProject().setNewProperty(resultproperty + "." + balancerIndex + "." + workerIndex + ".redirect", ""); } } /** * @param balancer * @param member */ private void setPropertyWorkerOnly(JkBalancer balancer, JkBalancerMember member) { //String prefix = resultproperty + "." + balancer.getName() + "." + member.getName(); String prefix = resultproperty + "." + member.getName(); Project currentProject = getProject(); if ( balancer.getId() >= 0) { currentProject.setNewProperty(prefix + ".lb.id", Integer.toString(balancer.getId())); } //currentProject.setNewProperty(prefix + ".lb.name", balancer.getName()); if( member.getId() >= 0) { currentProject.setNewProperty(prefix + ".id", Integer.toString(member.getId())); } currentProject.setNewProperty(prefix + ".type", member.getType()); if (member.getJvm_route() != null) { currentProject.setNewProperty(prefix + ".jvm_route", member.getJvm_route()); } if (member.getRoute() != null) { currentProject.setNewProperty(prefix + ".route", member.getRoute()); } if (member.getStatus() != null) { currentProject.setNewProperty(prefix + ".status", member.getStatus()); } if (member.getActivation() != null) { currentProject.setNewProperty(prefix + ".activation", member.getActivation()); } if (member.getState() != null) { currentProject.setNewProperty(prefix + ".state", member.getState()); } currentProject.setNewProperty(prefix + ".host", member.getHost()); currentProject.setNewProperty(prefix + ".address", member.getAddress()); currentProject.setNewProperty(prefix + ".port", Integer.toString(member.getPort())); currentProject.setNewProperty(prefix + ".lbfactor", Integer.toString(member.getLbfactor())); currentProject.setNewProperty(prefix + ".lbvalue", Long.toString(member.getLbvalue())); if(member.getLbmult() >= 0) { currentProject.setNewProperty(prefix + ".lbmult", Long.toString(member.getLbmult())); } currentProject.setNewProperty(prefix + ".elected", Long.toString(member.getElected())); currentProject.setNewProperty(prefix + ".readed", Long.toString(member.getReaded())); currentProject.setNewProperty(prefix + ".transferred", Long.toString(member.getTransferred())); currentProject.setNewProperty(prefix + ".busy", Integer.toString(member.getBusy())); if(member.getMax_busy() >= 0) { currentProject.setNewProperty(prefix + ".max_busy", Long.toString(member.getMax_busy())); } currentProject.setNewProperty(prefix + ".errors", Long.toString(member.getErrors())); if(member.getClient_errors() >= 0) { currentProject.setNewProperty(prefix + ".client_errors", Long.toString(member.getClient_errors())); } if(member.getDistance() >= 0) { currentProject.setNewProperty(prefix + ".distance", Integer.toString(member.getDistance())); } if (member.getDomain() != null) { currentProject.setNewProperty(prefix + ".domain", member.getDomain()); } else { currentProject.setNewProperty(prefix + ".domain", ""); } if (member.getRedirect() != null) { currentProject.setNewProperty(prefix + ".redirect", member.getRedirect()); } else { currentProject.setNewProperty(prefix + ".redirect", ""); } if(member.getTime_to_recover() >= 0) { currentProject.setNewProperty(prefix + ".time_to_recover", Integer.toString(member.getTime_to_recover())); } if(member.getTime_to_recover_min() >= 0) { currentProject.setNewProperty(prefix + ".time_to_recover_min", Integer.toString(member.getTime_to_recover_min())); } if(member.getTime_to_recover_max() >= 0) { currentProject.setNewProperty(prefix + ".time_to_recover_max", Integer.toString(member.getTime_to_recover_max())); currentProject.setNewProperty(prefix + ".time_to_recover", (Integer.toString((member.getTime_to_recover_min() + member.getTime_to_recover_max()) / 2))); } } /* * Set ant property for save error state * * @see org.apache.catalina.ant.BaseRedirectorHelperTask#setErrorProperty(java.lang.String) */ public void setErrorProperty(String arg0) { errorProperty = arg0; super.setErrorProperty(arg0); } /** * @return Returns the errorProperty. */ public String getErrorProperty() { return errorProperty; } protected void createProperty(Object result, String attribute) { createProperty(result, null, null, attribute); } protected void createProperty(Object result, String arraymark, String attribute) { createProperty(result, arraymark, null, attribute); } /** * create result as property with name from attribute resultproperty */ protected void createProperty(Object result, String arraymark, String arraymark2, String attribute) { if (resultproperty != null) { Object value = IntrospectionUtils.getProperty(result, attribute); if (value != null ) { StringBuffer propertyname = new StringBuffer(resultproperty); if (result instanceof JkBalancer) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } } else if (result instanceof JkServer) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } } else if (result instanceof JkSoftware) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } } else if (result instanceof JkResult) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } } else if (result instanceof JkBalancerMember) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } if (arraymark2 != null) { propertyname.append("."); propertyname.append(arraymark2); } } else if (result instanceof JkBalancerMapping) { if (arraymark != null) { propertyname.append("."); propertyname.append(arraymark); } if (arraymark2 != null) { propertyname.append("."); propertyname.append(arraymark2); } } propertyname.append("."); propertyname.append(attribute); getProject().setNewProperty(propertyname.toString(), value.toString()); } } } } tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkBalancer.java0000644000000000000020000001717313623533443026700 0ustar rootbin/* * 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 * @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; } } tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/LocalStrings.properties0000644000000000000020000000141613623533443030554 0ustar rootbin# 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. tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkServer.java0000644000000000000020000000274313623533443026434 0ustar rootbin/* * 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 * @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; } } tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateTask.java0000644000000000000020000003506413623533443030441 0ustar rootbin/* * 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 /status command, supported by the * mod_jk status (1.2.13) application. * * * @author Peter Rossbach * @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 * <description>/<version>. */ 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; } /** * * @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 * * *
Loadbalacing parameter: *
* * *
Tcp worker parameter: *
*
    *
  • w: name worker
  • *
  • sw: name lb sub worker
  • *
  • vwf: load factor
  • *
  • vwn: jvm route
  • *
  • vwx: distance
  • *
  • vwa: activation state
  • *
  • vwr: redirect route
  • *
  • vwd: cluster domain
  • *
  • ws: stopped deprecated 1.2.16
  • *
  • wd: disabled deprecated 1.2.16
  • *
* * @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"); } } } tomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusAccessor.java0000644000000000000020000001044613623533443030133 0ustar rootbin/* * 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 * @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); } }././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootroottomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.javatomcat-connectors-1.2.48-src/jkstatus/src/share/org/apache/jk/status/JkStatusUpdateLoadbalancerTask.0000644000000000000020000001575313623533443032072 0ustar rootbin/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jk.status; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import org.apache.tools.ant.BuildException; /** * Ant task that implements the /status update loadbalancer command, supported by the * mod_jk status (1.2.20) application. * * * @author Peter Rossbach * @since mod_jk 1.2.20 */ public class JkStatusUpdateLoadbalancerTask extends AbstractJkStatusTask { /** * The descriptive information about this implementation. */ private static final String info = "org.apache.jk.status.JkStatusUpdateLoadbalancerTask/1.0"; protected String loadbalancer ; protected int retries = -1; protected int recoverWaitTime = -1; protected int methodCode = -1; protected String method; protected Boolean stickySession ; protected Boolean forceStickySession ; protected int lockCode = -1; protected String lock; protected int maxReplyTimeouts = -1; /** * Return descriptive information about this implementation and the * corresponding version number, in the format * <description>/<version>. */ public String getInfo() { return (info); } /** * */ public JkStatusUpdateLoadbalancerTask() { super(); setUrl("http://localhost/jkstatus"); } /** * @return the forceStickySession */ public Boolean getForceStickySession() { return forceStickySession; } /** * @param forceStickySession the forceStickySession to set */ public void setForceStickySession(Boolean forceStickySession) { this.forceStickySession = forceStickySession; } /** * @return the loadbalancer */ public String getLoadbalancer() { return loadbalancer; } /** * @param loadbalancer the loadbalancer to set */ public void setLoadbalancer(String loadbalancer) { this.loadbalancer = loadbalancer; } /** * @return the locking */ public String getLock() { return lock; } /** * @param locking the locking to set */ public void setLock(String locking) { this.lock = locking; } /** * @return the lockingCode */ public int getLockCode() { return lockCode; } /** * @param lockingCode the lockingCode to set */ public void setLockCode(int lockingCode) { this.lockCode = lockingCode; } /** * @return the method */ public String getMethod() { return method; } /** * @param method the method to set */ public void setMethod(String method) { this.method = method; } /** * @return the methodCode */ public int getMethodCode() { return methodCode; } /** * @param methodCode the methodCode to set */ public void setMethodCode(int methodCode) { this.methodCode = methodCode; } /** * @return the recoverWaitTime */ public int getRecoverWaitTime() { return recoverWaitTime; } /** * @param recoverWaitTime the recoverWaitTime to set */ public void setRecoverWaitTime(int recoverWaitTime) { this.recoverWaitTime = recoverWaitTime; } /** * @return the retries */ public int getRetries() { return retries; } /** * @param retries the retries to set */ public void setRetries(int retries) { this.retries = retries; } /** * @return the stickySession */ public Boolean getStickySession() { return stickySession; } /** * @param stickySession the stickySession to set */ public void setStickySession(Boolean stickySession) { this.stickySession = stickySession; } /** * @return the maxReplyTimeouts */ public int getMaxReplyTimeouts() { return maxReplyTimeouts; } /** * @param maxReplyTimeouts the maxReplyTimeouts to set */ public void setMaxReplyTimeouts(int maxReplyTimeouts) { this.maxReplyTimeouts = maxReplyTimeouts; } /** * Create JkStatus worker update link *