You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alexander Lazic <al...@none.at> on 2006/08/19 21:40:51 UTC

Valve && Connectors && Request-Objects

Hi,

today i have try to get some Infos from tomcat 4.1.x similar like

--- 5.5.x
=>container/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/StatusTransformer.java
.
.
.
mBeanServer.getAttribute(grpName, "requestCount"));
.
.
---

My main target is as follow:

currentUsersSessions
currentConnections <= from connector if possible ;-)
requestDuration

Btw.: Is it true that mod_proxy_ajp and mod_jk make a tcp-session per
      request?!

I have seen a in 4.1.32
connectors/coyote/src/java/org/apache/coyote/RequestInfo.java which have
the infos but when i try to use this i get this error:

Javac: ${JAVA_HOME}/bin/javac -version
javac 1.5.0_05

OS: uname -a
Linux home1 2.6.17-1-686 #1 SMP Sat Jul 29 15:32:47 UTC 2006 i686
GNU/Linux

Distri: Debbian unstable

---
${JAVA_HOME}/bin/javac -deprecation -classpath ../apache-tomcat-4.1.32-LE-jdk14/server/lib/tomcat-jk.jar:../apache-tomcat-4.1.32-LE-jdk14/common/lib/servlet.jar:../apache-tomcat-4.1.32-LE-jdk14/server/lib/catalina.jar:../apache-tomcat-4.1.32-LE-jdk14/server/lib/tomcat4-coyote.jar:../apache-tomcat-4.1.32-LE-jdk14/server/lib/tomcat-coyote.jar LogData.java && rm LogData.jar && jar cf LogData.jar LogData.class && cp LogData.jar ../apache-tomcat-4.1.32-LE-jdk14/server/lib/LogData.jar
LogData.java:367: cannot find symbol
symbol  : constructor RequestInfo(org.apache.catalina.Request)
location: class org.apache.coyote.RequestInfo
        RequestInfo rp = new RequestInfo(request).getRequestProcessor();
                         ^
LogData.java:415: cannot find symbol
symbol  : method Long(long)
location: class LogData
            log(Long(rp.getRequestProcessingTime()).toString(),date);
                ^
2 errors
---

I have try to replace the org.apache.catalina.Request to
org.apache.coyote.Request but i wasn't successfully :-(

If you interested you can get the .java file from:

http://none.at/LogData.java

Be warned it is in development status ;-)

I use this Connector-setting in server.xml:

---
 <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
               port="4091" 
               minProcessors="5" maxProcessors="75"
               enableLookups="false" 
               acceptCount="10" debug="9"/>
---

and this valve setting in <Engine ...:

---
<Valve className="LogData" prefix="LogData1-" suffix=".log"
rotatable="true" />
---

A statment like "unpossible with this connector" is also valid ;-)

Btw2.: there are some more methodes in RequestInfo-class which is also
      nice that i can use it ;-) (getRequestProcessingTime(),getProcessingTime(),...)

Please also tell me if i'am on the wrong way ;-)

Thanks for help && regards

Alex

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Valve && Connectors && Request-Objects

Posted by Alexander Lazic <al...@none.at>.
Hi,

On Mon 21.08.2006 11:36, Martin Gainty wrote:
>
>If you know the name of the attribute you could use the getAttribute
>method

[snipp]

Ok, thanks.

I think i will go another way ;-)

For this i will start a new thread on this list, i hope that this is the
right List ;-)

Regards

Alex

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Valve && Connectors && Request-Objects

Posted by Martin Gainty <mg...@hotmail.com>.
Hello Alex

If you know the name of the attribute you could use the getAttribute method

public Object getAttribute(String name) 
{ //notice this goes to the ProcessorAttributes..
        return this.processorAttributes.get(name);
}

HTH,
M-
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Alexander Lazic" <al...@none.at>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, August 21, 2006 4:17 AM
Subject: Re: Valve && Connectors && Request-Objects


> On Son 20.08.2006 18:50, Martin Gainty wrote:
>>I believe you will have to acquire the ServletInfo from the
>>(Action)servlet itself as in the example..
>>
>>ServletInfo info = cyR.getRequestProcessor().servlet.getServletInfo();
> 
> Thanks for info but i'am not sure if i understand you right?!
> 
> The getServletInfo() give me *only* a String?!
> 
> ---
> apache-tomcat-4.1.32-src $ egrep -r ServletInfo *
> ---
> 
> Regards
> 
> alex
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Valve && Connectors && Request-Objects

Posted by Alexander Lazic <al...@none.at>.
On Son 20.08.2006 18:50, Martin Gainty wrote:
>I believe you will have to acquire the ServletInfo from the
>(Action)servlet itself as in the example..
>
>ServletInfo info = cyR.getRequestProcessor().servlet.getServletInfo();

Thanks for info but i'am not sure if i understand you right?!

The getServletInfo() give me *only* a String?!

---
apache-tomcat-4.1.32-src $ egrep -r ServletInfo *
---

