costin 02/05/15 12:32:43
Modified: jk/native2/include jk_channel.h jk_endpoint.h jk_global.h
jk_service.h jk_shm.h jk_uriEnv.h jk_worker.h
jk_workerEnv.h
Log:
More cosmetic changes - removing fields that are no longer used, adding
comments.
Added several timing fields in the data we collect on the scoreboard,
and flags to turn on/off the collection ( per uri or globally ).
The time collection uses apr - it won't work in Apache1.3 ( or IIS ) unless
apr support is enabled.
In my test the time collection adds about 2 ms per request ( 33->35 ms average
for a simple request, with ab -c 20 ). I don't think this is much, but
if you don't use the info there's no need to collect it.
Also added a new function to workerEnv - to be called by the 'parent'
process in a multi-process server ( i.e. apache :-). This will allow
jk to acquire the scoreboard ( at least HPUX is picky about this ),
and will be used to reset the sb on startup.
Revision Changes Path
1.10 +2 -0 jakarta-tomcat-connectors/jk/native2/include/jk_channel.h
Index: jk_channel.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_channel.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- jk_channel.h 11 Apr 2002 19:28:01 -0000 1.9
+++ jk_channel.h 15 May 2002 19:32:42 -0000 1.10
@@ -102,6 +102,8 @@
struct jk_channel {
struct jk_bean *mbean;
+ int id;
+
/* JK_TRUE if the channel is 'stream' based, i.e. it works using
send() followed by blocking reads().
XXX make it type and define an enum of supported types ?
1.14 +56 -39 jakarta-tomcat-connectors/jk/native2/include/jk_endpoint.h
Index: jk_endpoint.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_endpoint.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- jk_endpoint.h 14 May 2002 17:04:09 -0000 1.13
+++ jk_endpoint.h 15 May 2002 19:32:42 -0000 1.14
@@ -61,12 +61,13 @@
* Author: Gal Shachor <[EMAIL PROTECTED]>
* Author: Dan Milstein <[EMAIL PROTECTED]>
* Author: Henri Gomez <[EMAIL PROTECTED]>
- * Version: $Revision: 1.13 $
+ * Version: $Revision: 1.14 $
***************************************************************************/
#ifndef JK_ENDPOINT_H
#define JK_ENDPOINT_H
+#include "jk_global.h"
#include "jk_env.h"
#include "jk_map.h"
#include "jk_service.h"
@@ -121,46 +122,40 @@
*/
struct jk_endpoint {
struct jk_bean *mbean;
- /*
- * A 'this' pointer which is used by the subclasses of this class to
- * point to data/functions which are specific to a given protocol
- * (e.g. ajp12 or ajp13 or ajp14).
+
+ int id;
+
+ /* Parent
*/
- void *endpoint_private;
+ struct jk_worker *worker;
- /** Data specific to a channel connection
+ struct jk_workerEnv *workerEnv;
+
+ /** Data specific to a channel connection. Usually a struct
+ * containing info about the active connection ( sd, jniEnv, etc ).
*/
void *channelData;
- /* Ok, this is going to be a Notes - similar with what we have on the
- * java side. Various channels need to be able to store private data.
+ /* Channel-specific data. Usually a file descriptor. ( avoids
+ using a struct for typical socket channels )
*/
- void *currentData;
- int currentOffset;
- int currentLen;
+ int sd;
+ /** Current request beeing processed.
+ * Used by JNI worker mostly ( XXX remove it, pass it explicitely )
+ */
struct jk_ws_service *currentRequest;
-
- struct jk_worker *worker;
-
- /** 'main' pool for this endpoint. Used to store properties of the
- endpoint. Will be alive until the endpoint is destroyed.
- */
- struct jk_pool *pool;
/** Connection pool. Used to store temporary data. It'll be
- recycled after each transaction.
- */
+ * recycled after each transaction.
+ * XXX Do we need it ? env->tmpPool can be used as well.
+ */
struct jk_pool *cPool;
-
- int sd;
- int reuse;
- /* Buffers for req/res */
- /* Used to be ajp_operation */
+ /* Buffers */
/* Incoming messages ( from tomcat ). Will be overriten after each
- message, you must safe any data you want to keep.
+ message, you must save any data you want to keep.
*/
struct jk_msg *reply;
@@ -169,19 +164,25 @@
*/
struct jk_msg *post;
- struct jk_msg *request; /* original request storage */
- int recoverable; /* if exchange could be conducted on
- another TC ??? */
-
- /* For redirecting endpoints like lb */
- jk_endpoint_t *realEndpoint;
+ /* original request storage ( XXX do we need it ? )
+ */
+ struct jk_msg *request;
- char *servletContainerName;
+ char *readBuf;
+ int bufPos;
+
+ /* JK_TRUE if the endpoint can be reused ( after an error ).
+ * JK_FALSE if we must close the connection - for example we have
+ * packet/marshalling error.
+ * This is different from req->is_recoverable_error, which just
+ * specifies that the request can be sent to another tomcat.
+ * Set by workerEnv if a handler returns JK_HANDLER_ERROR.
+ */
+ int recoverable;
/* The struct will be created in shm if available
*/
struct jk_stat *stats;
-
};
/** Statistics collected per endpoint
@@ -191,13 +192,29 @@
int reqCnt;
int errCnt;
- /* Total time ( for average - divide by reqCnt ) and maxTime */
- long totalTime;
- long maxTime;
+ int connected;
+ int workerId;
/* Active request
*/
- char active[128];
+ char active[64];
+
+#ifdef HAS_APR
+ /* Time when this endpoint has opened a connection to
+ tomcat
+ */
+ apr_time_t connectedTime;
+ /* Total time ( for average - divide by reqCnt )
+ and maxTime for requests.
+ */
+ apr_time_t totalTime;
+ apr_time_t maxTime;
+ /* Last request - time of start, time when we start the ajp protocol, end time
+ */
+ apr_time_t startTime;
+ apr_time_t jkStartTime;
+ apr_time_t endTime;
+#endif
};
1.11 +2 -1 jakarta-tomcat-connectors/jk/native2/include/jk_global.h
Index: jk_global.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_global.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- jk_global.h 13 May 2002 10:35:48 -0000 1.10
+++ jk_global.h 15 May 2002 19:32:42 -0000 1.11
@@ -59,7 +59,7 @@
* Description: Global definitions and include files that should exist *
* anywhere *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.10 $ *
+ * Version: $Revision: 1.11 $ *
***************************************************************************/
#ifndef JK_GLOBAL_H
@@ -150,6 +150,7 @@
#include "apr.h"
#include "apr_errno.h"
+#include "apr_time.h"
#else
1.14 +5 -2 jakarta-tomcat-connectors/jk/native2/include/jk_service.h
Index: jk_service.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_service.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- jk_service.h 3 May 2002 18:44:03 -0000 1.13
+++ jk_service.h 15 May 2002 19:32:42 -0000 1.14
@@ -63,7 +63,7 @@
* Author: Gal Shachor <[EMAIL PROTECTED]> *
* Author: Dan Milstein <[EMAIL PROTECTED]> *
* Author: Henri Gomez <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.13 $ *
+ * Version: $Revision: 1.14 $ *
***************************************************************************/
#ifndef JK_SERVICE_H
@@ -268,7 +268,10 @@
int outPos;
int outSize;
char *outBuf;
-
+#ifdef HAS_APR
+ apr_time_t startTime;
+#endif
+
/** printf style output. Formats in the tmp buf, then calls write
*/
void (JK_METHOD *jkprintf)( struct jk_env *env, struct jk_ws_service *s, char
*frm,... );
1.6 +5 -0 jakarta-tomcat-connectors/jk/native2/include/jk_shm.h
Index: jk_shm.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_shm.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- jk_shm.h 14 May 2002 20:38:00 -0000 1.5
+++ jk_shm.h 15 May 2002 19:32:42 -0000 1.6
@@ -150,6 +150,11 @@
*/
int (JK_METHOD *init)(struct jk_env *env, struct jk_shm *shm);
+ /** Reset the shm area
+ */
+ int (JK_METHOD *reset)(struct jk_env *env, struct jk_shm *shm);
+
+
/** Detach from the shared memory segment
*/
int (JK_METHOD *destroy)(struct jk_env *env, struct jk_shm *shm);
1.14 +6 -1 jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h
Index: jk_uriEnv.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- jk_uriEnv.h 9 May 2002 20:52:54 -0000 1.13
+++ jk_uriEnv.h 15 May 2002 19:32:42 -0000 1.14
@@ -120,7 +120,7 @@
struct jk_uriMap *uriMap;
- /* Generic name/value properties. Some workers may use it.
+ /* Generic name/value properties.
*/
struct jk_map *properties;
@@ -158,6 +158,11 @@
*/
struct jk_map *aliases;
+ /* If set we'll use apr_time to get the request time in microseconds and update
+ the scoreboard to reflect that.
+ */
+ int timing;
+
/* -------------------- Properties extracted from the uri, at init()
-------------------- */
/* Extracted suffix, for extension-based mathces */
char *suffix;
1.22 +4 -6 jakarta-tomcat-connectors/jk/native2/include/jk_worker.h
Index: jk_worker.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_worker.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- jk_worker.h 14 May 2002 20:38:00 -0000 1.21
+++ jk_worker.h 15 May 2002 19:32:42 -0000 1.22
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Workers controller header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.21 $ *
+ * Version: $Revision: 1.22 $ *
***************************************************************************/
#ifndef JK_WORKER_H
@@ -138,7 +138,8 @@
struct jk_bean *mbean;
struct jk_workerEnv *workerEnv;
-
+
+ int id;
/*
* A 'this' pointer which is used by the subclasses of this class to
* point to data/functions which are specific to a given protocol
@@ -163,10 +164,6 @@
*/
struct jk_map *endpointMap;
- /* Critical section used for creation of the endpoints
- */
- JK_CRIT_SEC cs;
-
/** Request pool cache. XXX We may use a pool of requests.
*/
struct jk_objCache *rPoolCache;
@@ -174,6 +171,7 @@
/* Private key used to connect to the remote side2.*/
char * secret;
+ JK_CRIT_SEC cs;
/* -------------------- Information used for load balancing ajp workers
-------------------- */
/** The id of the tomcat instance we connect to. We may have multiple
1.21 +35 -21 jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h
Index: jk_workerEnv.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- jk_workerEnv.h 14 May 2002 20:38:00 -0000 1.20
+++ jk_workerEnv.h 15 May 2002 19:32:42 -0000 1.21
@@ -58,7 +58,7 @@
/***************************************************************************
* Description: Workers controller header file *
* Author: Gal Shachor <[EMAIL PROTECTED]> *
- * Version: $Revision: 1.20 $ *
+ * Version: $Revision: 1.21 $ *
***************************************************************************/
#ifndef JK_WORKERENV_H
@@ -147,10 +147,7 @@
*/
struct jk_map *channel_map;
- /* worker.list - workers to load at startup
- */
- char **worker_list;
- int declared_workers;
+ struct jk_map *endpointMap;
/* In a multi-process server, like Apache, stores the child
id in the scoreboard ( if the scoreboard is used ).
@@ -165,6 +162,7 @@
/** Worker that will be used by default, if no other
worker is specified. Usefull for SetHandler or
to avoid the lookup
+ XXX no need - lb is the default, easy to get it.
*/
struct jk_worker *defaultWorker;
@@ -183,28 +181,15 @@
*/
struct jk_map *initData;
- /** Root env, used to register object types, etc
- */
- struct jk_env *rootEnv;
-
/*
- * Log options. Extracted from init_data.
+ * Log options. XXX move it to uriEnv, make it configurable per webapp.
+ * XXX What about apache native logger ?
*/
char *log_file;
int log_level;
- char *secret_key;
- /* jk_map_t *automount; */
-
struct jk_uriMap *uriMap;
- struct jk_uriEnv *rootWebapp;
-
- /** If 'global' server mappings will be visible in virtual hosts
- as well. XXX Not sure this is needed
- */
- int mountcopy;
-
int was_initialized;
/*
@@ -233,7 +218,9 @@
struct jk_map * envvars;
struct jk_config *config;
+
struct jk_shm *shm;
+
/* Slot for endpoint stats
*/
struct jk_shm_slot *epStat;
@@ -256,7 +243,18 @@
*/
void *_private;
- int debug;
+ JK_CRIT_SEC cs;
+
+ /* Global setting to enable counters on all requests.
+ * That adds about 2-3 ms per request ( at least on linux ),
+ * and will store average and max processing time per endpoint
+ * ( that can be agregated per worker or per server ).
+ * Note that we can't collect per request times - it's not
+ * thread safe and sync is expensive. As workaround you
+ * can enable timers only on a specific request and/or
+ * use a dedicated worker/channel for that request.
+ */
+ int timing;
/* -------------------- Methods -------------------- */
@@ -277,6 +275,13 @@
struct jk_workerEnv *_this,
struct jk_channel *w);
+ /** Add an endpoint. Endpoints are long lived and used to store
+ statistics. The endpoint can be in used in only one thread
+ at a time, it's a good way to avoid synchronization.
+ */
+ int (*addEndpoint)(struct jk_env *env, struct jk_workerEnv *wEnv,
+ struct jk_endpoint *ep);
+
int (*initChannel)(struct jk_env *env,
struct jk_workerEnv *wEnv, struct jk_channel *ch);
@@ -296,6 +301,15 @@
struct jk_workerEnv *_this,
struct jk_endpoint *e,
struct jk_ws_service *r );
+
+ /**
+ * Special init function to be called from the parent process
+ * ( with root privs ? ).
+ * Used to create the scoreboard ( workaround required at least for HPUX )
+ *
+ * init() will be called for each child, parentInit() only once.
+ */
+ int (*parentInit)(struct jk_env *env, struct jk_workerEnv *_this);
/**
* Init the workers, prepare the worker environment. Will read
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>