Regards

alex

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Valve && Connectors && Request-Objects

Posted by Martin Gainty <mg...@hotmail.com>.
I believe you will have to acquire the ServletInfo from the (Action)servlet itself as in the example..
ServletInfo info = cyR.getRequestProcessor().servlet.getServletInfo();

In your Valve class:
public void invoke(request,response,valveContext) throws IOException,ServletException 
{
//main processing here 
 // now execute all other valves
    valveContext.invokeNext(request, response);
}

Anyone else ?
M-
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Alexander Lazic" <al...@none.at>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Sunday, August 20, 2006 2:41 PM
Subject: Re: Valve && Connectors && Request-Objects


> On Sam 19.08.2006 21:40, Alexander Lazic wrote:
> 
>>I have seen a in 4.1.32
>>connectors/coyote/src/java/org/apache/coyote/RequestInfo.java which
>>have the infos but when i try to use this i get this error:
> 
> With help from Mark Thomas i have know a working CoyoteConnector, thanks
> you Mark ;-).
> 
> But kow i have another question and I'am not sure if i'am on the wrong
> way.
> 
> My setup now:
> 
> ---
> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
>           protocolHandler="org.apache.jk.server.JkCoyoteHandler"
>           port="8009" enableLookups="false" 
>           connectionTimeout="0" debug="9"
>           useURIValidationHack="false"
>           protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" />
> 
> .
> .
> <Engine ...
> <Valve className="LogData" prefix="LogData1-" suffix=".log"
> rotatable="true" />
> .
> .
> ---
> 
> and try to get out some infos from RequstInfo:
> 
> ---
>  org.apache.coyote.Request cyR = ((CoyoteRequest)request).getCoyoteRequest();
>  RequestInfo rqInf = cyR.getRequestProcessor();
> .
> .
> .
> log("==>>>rqInf.getRequestProcessingTime() :"+rqInf.getRequestProcessingTime() +":\n",date);
> log("==>>>rqInf.getProcessingTime() :"+rqInf.getProcessingTime() +":\n",date);
> log("==>>>rqInf.getRequestCount() :" + rqInf.getRequestCount() +
>        >>>":\n",date);
> context.invokeNext(request, response);
> .
> .
> .
> result.append("RequestProcessingTime() :");
>     result.append(rqInf.getRequestProcessingTime());
>     result.append(": ProcessingTime() :");
>     result.append(rqInf.getProcessingTime());
>     result.append(": RequestCount() :");
>     result.append(rqInf.getRequestCount());
>     result.append(":");
> 
>     log(" result.toString() :" + result.toString(),date);
> ---
> 
> and i get for the first request 0, could this be a bug or do i
> understand the RequestInfo class wrong?!
> 
> Btw: i it possibel to get the info how many requests at the moment
>     tomcat currently handle?!
> 
> Thanks for help && regards
> 
> Alex
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Valve && Connectors && Request-Objects

Posted by Alexander Lazic <al...@none.at>.
On Sam 19.08.2006 21:40, Alexander Lazic wrote:

>I have seen a in 4.1.32
>connectors/coyote/src/java/org/apache/coyote/RequestInfo.java which
>have the infos but when i try to use this i get this error:

With help from Mark Thomas i have know a working CoyoteConnector, thanks
you Mark ;-).

But kow i have another question and I'am not sure if i'am on the wrong
way.

My setup now:

---
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
           protocolHandler="org.apache.jk.server.JkCoyoteHandler"
           port="8009" enableLookups="false" 
           connectionTimeout="0" debug="9"
           useURIValidationHack="false"
           protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" />

.
.
<Engine ...
<Valve className="LogData" prefix="LogData1-" suffix=".log"
rotatable="true" />
.
.
---

and try to get out some infos from RequstInfo:

---
  org.apache.coyote.Request cyR = ((CoyoteRequest)request).getCoyoteRequest();
  RequestInfo rqInf = cyR.getRequestProcessor();
.
.
.
	log("==>>>rqInf.getRequestProcessingTime() :"+rqInf.getRequestProcessingTime() +":\n",date);
	log("==>>>rqInf.getProcessingTime() :"+rqInf.getProcessingTime() +":\n",date);
	log("==>>>rqInf.getRequestCount() :" + rqInf.getRequestCount() +
	       >>>":\n",date);
context.invokeNext(request, response);
.
.
.
result.append("RequestProcessingTime() :");
	    result.append(rqInf.getRequestProcessingTime());
	    result.append(": ProcessingTime() :");
	    result.append(rqInf.getProcessingTime());
	    result.append(": RequestCount() :");
	    result.append(rqInf.getRequestCount());
	    result.append(":");

	    log(" result.toString() :" + result.toString(),date);
---

and i get for the first request 0, could this be a bug or do i
understand the RequestInfo class wrong?!

Btw: i it possibel to get the info how many requests at the moment
     tomcat currently handle?!

Thanks for help && regards

Alex

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org