JBoss Native SVN: r1605 - trunk/mod_cluster/native/include.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-15 10:21:28 -0400 (Thu, 15 May 2008)
New Revision: 1605
Modified:
trunk/mod_cluster/native/include/node.h
Log:
typo.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-05-15 06:39:02 UTC (rev 1604)
+++ trunk/mod_cluster/native/include/node.h 2008-05-15 14:21:28 UTC (rev 1605)
@@ -59,7 +59,7 @@
int flushwait;
int ping;
int smax;
- int ttl
+ int ttl;
char strtime[8]; /* date when send by the node */
16 years, 7 months
JBoss Native SVN: r1604 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-15 02:39:02 -0400 (Thu, 15 May 2008)
New Revision: 1604
Added:
trunk/mod_cluster/native/mod_manager/.deps
trunk/mod_cluster/native/mod_manager/Makefile.in
trunk/mod_cluster/native/mod_manager/balancer.c
trunk/mod_cluster/native/mod_manager/buildconf
trunk/mod_cluster/native/mod_manager/configure.in
trunk/mod_cluster/native/mod_manager/context.c
trunk/mod_cluster/native/mod_manager/host.c
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_manager/node.c
Log:
Add shared table handlers and protocol processor.
Added: trunk/mod_cluster/native/mod_manager/.deps
===================================================================
Added: trunk/mod_cluster/native/mod_manager/Makefile.in
===================================================================
--- trunk/mod_cluster/native/mod_manager/Makefile.in (rev 0)
+++ trunk/mod_cluster/native/mod_manager/Makefile.in 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,23 @@
+# Makefile.in for mod_proxy_cluster
+# copy the source in the httpd Apache source tree
+APACHE_BASE = @APACHE_BASE@
+top_builddir = @APACHE_BASE@
+# For .deps.
+builddir = @CLUSTER_BASE@
+# For the apache includes
+top_srcdir = @APACHE_BASE@
+
+include $(APACHE_BASE)/build/rules.mk
+SH_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CC) -I../include -prefer-pic -c $< && touch $@
+
+all: mod_manager.so
+
+mod_manager.so: mod_manager.la
+ $(APACHE_BASE)/build/instdso.sh SH_LIBTOOL='$(LIBTOOL)' mod_manager.la `pwd`
+
+mod_manager.la: mod_manager.slo node.slo context.slo host.slo balancer.slo
+ $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_manager.lo node.lo context.lo host.lo balancer.lo
+
+clean:
+ rm -f *.o *.lo *.slo
+ rm -rf .libs
Added: trunk/mod_cluster/native/mod_manager/balancer.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/balancer.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/balancer.c 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,227 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file balancer.c
+ * @brief balancer description Storage Module for Apache
+ *
+ * @defgroup MEM balancers
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "slotmem.h"
+#include "balancer.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_balancer(char *string, int *num, int type, apr_pool_t *p, slotmem_storage_method *storage) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = storage;
+ storename = apr_pstrcat(p, string, BALANCEREXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename, sizeof(balancerinfo_t), *num, p);
+ else {
+ apr_size_t size = sizeof(balancerinfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename, &size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a balancer record in the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ balancerinfo_t *in = (balancerinfo_t *)*data;
+ balancerinfo_t *ou = (balancerinfo_t *)mem;
+ if (strcmp(in->balancer, ou->balancer) == 0) {
+ memcpy(ou, in, sizeof(balancerinfo_t));
+ ou->id = id;
+ ou->updatetime = apr_time_sec(apr_time_now());
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou;
+ int ident;
+
+ balancer->id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &balancer, s->p);
+ if (balancer->id != 0 && rv == APR_SUCCESS) {
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **) &ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, balancer, sizeof(balancerinfo_t));
+ ou->id = ident;
+ ou->updatetime = apr_time_sec(apr_time_now());
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to read from the shared table.
+ * @return address of the read balancer or NULL if error.
+ */
+static apr_status_t loc_read_balancer(void* mem, void **data, int id, apr_pool_t *pool) {
+ balancerinfo_t *in = (balancerinfo_t *)*data;
+ balancerinfo_t *ou = (balancerinfo_t *)mem;
+
+ if (strcmp(in->balancer, ou->balancer) == 0) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+APR_DECLARE(balancerinfo_t *) read_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou = balancer;
+
+ if (balancer->id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, balancer->id, (void **) &ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_balancer, &ou, s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer address where the balancer is locate in the shared table.
+ * @param ids in the balancer table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_balancer(mem_t *s, balancerinfo_t **balancer, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) balancer));
+}
+
+/**
+ * remove(free) a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou = balancer;
+ if (balancer->id)
+ s->storage->ap_slotmem_free(s->slotmem, balancer->id, balancer);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_balancer, &ou, s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->id, balancer);
+ }
+ return rv;
+}
+
+/*
+ * get the ids for the used (not free) balancers in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_balancer(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_balancer(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared balancer table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_balancer(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_balancer(string, num, 0, p, storage));
+}
+/**
+ * create a shared balancer table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_balancer(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_balancer(string, num, 1, p, storage));
+}
Added: trunk/mod_cluster/native/mod_manager/buildconf
===================================================================
--- trunk/mod_cluster/native/mod_manager/buildconf (rev 0)
+++ trunk/mod_cluster/native/mod_manager/buildconf 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+rm -rf aclocal.m4 autom4te*.cache
+
+echo "Creating configure ..."
+### do some work to toss config.cache?
+if ${AUTOCONF:-autoconf}; then
+ :
+else
+ echo "autoconf failed"
+ exit 1
+fi
Property changes on: trunk/mod_cluster/native/mod_manager/buildconf
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/mod_cluster/native/mod_manager/configure.in
===================================================================
--- trunk/mod_cluster/native/mod_manager/configure.in (rev 0)
+++ trunk/mod_cluster/native/mod_manager/configure.in 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,24 @@
+dnl configure for mod_manager
+dnl
+
+AC_INIT(mod_manager.c)
+
+AC_MSG_CHECKING(for Apache httpd installation)
+AC_ARG_WITH(apache,
+[ --with-apache[=DIR] DIR is the apache base installation
+],
+[ if test "$withval" = "yes"; then
+ withval=/usr/local/etc/httpd
+ fi
+ if test "$withval" != "no"; then
+ APACHE_BASE=$withval
+ else
+ AC_MSG_ERROR(mod_manager need a valid apache location)
+ fi
+],
+[ AC_MSG_ERROR(Please use --with-apache[=DIR])])
+CLUSTER_BASE=`pwd`
+
+AC_SUBST(APACHE_BASE)
+AC_SUBST(CLUSTER_BASE)
+AC_OUTPUT(Makefile)
Added: trunk/mod_cluster/native/mod_manager/context.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/context.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/context.c 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,228 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file context.c
+ * @brief context description Storage Module for Apache
+ *
+ * @defgroup MEM contexts
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "slotmem.h"
+#include "context.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_context(char *string, int *num, int type, apr_pool_t *p, slotmem_storage_method *storage) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = storage;
+ storename = apr_pstrcat(p, string, CONTEXTEXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename, sizeof(contextinfo_t), *num, p);
+ else {
+ apr_size_t size = sizeof(contextinfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename, &size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a context record in the shared table
+ * @param pointer to the shared table.
+ * @param context context to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ contextinfo_t *in = (contextinfo_t *)*data;
+ contextinfo_t *ou = (contextinfo_t *)mem;
+ if (strcmp(in->context, ou->context) == 0 &&
+ in->vhost == ou->vhost && in->node == ou->node) {
+ memcpy(ou, in, sizeof(contextinfo_t));
+ ou->id = id;
+ ou->updatetime = apr_time_sec(apr_time_now());
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_context(mem_t *s, contextinfo_t *context)
+{
+ apr_status_t rv;
+ contextinfo_t *ou;
+ int ident;
+
+ context->id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &context, s->p);
+ if (context->id != 0 && rv == APR_SUCCESS) {
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **) &ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, context, sizeof(contextinfo_t));
+ ou->id = ident;
+ ou->updatetime = apr_time_sec(apr_time_now());
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context context to read from the shared table.
+ * @return address of the read context or NULL if error.
+ */
+static apr_status_t loc_read_context(void* mem, void **data, int id, apr_pool_t *pool) {
+ contextinfo_t *in = (contextinfo_t *)*data;
+ contextinfo_t *ou = (contextinfo_t *)mem;
+ if (strcmp(in->context, ou->context) == 0 &&
+ in->vhost == ou->vhost && ou->node == in->node) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+APR_DECLARE(contextinfo_t *) read_context(mem_t *s, contextinfo_t *context)
+{
+ apr_status_t rv;
+ contextinfo_t *ou = context;
+
+ if (context->id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, context->id, (void **) &ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_context, &ou, s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context address where the context is locate in the shared table.
+ * @param ids in the context table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_context(mem_t *s, contextinfo_t **context, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) context));
+}
+
+/**
+ * remove(free) a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context context to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_context(mem_t *s, contextinfo_t *context)
+{
+ apr_status_t rv;
+ contextinfo_t *ou = context;
+ if (context->id)
+ s->storage->ap_slotmem_free(s->slotmem, context->id, context);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_context, &ou, s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->id, context);
+ }
+ return rv;
+}
+
+/*
+ * get the ids for the used (not free) contexts in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of context existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_context(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of context existing or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_context(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared context table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_context(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_context(string, num, 0, p, storage));
+}
+/**
+ * create a shared context table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_context(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_context(string, num, 1, p, storage));
+}
Added: trunk/mod_cluster/native/mod_manager/host.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/host.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/host.c 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,225 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file host.c
+ * @brief host description Storage Module for Apache
+ *
+ * @defgroup MEM hosts
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "slotmem.h"
+#include "host.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_host(char *string, int *num, int type, apr_pool_t *p, slotmem_storage_method *storage) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = storage;
+ storename = apr_pstrcat(p, string, HOSTEXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename, sizeof(hostinfo_t), *num, p);
+ else {
+ apr_size_t size = sizeof(hostinfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename, &size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a host record in the shared table
+ * @param pointer to the shared table.
+ * @param host host to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ hostinfo_t *in = (hostinfo_t *)*data;
+ hostinfo_t *ou = (hostinfo_t *)mem;
+ if (strcmp(in->host, ou->host) == 0 && in->vhost == ou->vhost && in->node == ou->node) {
+ memcpy(ou, in, sizeof(hostinfo_t));
+ ou->id = id;
+ ou->updatetime = apr_time_sec(apr_time_now());
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_host(mem_t *s, hostinfo_t *host)
+{
+ apr_status_t rv;
+ hostinfo_t *ou;
+ int ident;
+
+ host->id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &host, s->p);
+ if (host->id != 0 && rv == APR_SUCCESS) {
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **) &ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, host, sizeof(hostinfo_t));
+ ou->id = ident;
+ ou->updatetime = apr_time_sec(apr_time_now());
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host host to read from the shared table.
+ * @return address of the read host or NULL if error.
+ */
+static apr_status_t loc_read_host(void* mem, void **data, int id, apr_pool_t *pool) {
+ hostinfo_t *in = (hostinfo_t *)*data;
+ hostinfo_t *ou = (hostinfo_t *)mem;
+
+ if (strcmp(in->host, ou->host) == 0 && in->node == ou->node ) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+APR_DECLARE(hostinfo_t *) read_host(mem_t *s, hostinfo_t *host)
+{
+ apr_status_t rv;
+ hostinfo_t *ou = host;
+
+ if (host->id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, host->id, (void **) &ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_host, &ou, s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host address where the host is locate in the shared table.
+ * @param ids in the host table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_host(mem_t *s, hostinfo_t **host, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) host));
+}
+
+/**
+ * remove(free) a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host host to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_host(mem_t *s, hostinfo_t *host)
+{
+ apr_status_t rv;
+ hostinfo_t *ou = host;
+ if (host->id)
+ s->storage->ap_slotmem_free(s->slotmem, host->id, host);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_host, &ou, s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->id, host);
+ }
+ return rv;
+}
+
+/*
+ * get the ids for the used (not free) hosts in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of host existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_host(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of host existing or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_host(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared host table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_host(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_host(string, num, 0, p, storage));
+}
+/**
+ * create a shared host table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_host(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_host(string, num, 1, p, storage));
+}
Added: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,880 @@
+/*
+ Copyright 2008 Red Hat Middleware, LLC.
+ Licensed 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,i
+ 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.
+ */
+
+#include "apr_strings.h"
+#include "apr_lib.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
+#include "http_main.h"
+#include "http_request.h"
+#include "http_protocol.h"
+#include "http_core.h"
+#include "scoreboard.h"
+
+#include "slotmem.h"
+
+#include "node.h"
+#include "host.h"
+#include "context.h"
+#include "balancer.h"
+
+#define DEFMAXCONTEXT 100
+#define DEFMAXNODE 10
+#define DEFMAXHOST 20
+
+/* shared memory */
+mem_t *contextstatsmem = NULL;
+mem_t *nodestatsmem = NULL;
+mem_t *hoststatsmem = NULL;
+mem_t *balancerstatsmem = NULL;
+
+slotmem_storage_method *storage = NULL;
+
+module AP_MODULE_DECLARE_DATA manager_module;
+
+typedef struct mod_manager_config
+{
+ /* base name for the shared memory */
+ char *basefilename;
+ /* max number of context supported */
+ int maxcontext;
+ /* max munber of node supported */
+ int maxnode;
+ /* max munber of host supported */
+ int maxhost;
+} mod_manager_config;
+
+/*
+ * routines for the node_storage_method
+ */
+static apr_status_t loc_read_node(int ids, nodeinfo_t **node)
+{
+ return (get_node(nodestatsmem, node, ids));
+}
+static int loc_get_ids_used_node(int *ids)
+{
+ return(get_ids_used_node(nodestatsmem, ids));
+}
+static int loc_get_max_size_node()
+{
+ return(get_max_size_node(nodestatsmem));
+}
+static const struct node_storage_method node_storage =
+{
+ loc_read_node,
+ loc_get_ids_used_node,
+ loc_get_max_size_node
+};
+
+/*
+ * routines for the context_storage_method
+ */
+static apr_status_t loc_read_context(int ids, contextinfo_t **context)
+{
+ return (get_context(contextstatsmem, context, ids));
+}
+static int loc_get_ids_used_context(int *ids)
+{
+ return(get_ids_used_context(contextstatsmem, ids));
+}
+static int loc_get_max_size_context()
+{
+ return(get_max_size_context(contextstatsmem));
+}
+static const struct context_storage_method context_storage =
+{
+ loc_read_context,
+ loc_get_ids_used_context,
+ loc_get_max_size_context
+};
+
+/*
+ * routines for the host_storage_method
+ */
+static apr_status_t loc_read_host(int ids, hostinfo_t **host)
+{
+ return (get_host(hoststatsmem, host, ids));
+}
+static int loc_get_ids_used_host(int *ids)
+{
+ return(get_ids_used_host(hoststatsmem, ids));
+}
+static int loc_get_max_size_host()
+{
+ return(get_max_size_host(hoststatsmem));
+}
+static const struct host_storage_method host_storage =
+{
+ loc_read_host,
+ loc_get_ids_used_host,
+ loc_get_max_size_host
+};
+
+/*
+ * routines for the balancer_storage_method
+ */
+static apr_status_t loc_read_balancer(int ids, balancerinfo_t **balancer)
+{
+ return (get_balancer(balancerstatsmem, balancer, ids));
+}
+static int loc_get_ids_used_balancer(int *ids)
+{
+ return(get_ids_used_balancer(balancerstatsmem, ids));
+}
+static int loc_get_max_size_balancer()
+{
+ return(get_max_size_balancer(balancerstatsmem));
+}
+static const struct balancer_storage_method balancer_storage =
+{
+ loc_read_balancer,
+ loc_get_ids_used_balancer,
+ loc_get_max_size_balancer
+};
+
+/* helper for the handling of the Alias: host1,... Context: context1,... */
+struct cluster_host {
+ char *host;
+ char *context;
+ struct cluster_host *next;
+};
+
+/*
+ * call after parser the configuration.
+ * create the shared memory.
+ */
+static int manager_init(apr_pool_t *p, apr_pool_t *plog,
+ apr_pool_t *ptemp, server_rec *s)
+{
+ char *node;
+ char *context;
+ char *host;
+ char *balancer;
+ mod_manager_config *mconf = ap_get_module_config(s->module_config, &manager_module);
+ if (mconf->basefilename) {
+ node = apr_pstrcat(ptemp, mconf->basefilename, ".node", NULL);
+ context = apr_pstrcat(ptemp, mconf->basefilename, ".context", NULL);
+ host = apr_pstrcat(ptemp, mconf->basefilename, ".host", NULL);
+ balancer = apr_pstrcat(ptemp, mconf->basefilename, ".balancer", NULL);
+ } else {
+ node = "manager.node";
+ context = "manager.context";
+ host = "manager.host";
+ host = "manager.balancer";
+ }
+
+ /* Get a provider to handle the shared memory */
+
+ storage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0");
+ if (storage == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "ap_lookup_provider %s failed", SLOTMEM_STORAGE);
+ return !OK;
+ }
+ nodestatsmem = create_mem_node(node, &mconf->maxnode, p, storage);
+ if (nodestatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_node %s failed", node);
+ return !OK;
+ }
+
+ contextstatsmem = create_mem_context(context, &mconf->maxcontext, p, storage);
+ if (contextstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_context failed");
+ return !OK;
+ }
+
+ hoststatsmem = create_mem_host(host, &mconf->maxhost, p, storage);
+ if (hoststatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_host failed");
+ return !OK;
+ }
+
+ balancerstatsmem = create_mem_balancer(balancer, &mconf->maxhost, p, storage);
+ if (balancerstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_balancer failed");
+ return !OK;
+ }
+
+ // sharedmem_initialize_cleanup(p);
+ return OK;
+}
+static char **process_buff(request_rec *r, char *buff)
+{
+ int i = 0;
+ char *s = buff;
+ char **ptr = NULL;
+ for (; *s != '\0'; s++) {
+ if (*s == '&') {
+ i++;
+ }
+ }
+ ptr = apr_palloc(r->pool, sizeof(char *) * ((2 *i) +1));
+ if (ptr == NULL)
+ return NULL;
+
+ s = buff;
+ ptr[0] = s;
+ ptr[2*i] = NULL;
+ i = 1;
+ for (; *s != '\0'; s++) {
+ if (*s == '&' || *s == '=') {
+ *s = '\0';
+ ptr[i] = s + 1;
+ i++;
+ }
+ }
+ return ptr;
+}
+/*
+ * Insert the hosts from Alias information
+ */
+static int insert_update_hosts(mem_t *mem, char *str, int node, int vhost)
+{
+ char *ptr = str;
+ char *previous = str;
+ int ret = 0;
+ hostinfo_t info;
+ char empty[1] = {'\0'};
+
+ info.node = node;
+ info.vhost = vhost;
+ if (ptr == NULL) {
+ ptr = empty;
+ previous = ptr;
+ }
+ while (*ptr) {
+ if (*ptr == ',') {
+ *ptr = '\0';
+ strncpy(info.host, previous, sizeof(info.host));
+ insert_update_host(mem, &info);
+ if (!ret)
+ ret = info.id;
+ previous = ptr + 1;
+ }
+ ptr ++;
+ }
+ strncpy(info.host, previous, sizeof(info.host));
+ insert_update_host(mem, &info);
+ return ret;
+}
+/*
+ * Insert the context from Context information
+ */
+static int insert_update_contexts(mem_t *mem, char *str, int node, int vhost, int status)
+{
+ char *ptr = str;
+ char *previous = str;
+ int ret = 0;
+ contextinfo_t info;
+ char empty[2] = {'/','\0'};
+
+ info.node = node;
+ info.vhost = vhost;
+ info.status = status;
+ if (ptr == NULL) {
+ ptr = empty;
+ previous = ptr;
+ }
+ while (*ptr) {
+ if (*ptr == ',') {
+ *ptr = '\0';
+ strncpy(info.context, previous, sizeof(info.context));
+ insert_update_context(mem, &info);
+ if (!ret)
+ ret = info.id;
+ previous = ptr + 1;
+ }
+ ptr ++;
+ }
+ strncpy(info.context, previous, sizeof(info.context));
+ if (status != REMOVE)
+ insert_update_context(mem, &info);
+ else
+ remove_context(mem, &info);
+ return ret;
+}
+
+/*
+ * Process a CONFIG message
+ * JvmRoute?: <JvmRoute>
+ * Domain: <Domain>
+ * <Host: <Node IP>
+ * Port: <Connector Port>
+ * Type: <Type of the connector>
+ * Reserved: <Use connection pool initiated by Tomcat *.
+ * (<node conf>
+ * Virtual hosts in JBossAS
+ * Alias: <vhost list>
+ * Context corresponding to the applications.
+ * Context: <context list>
+ */
+static int process_config(request_rec *r, char *buff)
+{
+ /* Process the node description */
+ nodeinfo_t nodeinfo;
+ char *JVMRoute;
+ char *Domain;
+ char *Host;
+ char *Port;
+ char *Type;
+ /* XXX node conf */
+
+ struct cluster_host *vhost;
+ struct cluster_host *phost;
+
+ char **ptr = process_buff(r, buff);
+ if (ptr == NULL)
+ return 500;
+ vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
+
+ /* Map nothing by default */
+ vhost->host = NULL;
+ vhost->context = NULL;
+ vhost->next = NULL;
+ phost = vhost;
+
+ nodeinfo.mess.reversed = 0;
+ int i = 0;
+ while (ptr[i]) {
+ if (strcasecmp(ptr[i], "Balancer") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.balancer))
+ return 500;
+ strcpy(nodeinfo.mess.balancer, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "JVMRoute") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.JVMRoute))
+ return 500;
+ strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "Domain") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.Domain))
+ return 500;
+ strcpy(nodeinfo.mess.Domain, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "Host") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.Host))
+ return 500;
+ strcpy(nodeinfo.mess.Host, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "Port") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.Port))
+ return 500;
+ strcpy(nodeinfo.mess.Port, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "Type") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.Type))
+ return 500;
+ strcpy(nodeinfo.mess.Type, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "Reversed") == 0) {
+ if (strcasecmp(ptr[i+1], "yes") == 0) {
+ nodeinfo.mess.reversed = 1;
+ }
+ }
+ if (strcasecmp(ptr[i], "Alias") == 0) {
+ if (phost->host && !phost->context) {
+ return 500;
+ }
+ if (phost->host) {
+ phost->next = apr_palloc(r->pool, sizeof(struct cluster_host));
+ phost = phost->next;
+ phost->next = NULL;
+ phost->host = ptr[i+1];
+ phost->context = NULL;
+ } else {
+ phost->host = ptr[i+1];
+ }
+ }
+ if (strcasecmp(ptr[i], "Context") == 0) {
+ if (phost->context) {
+ return 500;
+ }
+ phost->context = ptr[i+1];
+ }
+ i++;
+ i++;
+ }
+ /* XXX: Read the default balancer name is balancer empty */
+
+ /* Insert or update node description */
+ int id;
+ if (insert_update_node(nodestatsmem, &nodeinfo, &id) != APR_SUCCESS)
+ return 500;
+
+ /* Insert the Alias and corresponding Context */
+ phost = vhost;
+ int vid = 1; /* zero and "" is empty */
+ while (phost) {
+ insert_update_hosts(hoststatsmem, phost->host, id, vid);
+ insert_update_contexts(contextstatsmem, phost->context, id, vid, STOPPED);
+ phost = phost->next;
+ vid++;
+ }
+ return OK;
+}
+/*
+ * Process a DUMP command.
+ */
+static int process_dump(request_rec *r, char *buff)
+{
+ int size, i;
+ int *id;
+
+ ap_set_content_type(r, "text/plain");
+
+ size = get_max_size_node(nodestatsmem);
+ id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_node(nodestatsmem, id);
+ for (i=0; i<size; i++) {
+ nodeinfo_t *ou;
+ get_node(nodestatsmem, &ou, id[i]);
+ ap_rprintf(r, "node: [%d:%d] JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s\n",
+ id[i], ou->mess.id, ou->mess.JVMRoute, ou->mess.Domain,
+ ou->mess.Host, ou->mess.Port, ou->mess.Type);
+ }
+
+ size = get_max_size_host(hoststatsmem);
+ id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_host(hoststatsmem, id);
+ for (i=0; i<size; i++) {
+ hostinfo_t *ou;
+ get_host(hoststatsmem, &ou, id[i]);
+ ap_rprintf(r, "host: %d [%s] vhost: %d node: %d\n", id[i], ou->host, ou->vhost,
+ ou->node);
+ }
+
+ size = get_max_size_context(contextstatsmem);
+ id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_context(contextstatsmem, id);
+ for (i=0; i<size; i++) {
+ contextinfo_t *ou;
+ get_context(contextstatsmem, &ou, id[i]);
+ ap_rprintf(r, "context: %d [%s] vhost: %d node: %d status: %d\n", id[i], ou->context,
+ ou->vhost, ou->node,
+ ou->status);
+ }
+ return OK;
+}
+
+/* Process an enable/disable/stop application message */
+static int process_appl_cmd(request_rec *r, char *buff, int status)
+{
+ char *JVMRoute;
+ nodeinfo_t nodeinfo;
+ nodeinfo_t *node;
+ struct cluster_host *vhost;
+ struct cluster_host *phost;
+
+ char **ptr = process_buff(r, buff);
+ if (ptr == NULL)
+ return 500;
+
+ /* Map nothing by default */
+ vhost->host = NULL;
+ vhost->context = NULL;
+ vhost->next = NULL;
+ vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
+ phost = vhost;
+
+ int i = 0;
+ while (ptr[i]) {
+ if (strcasecmp(ptr[i], "JVMRoute") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.JVMRoute))
+ return 500;
+ strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+ nodeinfo.mess.id = 0;
+ }
+ if (strcasecmp(ptr[i], "Alias") == 0) {
+ if (phost->host && !phost->context) {
+ return 500;
+ }
+ if (phost->host) {
+ phost->next = apr_palloc(r->pool, sizeof(struct cluster_host));
+ phost = phost->next;
+ phost->next = NULL;
+ phost->host = ptr[i+1];
+ phost->context = NULL;
+ } else {
+ phost->host = ptr[i+1];
+ }
+ }
+ if (strcasecmp(ptr[i], "Context") == 0) {
+ if (phost->context) {
+ return 500;
+ }
+ phost->context = ptr[i+1];
+ }
+ i++;
+ i++;
+ }
+
+ /* Read the node */
+ node = read_node(nodestatsmem, &nodeinfo);
+ if (node == NULL)
+ return 500;
+
+ /* Read the ID of the virtual corresponding to the first Alias */
+ hostinfo_t hostinfo;
+ hostinfo_t *host;
+
+ hostinfo.node = node->mess.id;
+ if (vhost->host != NULL)
+ strcpy(hostinfo.host, vhost->host);
+ else
+ hostinfo.host[0] = '\0';
+
+ hostinfo.id = 0;
+ host = read_host(hoststatsmem, &hostinfo);
+ if (host == NULL) {
+ return 500;
+ }
+
+ /* Now update each context from Context: part */
+ insert_update_contexts(contextstatsmem, phost->context, node->mess.id, host->vhost, status);
+ return OK;
+}
+static int process_enable(request_rec *r, char *buff)
+{
+ return process_appl_cmd(r, buff, ENABLED);
+}
+static int process_disable(request_rec *r, char *buff)
+{
+ return process_appl_cmd(r, buff, DISABLED);
+}
+static int process_stop(request_rec *r, char *buff)
+{
+ return process_appl_cmd(r, buff, STOPPED);
+}
+static int process_remove(request_rec *r, char *buff)
+{
+ return process_appl_cmd(r, buff, REMOVE);
+}
+
+/*
+ * XXX: Need to be write the idea is to get a provider for mod_proxy_cluster for each scheme.
+ * Do a ping/png request to the node and set the load factor.
+ */
+static int isnode_up(request_rec *r, int id, char *scheme, int Load)
+{
+ return OK;
+}
+/*
+ * Process the STATUS command
+ * Load -1 : Broken
+ * Load 0 : Standby.
+ * Load 1-100 : Load factor.
+ */
+static int process_status(request_rec *r, char *buff)
+{
+ int Load;
+ nodeinfo_t nodeinfo;
+ nodeinfo_t *node;
+ char **ptr = process_buff(r, buff);
+ if (ptr == NULL)
+ return 500;
+
+ int i = 0;
+ while (ptr[i]) {
+ if (strcasecmp(ptr[i], "JVMRoute") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.JVMRoute))
+ return 500;
+ strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+ nodeinfo.mess.id = 0;
+ }
+ else if (strcasecmp(ptr[i], "Load") == 0) {
+ Load = atoi(ptr[i+1]);
+ }
+ else
+ return 500;
+ i++;
+ i++;
+ }
+
+ /* Read the node */
+ node = read_node(nodestatsmem, &nodeinfo);
+ if (node == NULL)
+ return 500;
+
+ /*
+ * If the node is usualable do a ping/pong to prevent Split-Brain Syndrome
+ * and update the worker status and load factor acccording to the test result.
+ */
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Type=STATUS-RSP&JVMRoute=%s", nodeinfo.mess.JVMRoute);
+
+ if (isnode_up(r, node->mess.id, node->mess.Type, Load) != OK)
+ ap_rprintf(r, "&State=NOTOK");
+ else
+ ap_rprintf(r, "&State=OK");
+ if (ap_my_generation)
+ ap_rprintf(r, "&id=%d", ap_my_generation);
+ else
+ ap_rprintf(r, "&id=%d", ap_scoreboard_image->global->restart_time);
+
+ ap_rprintf(r, "\n");
+ return OK;
+}
+
+/*
+ * Decodes a '%' escaped string, and returns the number of characters
+ * (From mod_proxy_ftp.c).
+ */
+static int decodeenc(char *x)
+{
+ int i, j, ch;
+
+ if (x[0] == '\0')
+ return 0; /* special case for no characters */
+ for (i = 0, j = 0; x[i] != '\0'; i++, j++) {
+ /* decode it if not already done */
+ ch = x[i];
+ if (ch == '%' && apr_isxdigit(x[i + 1]) && apr_isxdigit(x[i + 2])) {
+ ch = ap_proxy_hex2c(&x[i + 1]);
+ i += 2;
+ }
+ x[j] = ch;
+ }
+ x[j] = '\0';
+ return j;
+}
+/*
+ * This routine is called before mod_proxy translate name.
+ * This allows us to make decisions before mod_proxy
+ * to be able to fill tables even with ProxyPass / balancer...
+ */
+static int manager_trans(request_rec *r)
+{
+ int ours = 0;
+ if (strcasecmp(r->method, "CONFIG") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "ENABLE-APP") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "DISABLE-APP") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "STOP-APP") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "REMOVE-APP") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "STATUS") == 0)
+ ours = 1;
+ else if (strcasecmp(r->method, "DUMP") == 0)
+ ours = 1;
+ if (ours) {
+ /* The method one of ours */
+ r->handler = "mod-cluster";
+ return OK;
+ }
+
+ return DECLINED;
+}
+
+
+/* Process the requests from the ModClusterService */
+static int manager_handler(request_rec *r)
+{
+ apr_bucket_brigade *input_brigade;
+ char buff[4096];
+ int bufsiz=sizeof(buff);
+ if (strcmp(r->handler, "mod-cluster"))
+ return DECLINED;
+ input_brigade = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
+ ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ, sizeof(buff));
+ apr_brigade_flatten(input_brigade, buff, &bufsiz);
+ buff[bufsiz] = '\0';
+ decodeenc(buff);
+ if (strcasecmp(r->method, "CONFIG") == 0)
+ return(process_config(r, buff));
+ /* Application handling */
+ else if (strcasecmp(r->method, "ENABLE-APP") == 0)
+ return(process_enable(r, buff));
+ else if (strcasecmp(r->method, "DISABLE-APP") == 0)
+ return(process_disable(r, buff));
+ else if (strcasecmp(r->method, "STOP-APP") == 0)
+ return(process_stop(r, buff));
+ else if (strcasecmp(r->method, "REMOVE-APP") == 0)
+ return(process_remove(r, buff));
+ /* Status handling */
+ else if (strcasecmp(r->method, "STATUS") == 0)
+ return(process_status(r, buff));
+ else if (strcasecmp(r->method, "DUMP") == 0)
+ return(process_dump(r, buff));
+ else {
+ /* The command is not supported */
+ r->status_line = apr_psprintf(r->pool, "%3.3u VERSION %d.%d.%d", 500, 0, 0, 0);
+ return 500;
+ }
+
+ return (OK);
+}
+
+/*
+ * Supported directives.
+ */
+AP_DECLARE_NONSTD(const char *) cmd_manager_maxcontext(cmd_parms *cmd, void *mconfig, const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config, &manager_module);
+ mconf->maxcontext = atoi(word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_maxnode(cmd_parms *cmd, void *mconfig, const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config, &manager_module);
+ mconf->maxnode = atoi(word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_maxhost(cmd_parms *cmd, void *mconfig, const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config, &manager_module);
+ mconf->maxhost = atoi(word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_memmanagerfile(cmd_parms *cmd, void *mconfig, const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config, &manager_module);
+ mconf->basefilename = apr_pstrdup(cmd->pool, word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_balancername(cmd_parms *cmd, void *mconfig, const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config, &manager_module);
+ /* XXX: create the entry in the shared balancer table */
+ return NULL;
+}
+static const command_rec manager_cmds[] =
+{
+ AP_INIT_TAKE1(
+ "Maxcontext",
+ cmd_manager_maxcontext,
+ NULL,
+ OR_ALL,
+ "Maxcontext - number max context supported by mod_cluster"
+ ),
+ AP_INIT_TAKE1(
+ "Maxnode",
+ cmd_manager_maxnode,
+ NULL,
+ OR_ALL,
+ "Maxnode - number max node supported by mod_cluster"
+ ),
+ AP_INIT_TAKE1(
+ "Maxhost",
+ cmd_manager_maxhost,
+ NULL,
+ OR_ALL,
+ "Maxhost - number max host (Alias in virtual hosts) supported by mod_cluster"
+ ),
+ AP_INIT_TAKE1(
+ "MemManagerFile",
+ cmd_manager_memmanagerfile,
+ NULL,
+ OR_ALL,
+ "MemManagerFile - base name of the files used to create/attach to shared memory"
+ ),
+ AP_INIT_TAKE1(
+ "ManagerBalancerName",
+ cmd_manager_balancername,
+ NULL,
+ OR_ALL,
+ "ManagerBalancerName - name of a balancer corresponding to the manager"
+ ),
+ {NULL}
+};
+
+/* hooks declaration */
+
+static void manager_hooks(apr_pool_t *p)
+{
+ static const char * const aszSucc[]={ "mod_proxy.c", NULL };
+
+ /* Create the shared tables for mod_proxy_cluster */
+ ap_hook_post_config(manager_init, NULL, NULL, APR_HOOK_MIDDLE);
+
+ /* post read_request handling: to be handle to use ProxyPass / */
+ ap_hook_translate_name(manager_trans, NULL, aszSucc,
+ APR_HOOK_FIRST);
+
+ /* Process the request from the ModClusterService */
+ ap_hook_handler(manager_handler, NULL, NULL, APR_HOOK_MIDDLE);
+
+ /* Register nodes/hosts/contexts table provider */
+ ap_register_provider(p, "manager" , "shared", "0", &node_storage);
+ ap_register_provider(p, "manager" , "shared", "1", &host_storage);
+ ap_register_provider(p, "manager" , "shared", "2", &context_storage);
+ ap_register_provider(p, "manager" , "shared", "3", &balancer_storage);
+}
+
+/*
+ * Config creation stuff
+ */
+static void *create_manager_config(apr_pool_t *p)
+{
+ mod_manager_config *mconf = apr_pcalloc(p, sizeof(*mconf));
+
+ mconf->basefilename = NULL;
+ mconf->maxcontext = DEFMAXCONTEXT;
+ mconf->maxnode = DEFMAXNODE;
+ mconf->maxhost = DEFMAXHOST;
+ return mconf;
+}
+
+static void *create_manager_server_config(apr_pool_t *p, server_rec *s)
+{
+ return(create_manager_config(p));
+}
+static void *merge_manager_server_config(apr_pool_t *p, void *server1_conf,
+ void *server2_conf)
+{
+ mod_manager_config *mconf1 = (mod_manager_config *) server1_conf;
+ mod_manager_config *mconf2 = (mod_manager_config *) server2_conf;
+ mod_manager_config *mconf = apr_pcalloc(p, sizeof(*mconf));
+
+ mconf->basefilename = NULL;
+ mconf->maxcontext = DEFMAXCONTEXT;
+ mconf->maxnode = DEFMAXNODE;
+
+ if (mconf2->basefilename)
+ mconf->basefilename = apr_pstrdup(p, mconf2->basefilename);
+ else if (mconf1->basefilename)
+ mconf->basefilename = apr_pstrdup(p, mconf1->basefilename);
+
+ if (mconf2->maxcontext != DEFMAXCONTEXT)
+ mconf->maxcontext = mconf2->maxcontext;
+ else if (mconf1->maxcontext != DEFMAXCONTEXT)
+ mconf->maxcontext = mconf1->maxcontext;
+
+ if (mconf2->maxnode != DEFMAXNODE)
+ mconf->maxnode = mconf2->maxnode;
+ else if (mconf1->maxnode != DEFMAXNODE)
+ mconf->maxnode = mconf1->maxnode;
+
+ if (mconf2->maxhost != DEFMAXHOST)
+ mconf->maxhost = mconf2->maxhost;
+ else if (mconf1->maxhost != DEFMAXHOST)
+ mconf->maxhost = mconf1->maxhost;
+
+ return mconf;
+}
+
+/* Module declaration */
+
+module AP_MODULE_DECLARE_DATA manager_module = {
+ STANDARD20_MODULE_STUFF,
+ NULL,
+ NULL,
+ create_manager_server_config,
+ merge_manager_server_config,
+ manager_cmds, /* command table */
+ manager_hooks /* register hooks */
+};
Added: trunk/mod_cluster/native/mod_manager/node.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/node.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/node.c 2008-05-15 06:39:02 UTC (rev 1604)
@@ -0,0 +1,242 @@
+/*
+ * mod_cluster.
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file node.c
+ * @brief node description Storage Module for Apache
+ *
+ * @defgroup MEM nodes
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "slotmem.h"
+#include "node.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_node(char *string, int *num, int type, apr_pool_t *p, slotmem_storage_method *storage) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = storage;
+ storename = apr_pstrcat(p, string, NODEEXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename, sizeof(nodeinfo_t), *num, p);
+ else {
+ apr_size_t size = sizeof(nodeinfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename, &size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a node record in the shared table
+ * @param pointer to the shared table.
+ * @param node node to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ nodeinfo_t *in = (nodeinfo_t *)*data;
+ nodeinfo_t *ou = (nodeinfo_t *)mem;
+ if (strcmp(in->mess.JVMRoute, ou->mess.JVMRoute) == 0) {
+ /*
+ * The node information is made of several pieces:
+ * Information from the cluster (nodemess_t).
+ * updatetime (time of last received message).
+ * offset (of the area shared with the proxy logic).
+ * stat (shared area with the proxy logic we shouldn't modify it here).
+ */
+ memcpy(ou, in, sizeof(nodemess_t));
+ ou->mess.id = id;
+ ou->updatetime = (unsigned long) apr_time_sec(apr_time_now());
+ ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_node(mem_t *s, nodeinfo_t *node, int *id)
+{
+ apr_status_t rv;
+ nodeinfo_t *ou;
+ int ident;
+
+ node->mess.id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &node, s->p);
+ if (node->mess.id != 0 && rv == APR_SUCCESS) {
+ *id = node->mess.id;
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **) &ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, node, sizeof(nodeinfo_t));
+ ou->mess.id = ident;
+ *id = ident;
+ ou->updatetime = (unsigned long) apr_time_sec(apr_time_now());
+
+ /* set of offset to the proxy_worker_stat */
+ ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
+
+ /* blank the proxy status information */
+ memset(ou->stat, '\0', SIZEOFSCORE);
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node node to read from the shared table.
+ * @return address of the read node or NULL if error.
+ */
+static apr_status_t loc_read_node(void* mem, void **data, int id, apr_pool_t *pool) {
+ nodeinfo_t *in = (nodeinfo_t *)*data;
+ nodeinfo_t *ou = (nodeinfo_t *)mem;
+ if (strcmp(in->mess.JVMRoute, ou->mess.JVMRoute) == 0) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+APR_DECLARE(nodeinfo_t *) read_node(mem_t *s, nodeinfo_t *node)
+{
+ apr_status_t rv;
+ nodeinfo_t *ou = node;
+
+ if (node->mess.id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, node->mess.id, (void **) &ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_node, &ou, s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node address where the node is locate in the shared table.
+ * @param ids in the node table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_node(mem_t *s, nodeinfo_t **node, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) node));
+}
+
+/**
+ * remove(free) a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node node to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_node(mem_t *s, nodeinfo_t *node)
+{
+ apr_status_t rv;
+ nodeinfo_t *ou = node;
+ if (node->mess.id)
+ s->storage->ap_slotmem_free(s->slotmem, node->mess.id, node);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_node, &ou, s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->mess.id, node);
+ }
+ return rv;
+}
+
+/*
+ * get the ids for the used (not free) nodes in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of node existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_node(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of node existing or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_node(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared node table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_node(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_node(string, num, 0, p, storage));
+}
+/**
+ * create a shared node table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @param storage slotmem logic provider.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_node(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage)
+{
+ return(create_attach_mem_node(string, num, 1, p, storage));
+}
16 years, 7 months
JBoss Native SVN: r1603 - trunk/mod_cluster/native/mod_slotmem.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-15 02:35:57 -0400 (Thu, 15 May 2008)
New Revision: 1603
Modified:
trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
Log:
Only install the cleanup in the second round of post_config.
Modified: trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c 2008-05-14 20:43:46 UTC (rev 1602)
+++ trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c 2008-05-15 06:35:57 UTC (rev 1603)
@@ -33,6 +33,16 @@
/* make sure the shared memory is cleaned */
static int initialize_cleanup(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
+ void *data;
+ const char *userdata_key = "mod_sharedmem_init";
+
+ apr_pool_userdata_get(&data, userdata_key, s->process->pool);
+ if (!data) {
+ apr_pool_userdata_set((const void *)1, userdata_key,
+ apr_pool_cleanup_null, s->process->pool);
+ return OK;
+ }
+
sharedmem_initialize_cleanup(p);
return OK;
}
16 years, 7 months
JBoss Native SVN: r1602 - trunk/mod_cluster/native/mod_slotmem.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-14 16:43:46 -0400 (Wed, 14 May 2008)
New Revision: 1602
Modified:
trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
Log:
Use mem_getstorage() and arrange it.
Modified: trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c 2008-05-14 13:34:30 UTC (rev 1601)
+++ trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c 2008-05-14 20:43:46 UTC (rev 1602)
@@ -49,13 +49,13 @@
"Fatal error: unable to create global pool for shared slotmem");
return rv;
}
- sharedmem_initglobalpool(global_pool);
+ mem_getstorage(global_pool, "");
return OK;
}
static void ap_sharedmem_register_hook(apr_pool_t *p)
{
- const slotmem_storage_method *storage = sharedmem_getstorage();
+ const slotmem_storage_method *storage = mem_getstorage(NULL, "");
ap_register_provider(p, SLOTMEM_STORAGE, "shared", "0", storage);
ap_hook_post_config(initialize_cleanup, NULL, NULL, APR_HOOK_LAST);
ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE);
Modified: trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-05-14 13:34:30 UTC (rev 1601)
+++ trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-05-14 20:43:46 UTC (rev 1602)
@@ -472,7 +472,7 @@
* and initialise the global pool */
const slotmem_storage_method *mem_getstorage(apr_pool_t *p, char *type)
{
- if (globalpool == NULL)
+ if (globalpool == NULL && p != NULL)
globalpool = p;
return(&storage);
}
16 years, 7 months
JBoss Native SVN: r1601 - in trunk/mod_cluster/native: mod_slotmem and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-14 09:34:30 -0400 (Wed, 14 May 2008)
New Revision: 1601
Modified:
trunk/mod_cluster/native/include/slotmem.h
trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
Log:
Use a more sophisticated version.
Modified: trunk/mod_cluster/native/include/slotmem.h
===================================================================
--- trunk/mod_cluster/native/include/slotmem.h 2008-05-14 09:07:33 UTC (rev 1600)
+++ trunk/mod_cluster/native/include/slotmem.h 2008-05-14 13:34:30 UTC (rev 1601)
@@ -1,17 +1,28 @@
-/* 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
+/*
+ * ALOHA - Apache Httpd Native Java Library
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Copyright(c) 2006 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
*
- * 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
*/
#ifndef SLOTMEM_H
@@ -33,10 +44,6 @@
#include "apr_pools.h"
#include "apr_shm.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-
#define SLOTMEM_STORAGE "slotmem"
typedef struct ap_slotmem ap_slotmem_t;
@@ -45,10 +52,11 @@
* callback function used for slotmem.
* @param mem is the memory associated with a worker.
* @param data is what is passed to slotmem.
+ * @param int is id of the slotmem in the table.
* @param pool is pool used to create scoreboard
* @return APR_SUCCESS if all went well
*/
-typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void *data, apr_pool_t *pool);
+typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void **data, int ident, apr_pool_t *pool);
struct slotmem_storage_method {
/**
@@ -59,7 +67,7 @@
* @param pool is pool used to create scoreboard
* @return APR_SUCCESS if all went well
*/
-AP_DECLARE(apr_status_t) (* slotmem)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
+APR_DECLARE(apr_status_t) (* ap_slotmem_do)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
/**
* create a new slotmem with each item size is item_size.
@@ -71,7 +79,7 @@
* @param pool is pool used to create scoreboard
* @return APR_SUCCESS if all went well
*/
-AP_DECLARE(apr_status_t) (* ap_slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool);
+APR_DECLARE(apr_status_t) (* ap_slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool);
/**
* attach to an existing slotmem.
@@ -83,17 +91,66 @@
* @param pool is pool to memory allocate.
* @return APR_SUCCESS if all went well
*/
-AP_DECLARE(apr_status_t) (* ap_slotmem_attach)(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
+APR_DECLARE(apr_status_t) (* ap_slotmem_attach)(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
/**
* get the memory associated with this worker slot.
* @param s ap_slotmem_t to use.
* @param item_id item to return for 0 to item_num
* @param mem address to store the pointer to the slot
+ * @return APR_SUCCESS if all went well (the slot must be an allocated slot).
+ */
+APR_DECLARE(apr_status_t) (* ap_slotmem_mem)(ap_slotmem_t *s, int item_id, void**mem);
+/**
+ * alloc a slot from the slotmem free idems.
+ * @param s ap_slotmem_t to use.
+ * @param item_id address to return the id of the slot allocates.
+ * @param mem address to store the pointer to the slot
* @return APR_SUCCESS if all went well
*/
-AP_DECLARE(apr_status_t) (* ap_slotmem_mem)(ap_slotmem_t *s, int item_id, void**mem);
+APR_DECLARE(apr_status_t) (* ap_slotmem_alloc)(ap_slotmem_t *s, int *item_id, void**mem);
+/**
+ * free a slot (return it to the free list).
+ * @param s ap_slotmem_t to use.
+ * @param item_id the id of the slot in the slotmem.
+ * @param mem pointer to the slot
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* ap_slotmem_free)(ap_slotmem_t *s, int item_id, void*mem);
+/**
+ * Lock the slotmem.
+ * @param s ap_slotmem_t to use.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* ap_slotmem_lock)(ap_slotmem_t *s);
+/**
+ * Unlock the slotmem.
+ * @param s ap_slotmem_t to use.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* ap_slotmem_unlock)(ap_slotmem_t *s);
+/**
+ * Return the used id in the slotmem table.
+ * @param s ap_slotmem_t to use.
+ * @param ids array of int where to store the free idents.
+ * @return number of slotmem in use.
+ */
+APR_DECLARE(int) (*ap_slotmem_get_used)(ap_slotmem_t *s, int *ids);
+/**
+ * Return the size of the slotmem table.
+ * @param s ap_slotmem_t to use.
+ * @return number of slotmem that cant be stored in the slotmem table.
+ */
+APR_DECLARE(int) (*ap_slotmem_get_max_size)(ap_slotmem_t *s);
};
typedef struct slotmem_storage_method slotmem_storage_method;
+/* Memory handler for a shared memory divided in slot.
+ * This one uses shared memory.
+ * @param pool is a global pool to allocate memory.
+ * @param type name of the module provider of charged memory.
+ * @return structure to the storage routines.
+ */
+const slotmem_storage_method *mem_getstorage(apr_pool_t *p, char *type);
+
#endif /*SLOTMEM_H*/
Modified: trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-05-14 09:07:33 UTC (rev 1600)
+++ trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-05-14 13:34:30 UTC (rev 1601)
@@ -1,23 +1,33 @@
-/* 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
+/*
+ * mod_cluster.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
*
- * 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
*/
/* Memory handler for a shared memory divided in slot.
* This one uses shared memory.
*/
-#define CORE_PRIVATE
#include "apr.h"
#include "apr_file_io.h"
@@ -25,12 +35,7 @@
#include "apr_pools.h"
#include "apr_shm.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-
#include "slotmem.h"
-#include "sharedmem_util.h"
/* The description of the slots to reuse the slotmem */
struct sharedslotdesc {
@@ -41,10 +46,12 @@
struct ap_slotmem {
char *name;
apr_shm_t *shm;
+ int *ident; /* integer table to process a fast alloc/free */
void *base;
apr_size_t size;
int num;
apr_pool_t *globalpool;
+ apr_file_t *global_lock; /* file used for the locks */
struct ap_slotmem *next;
};
@@ -55,6 +62,7 @@
/*
* Persiste the slotmem in a file
* slotmem name and file name.
+ * for example use:
* anonymous : $server_root/logs/anonymous.slotmem
* :module.c : $server_root/logs/module.c.slotmem
* abs_name : $abs_name.slotmem
@@ -63,18 +71,7 @@
static const char *store_filename(apr_pool_t *pool, const char *slotmemname)
{
const char *storename;
- const char *fname;
- if (strcmp(slotmemname, "anonymous") == 0)
- fname = ap_server_root_relative(pool, "logs/anonymous");
- else if (slotmemname[0] == ':') {
- const char *tmpname;
- tmpname = apr_pstrcat(pool, "logs/", &slotmemname[1], NULL);
- fname = ap_server_root_relative(pool, tmpname);
- }
- else {
- fname = slotmemname;
- }
- storename = apr_pstrcat(pool, fname , ".slotmem", NULL);
+ storename = apr_pstrcat(pool, slotmemname , ".slotmem", NULL);
return storename;
}
static void store_slotmem(ap_slotmem_t *slotmem)
@@ -94,15 +91,15 @@
if (rv != APR_SUCCESS) {
return;
}
- nbytes = slotmem->size * slotmem->num;
- apr_file_write(fp, slotmem->base, &nbytes);
+ nbytes = slotmem->size * slotmem->num + sizeof(int) * (slotmem->num + 1);
+ apr_file_write(fp, slotmem->ident, &nbytes);
apr_file_close(fp);
}
void restore_slotmem(void *ptr, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
const char *storename;
apr_file_t *fp;
- apr_size_t nbytes = item_size * item_num;
+ apr_size_t nbytes = item_size * item_num + sizeof(int) * (item_num + 1);
apr_status_t rv;
storename = store_filename(pool, name);
@@ -135,28 +132,42 @@
while (next) {
store_slotmem(next);
rv = apr_shm_destroy(next->shm);
+ /* XXX: remove the lock file ? */
next = next->next;
}
- apr_pool_destroy(pool);
}
return APR_SUCCESS;
}
static apr_status_t ap_slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
{
- int i;
+ int i, j, isfree, *ident;
void *ptr;
+ apr_status_t rv;
if (!mem) {
return APR_ENOSHMAVAIL;
}
+ /* performs the func only on allocated slots! */
ptr = mem->base;
- for (i = 0; i < mem->num; i++) {
+ for (i = 1; i < mem->num+1; i++) {
+ ident = mem->ident;
+ isfree = 0;
+ for (j=0; j<mem->num+1; j++) {
+ if (ident[j] == i) {
+ isfree = 1;
+ break;
+ }
+ }
+ if (!isfree) {
+ rv = func((void *)ptr, data, i, pool);
+ if (rv == APR_SUCCESS)
+ return(rv);
+ }
ptr = ptr + mem->size;
- func((void *)ptr, data, pool);
}
- return 0;
+ return APR_NOTFOUND;
}
static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
{
@@ -165,18 +176,16 @@
struct sharedslotdesc desc;
ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
+ apr_status_t rv;
const char *fname;
- apr_status_t rv;
+ const char *filename;
+ apr_size_t nbytes = item_size * item_num + sizeof(int) * (item_num + 1) + sizeof(struct sharedslotdesc);
+ int i, *ident;
if (globalpool == NULL)
return APR_ENOSHMAVAIL;
if (name) {
- if (name[0] == ':') {
- fname = name;
- }
- else {
- fname = ap_server_root_relative(pool, name);
- }
+ fname = name;
/* first try to attach to existing slotmem */
if (next) {
@@ -199,7 +208,7 @@
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
- if (name && name[0] != ':') {
+ if (name) {
rv = apr_shm_attach(&res->shm, fname, globalpool);
}
else {
@@ -207,14 +216,14 @@
}
if (rv == APR_SUCCESS) {
/* check size */
- if (apr_shm_size_get(res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
+ if (apr_shm_size_get(res->shm) != nbytes) {
apr_shm_detach(res->shm);
res->shm = NULL;
return APR_EINVAL;
}
ptr = apr_shm_baseaddr_get(res->shm);
memcpy(&desc, ptr, sizeof(desc));
- if ( desc.item_size != item_size || desc.item_num != item_num) {
+ if (desc.item_size != item_size || desc.item_num != item_num) {
apr_shm_detach(res->shm);
res->shm = NULL;
return APR_EINVAL;
@@ -222,28 +231,44 @@
ptr = ptr + sizeof(desc);
}
else {
- if (name && name[0] != ':') {
+ if (name) {
apr_shm_remove(fname, globalpool);
- rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, globalpool);
+ rv = apr_shm_create(&res->shm, nbytes, fname, globalpool);
}
else {
- rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, globalpool);
+ rv = apr_shm_create(&res->shm, nbytes, NULL, globalpool);
}
if (rv != APR_SUCCESS) {
return rv;
}
+
ptr = apr_shm_baseaddr_get(res->shm);
desc.item_size = item_size;
desc.item_num = item_num;
memcpy(ptr, &desc, sizeof(desc));
ptr = ptr + sizeof(desc);
- memset(ptr, 0, item_size * item_num);
- restore_slotmem(ptr, fname, item_size, item_num, pool);
+ /* write the idents table */
+ ident = ptr;
+ for (i=0; i<item_num+1; i++) {
+ ident[i] = i + 1;
+ }
+ /* clean the slots table */
+ memset(ptr + sizeof(int) * (item_num + 1), 0, item_size * item_num);
+ /* try to restore the _whole_ stuff from a persisted location */
+ restore_slotmem(ptr, fname, item_size, item_num, pool);
}
+ /* create the lock */
+ filename = apr_pstrcat(pool, fname , ".lock", NULL);
+ rv = apr_file_open(&res->global_lock, filename, APR_WRITE|APR_CREATE, APR_OS_DEFAULT, globalpool);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+
/* For the chained slotmem stuff */
res->name = apr_pstrdup(globalpool, fname);
- res->base = ptr;
+ res->ident = ptr;
+ res->base = ptr + sizeof(int) * (item_num + 1);
res->size = item_size;
res->num = item_num;
res->globalpool = globalpool;
@@ -266,18 +291,14 @@
ap_slotmem_t *next = globallistmem;
struct sharedslotdesc desc;
const char *fname;
+ const char *filename;
apr_status_t rv;
if (globalpool == NULL) {
return APR_ENOSHMAVAIL;
}
if (name) {
- if (name[0] == ':') {
- fname = name;
- }
- else {
- fname = ap_server_root_relative(pool, name);
- }
+ fname = name;
}
else {
return APR_ENOSHMAVAIL;
@@ -305,6 +326,12 @@
if (rv != APR_SUCCESS) {
return rv;
}
+ /* get the corresponding lock */
+ filename = apr_pstrcat(pool, fname , ".lock", NULL);
+ rv = apr_file_open(&res->global_lock, filename, APR_WRITE|APR_CREATE, APR_OS_DEFAULT, globalpool);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
/* Read the description of the slotmem */
ptr = apr_shm_baseaddr_get(res->shm);
@@ -313,7 +340,8 @@
/* For the chained slotmem stuff */
res->name = apr_pstrdup(globalpool, fname);
- res->base = ptr;
+ res->ident = ptr;
+ res->base = ptr + sizeof(int) * (desc.item_num + 1);
res->size = desc.item_size;
res->num = desc.item_num;
res->globalpool = globalpool;
@@ -334,6 +362,8 @@
{
void *ptr;
+ int i;
+ int *ident;
if (!score) {
return APR_ENOSHMAVAIL;
@@ -342,32 +372,110 @@
return APR_ENOSHMAVAIL;
}
- ptr = score->base + score->size * id;
+ /* Check that it is not a free slot */
+ ident = score->ident;
+ for (i=0; i<score->num+1; i++) {
+ if (ident[i] == id)
+ return APR_NOTFOUND;
+ }
+
+ ptr = score->base + score->size * (id - 1);
if (!ptr) {
return APR_ENOSHMAVAIL;
}
- ptr = score->base + score->size * id;
*mem = ptr;
return APR_SUCCESS;
}
+static apr_status_t ap_slotmem_lock(ap_slotmem_t *s)
+{
+ return(apr_file_lock(s->global_lock, APR_FLOCK_EXCLUSIVE));
+}
+static apr_status_t ap_slotmem_unlock(ap_slotmem_t *s)
+{
+ return(apr_file_unlock(s->global_lock));
+}
+static apr_status_t ap_slotmem_alloc(ap_slotmem_t *score, int *item_id, void**mem)
+{
+ int ff;
+ int *ident;
+ apr_status_t rv;
+ ap_slotmem_lock(score);
+ ident = score->ident;
+ ff = ident[0];
+ if (ff > score->num) {
+ rv = APR_ENOMEM;
+ } else {
+ ident[0] = ident[ff];
+ ident[ff] = 0;
+ *item_id = ff;
+ *mem = score->base + score->size * (ff - 1);
+ rv = APR_SUCCESS;
+ }
+
+ ap_slotmem_unlock(score);
+ return rv;
+}
+static apr_status_t ap_slotmem_free(ap_slotmem_t *score, int item_id, void*mem)
+{
+ int ff;
+ int *ident;
+ apr_status_t rv;
+ if (item_id > score->num || item_id <=0) {
+ return APR_EINVAL;
+ } else {
+ ap_slotmem_lock(score);
+ ident = score->ident;
+ if (ident[item_id]) {
+ ap_slotmem_unlock(score);
+ return APR_SUCCESS;
+ }
+ ff = ident[0];
+ ident[0] = item_id;
+ ident[item_id] = ff;
+ ap_slotmem_unlock(score);
+ return APR_SUCCESS;
+ }
+}
+static int ap_slotmem_get_used(ap_slotmem_t *score, int *ids)
+{
+ int i, ret = 0;
+ int *ident;
+ ident = score->ident;
+ for (i=0; i<score->num+1; i++) {
+ if (ident[i] == 0) {
+ *ids = i;
+ ids++;
+ ret++;
+ }
+ }
+ return ret;
+}
+static int ap_slotmem_get_max_size(ap_slotmem_t *score)
+{
+ return score->num;
+}
static const slotmem_storage_method storage = {
&ap_slotmem_do,
&ap_slotmem_create,
&ap_slotmem_attach,
- &ap_slotmem_mem
+ &ap_slotmem_mem,
+ &ap_slotmem_alloc,
+ &ap_slotmem_free,
+ &ap_slotmem_lock,
+ &ap_slotmem_unlock,
+ &ap_slotmem_get_used,
+ &ap_slotmem_get_max_size
};
-/* make the storage usuable from outside */
-const slotmem_storage_method *sharedmem_getstorage()
+/* make the storage usuable from outside
+ * and initialise the global pool */
+const slotmem_storage_method *mem_getstorage(apr_pool_t *p, char *type)
{
+ if (globalpool == NULL)
+ globalpool = p;
return(&storage);
}
-/* initialise the global pool */
-void sharedmem_initglobalpool(apr_pool_t *p)
-{
- globalpool = p;
-}
/* Add the pool_clean routine */
void sharedmem_initialize_cleanup(apr_pool_t *p)
{
16 years, 7 months
JBoss Native SVN: r1600 - trunk/mod_cluster/native/mod_slotmem.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-14 05:07:33 -0400 (Wed, 14 May 2008)
New Revision: 1600
Added:
trunk/mod_cluster/native/mod_slotmem/.deps
trunk/mod_cluster/native/mod_slotmem/Makefile.in
trunk/mod_cluster/native/mod_slotmem/buildconf
trunk/mod_cluster/native/mod_slotmem/configure.in
trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
trunk/mod_cluster/native/mod_slotmem/sharedmem_util.h
Log:
shared memory handler.
Added: trunk/mod_cluster/native/mod_slotmem/.deps
===================================================================
Added: trunk/mod_cluster/native/mod_slotmem/Makefile.in
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/Makefile.in (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/Makefile.in 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,23 @@
+# Makefile.in for mod_proxy_cluster
+# copy the source in the httpd Apache source tree
+APACHE_BASE = @APACHE_BASE@
+top_builddir = @APACHE_BASE@
+# For .deps.
+builddir = @CLUSTER_BASE@
+# For the apache includes
+top_srcdir = @APACHE_BASE@
+
+include $(APACHE_BASE)/build/rules.mk
+SH_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CC) -I../include -prefer-pic -c $< && touch $@
+
+all: mod_sharedmem.so
+
+mod_sharedmem.so: mod_sharedmem.la
+ $(APACHE_BASE)/build/instdso.sh SH_LIBTOOL='$(LIBTOOL)' mod_sharedmem.la `pwd`
+
+mod_sharedmem.la: sharedmem_util.slo mod_sharedmem.slo
+ $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_sharedmem.lo sharedmem_util.lo
+
+clean:
+ rm -f *.o *.lo *.slo
+ rm -rf .libs
Added: trunk/mod_cluster/native/mod_slotmem/buildconf
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/buildconf (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/buildconf 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+rm -rf aclocal.m4 autom4te*.cache
+
+echo "Creating configure ..."
+### do some work to toss config.cache?
+if ${AUTOCONF:-autoconf}; then
+ :
+else
+ echo "autoconf failed"
+ exit 1
+fi
Property changes on: trunk/mod_cluster/native/mod_slotmem/buildconf
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/mod_cluster/native/mod_slotmem/configure.in
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/configure.in (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/configure.in 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,24 @@
+dnl configure for mod_manager
+dnl
+
+AC_INIT(mod_sharedmem.c)
+
+AC_MSG_CHECKING(for Apache httpd installation)
+AC_ARG_WITH(apache,
+[ --with-apache[=DIR] DIR is the apache base installation
+],
+[ if test "$withval" = "yes"; then
+ withval=/usr/local/etc/httpd
+ fi
+ if test "$withval" != "no"; then
+ APACHE_BASE=$withval
+ else
+ AC_MSG_ERROR(mod_manager need a valid apache location)
+ fi
+],
+[ AC_MSG_ERROR(Please use --with-apache[=DIR])])
+CLUSTER_BASE=`pwd`
+
+AC_SUBST(APACHE_BASE)
+AC_SUBST(CLUSTER_BASE)
+AC_OUTPUT(Makefile)
Added: trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/mod_sharedmem.c 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,72 @@
+/* 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.
+ */
+
+/* Memory handler for a shared memory divided in slot.
+ * This one uses shared memory.
+ */
+#define CORE_PRIVATE
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_shm.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
+
+#include "slotmem.h"
+#include "sharedmem_util.h"
+
+/* make sure the shared memory is cleaned */
+static int initialize_cleanup(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
+{
+ sharedmem_initialize_cleanup(p);
+ return OK;
+}
+
+static int pre_config(apr_pool_t *p, apr_pool_t *plog,
+ apr_pool_t *ptemp)
+{
+ apr_pool_t *global_pool;
+ apr_status_t rv;
+
+ rv = apr_pool_create(&global_pool, NULL);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
+ "Fatal error: unable to create global pool for shared slotmem");
+ return rv;
+ }
+ sharedmem_initglobalpool(global_pool);
+ return OK;
+}
+
+static void ap_sharedmem_register_hook(apr_pool_t *p)
+{
+ const slotmem_storage_method *storage = sharedmem_getstorage();
+ ap_register_provider(p, SLOTMEM_STORAGE, "shared", "0", storage);
+ ap_hook_post_config(initialize_cleanup, NULL, NULL, APR_HOOK_LAST);
+ ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
+module AP_MODULE_DECLARE_DATA sharedmem_module = {
+ STANDARD20_MODULE_STUFF,
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ NULL, /* command apr_table_t */
+ ap_sharedmem_register_hook /* register hooks */
+};
Added: trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,375 @@
+/* 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.
+ */
+
+/* Memory handler for a shared memory divided in slot.
+ * This one uses shared memory.
+ */
+#define CORE_PRIVATE
+
+#include "apr.h"
+#include "apr_file_io.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_shm.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
+
+#include "slotmem.h"
+#include "sharedmem_util.h"
+
+/* The description of the slots to reuse the slotmem */
+struct sharedslotdesc {
+ apr_size_t item_size;
+ int item_num;
+};
+
+struct ap_slotmem {
+ char *name;
+ apr_shm_t *shm;
+ void *base;
+ apr_size_t size;
+ int num;
+ apr_pool_t *globalpool;
+ struct ap_slotmem *next;
+};
+
+/* global pool and list of slotmem we are handling */
+static struct ap_slotmem *globallistmem = NULL;
+static apr_pool_t *globalpool = NULL;
+
+/*
+ * Persiste the slotmem in a file
+ * slotmem name and file name.
+ * anonymous : $server_root/logs/anonymous.slotmem
+ * :module.c : $server_root/logs/module.c.slotmem
+ * abs_name : $abs_name.slotmem
+ *
+ */
+static const char *store_filename(apr_pool_t *pool, const char *slotmemname)
+{
+ const char *storename;
+ const char *fname;
+ if (strcmp(slotmemname, "anonymous") == 0)
+ fname = ap_server_root_relative(pool, "logs/anonymous");
+ else if (slotmemname[0] == ':') {
+ const char *tmpname;
+ tmpname = apr_pstrcat(pool, "logs/", &slotmemname[1], NULL);
+ fname = ap_server_root_relative(pool, tmpname);
+ }
+ else {
+ fname = slotmemname;
+ }
+ storename = apr_pstrcat(pool, fname , ".slotmem", NULL);
+ return storename;
+}
+static void store_slotmem(ap_slotmem_t *slotmem)
+{
+ apr_file_t *fp;
+ apr_status_t rv;
+ apr_size_t nbytes;
+ const char *storename;
+
+ storename = store_filename(slotmem->globalpool, slotmem->name);
+
+ rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->globalpool);
+ if (APR_STATUS_IS_EEXIST(rv)) {
+ apr_file_remove(storename, slotmem->globalpool);
+ rv = apr_file_open(&fp, storename, APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, slotmem->globalpool);
+ }
+ if (rv != APR_SUCCESS) {
+ return;
+ }
+ nbytes = slotmem->size * slotmem->num;
+ apr_file_write(fp, slotmem->base, &nbytes);
+ apr_file_close(fp);
+}
+void restore_slotmem(void *ptr, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
+{
+ const char *storename;
+ apr_file_t *fp;
+ apr_size_t nbytes = item_size * item_num;
+ apr_status_t rv;
+
+ storename = store_filename(pool, name);
+ rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT, pool);
+ if (rv == APR_SUCCESS) {
+ apr_finfo_t fi;
+ if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
+ if (fi.size == nbytes) {
+ apr_file_read(fp, ptr, &nbytes);
+ }
+ else {
+ apr_file_close(fp);
+ apr_file_remove(storename, pool);
+ return;
+ }
+ }
+ apr_file_close(fp);
+ }
+}
+
+apr_status_t cleanup_slotmem(void *param)
+{
+ ap_slotmem_t **mem = param;
+ apr_status_t rv;
+ apr_pool_t *pool = NULL;
+
+ if (*mem) {
+ ap_slotmem_t *next = *mem;
+ pool = next->globalpool;
+ while (next) {
+ store_slotmem(next);
+ rv = apr_shm_destroy(next->shm);
+ next = next->next;
+ }
+ apr_pool_destroy(pool);
+ }
+ return APR_SUCCESS;
+}
+
+static apr_status_t ap_slotmem_do(ap_slotmem_t *mem, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool)
+{
+ int i;
+ void *ptr;
+
+ if (!mem) {
+ return APR_ENOSHMAVAIL;
+ }
+
+ ptr = mem->base;
+ for (i = 0; i < mem->num; i++) {
+ ptr = ptr + mem->size;
+ func((void *)ptr, data, pool);
+ }
+ return 0;
+}
+static apr_status_t ap_slotmem_create(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool)
+{
+ void *slotmem = NULL;
+ void *ptr;
+ struct sharedslotdesc desc;
+ ap_slotmem_t *res;
+ ap_slotmem_t *next = globallistmem;
+ const char *fname;
+ apr_status_t rv;
+
+ if (globalpool == NULL)
+ return APR_ENOSHMAVAIL;
+ if (name) {
+ if (name[0] == ':') {
+ fname = name;
+ }
+ else {
+ fname = ap_server_root_relative(pool, name);
+ }
+
+ /* first try to attach to existing slotmem */
+ if (next) {
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ return APR_SUCCESS;
+ }
+ if (!next->next) {
+ break;
+ }
+ next = next->next;
+ }
+ }
+ }
+ else {
+ fname = "anonymous";
+ }
+
+ /* first try to attach to existing shared memory */
+ res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
+ if (name && name[0] != ':') {
+ rv = apr_shm_attach(&res->shm, fname, globalpool);
+ }
+ else {
+ rv = APR_EINVAL;
+ }
+ if (rv == APR_SUCCESS) {
+ /* check size */
+ if (apr_shm_size_get(res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
+ apr_shm_detach(res->shm);
+ res->shm = NULL;
+ return APR_EINVAL;
+ }
+ ptr = apr_shm_baseaddr_get(res->shm);
+ memcpy(&desc, ptr, sizeof(desc));
+ if ( desc.item_size != item_size || desc.item_num != item_num) {
+ apr_shm_detach(res->shm);
+ res->shm = NULL;
+ return APR_EINVAL;
+ }
+ ptr = ptr + sizeof(desc);
+ }
+ else {
+ if (name && name[0] != ':') {
+ apr_shm_remove(fname, globalpool);
+ rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, globalpool);
+ }
+ else {
+ rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, globalpool);
+ }
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ ptr = apr_shm_baseaddr_get(res->shm);
+ desc.item_size = item_size;
+ desc.item_num = item_num;
+ memcpy(ptr, &desc, sizeof(desc));
+ ptr = ptr + sizeof(desc);
+ memset(ptr, 0, item_size * item_num);
+ restore_slotmem(ptr, fname, item_size, item_num, pool);
+ }
+
+ /* For the chained slotmem stuff */
+ res->name = apr_pstrdup(globalpool, fname);
+ res->base = ptr;
+ res->size = item_size;
+ res->num = item_num;
+ res->globalpool = globalpool;
+ res->next = NULL;
+ if (globallistmem==NULL) {
+ globallistmem = res;
+ }
+ else {
+ next->next = res;
+ }
+
+ *new = res;
+ return APR_SUCCESS;
+}
+static apr_status_t ap_slotmem_attach(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool)
+{
+ void *slotmem = NULL;
+ void *ptr;
+ ap_slotmem_t *res;
+ ap_slotmem_t *next = globallistmem;
+ struct sharedslotdesc desc;
+ const char *fname;
+ apr_status_t rv;
+
+ if (globalpool == NULL) {
+ return APR_ENOSHMAVAIL;
+ }
+ if (name) {
+ if (name[0] == ':') {
+ fname = name;
+ }
+ else {
+ fname = ap_server_root_relative(pool, name);
+ }
+ }
+ else {
+ return APR_ENOSHMAVAIL;
+ }
+
+ /* first try to attach to existing slotmem */
+ if (next) {
+ for (;;) {
+ if (strcmp(next->name, fname) == 0) {
+ /* we already have it */
+ *new = next;
+ *item_size = next->size;
+ *item_num = next->num;
+ return APR_SUCCESS;
+ }
+ if (!next->next)
+ break;
+ next = next->next;
+ }
+ }
+
+ /* first try to attach to existing shared memory */
+ res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
+ rv = apr_shm_attach(&res->shm, fname, globalpool);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+
+ /* Read the description of the slotmem */
+ ptr = apr_shm_baseaddr_get(res->shm);
+ memcpy(&desc, ptr, sizeof(desc));
+ ptr = ptr + sizeof(desc);
+
+ /* For the chained slotmem stuff */
+ res->name = apr_pstrdup(globalpool, fname);
+ res->base = ptr;
+ res->size = desc.item_size;
+ res->num = desc.item_num;
+ res->globalpool = globalpool;
+ res->next = NULL;
+ if (globallistmem==NULL) {
+ globallistmem = res;
+ }
+ else {
+ next->next = res;
+ }
+
+ *new = res;
+ *item_size = desc.item_size;
+ *item_num = desc.item_num;
+ return APR_SUCCESS;
+}
+static apr_status_t ap_slotmem_mem(ap_slotmem_t *score, int id, void**mem)
+{
+
+ void *ptr;
+
+ if (!score) {
+ return APR_ENOSHMAVAIL;
+ }
+ if (id<0 || id>score->num) {
+ return APR_ENOSHMAVAIL;
+ }
+
+ ptr = score->base + score->size * id;
+ if (!ptr) {
+ return APR_ENOSHMAVAIL;
+ }
+ ptr = score->base + score->size * id;
+ *mem = ptr;
+ return APR_SUCCESS;
+}
+
+static const slotmem_storage_method storage = {
+ &ap_slotmem_do,
+ &ap_slotmem_create,
+ &ap_slotmem_attach,
+ &ap_slotmem_mem
+};
+
+/* make the storage usuable from outside */
+const slotmem_storage_method *sharedmem_getstorage()
+{
+ return(&storage);
+}
+/* initialise the global pool */
+void sharedmem_initglobalpool(apr_pool_t *p)
+{
+ globalpool = p;
+}
+/* Add the pool_clean routine */
+void sharedmem_initialize_cleanup(apr_pool_t *p)
+{
+ apr_pool_cleanup_register(p, &globallistmem, cleanup_slotmem, apr_pool_cleanup_null);
+}
Added: trunk/mod_cluster/native/mod_slotmem/sharedmem_util.h
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/sharedmem_util.h (rev 0)
+++ trunk/mod_cluster/native/mod_slotmem/sharedmem_util.h 2008-05-14 09:07:33 UTC (rev 1600)
@@ -0,0 +1,20 @@
+/* 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.
+ */
+
+/* Memory handler for a shared memory divided in slot.
+ * This one uses shared memory.
+ */
+const slotmem_storage_method *sharedmem_getstorage();
16 years, 7 months
JBoss Native SVN: r1599 - trunk/mod_cluster/native/include.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-14 03:44:51 -0400 (Wed, 14 May 2008)
New Revision: 1599
Added:
trunk/mod_cluster/native/include/slotmem.h
Log:
Add missing include.
Added: trunk/mod_cluster/native/include/slotmem.h
===================================================================
--- trunk/mod_cluster/native/include/slotmem.h (rev 0)
+++ trunk/mod_cluster/native/include/slotmem.h 2008-05-14 07:44:51 UTC (rev 1599)
@@ -0,0 +1,99 @@
+/* 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.
+ */
+
+#ifndef SLOTMEM_H
+#define SLOTMEM_H
+
+/* Memory handler for a shared memory divided in slot.
+ */
+/**
+ * @file slotmem.h
+ * @brief Memory Slot Extension Storage Module for Apache
+ *
+ * @defgroup MEM mem
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_shm.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
+
+#define SLOTMEM_STORAGE "slotmem"
+
+typedef struct ap_slotmem ap_slotmem_t;
+
+/**
+ * callback function used for slotmem.
+ * @param mem is the memory associated with a worker.
+ * @param data is what is passed to slotmem.
+ * @param pool is pool used to create scoreboard
+ * @return APR_SUCCESS if all went well
+ */
+typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void *data, apr_pool_t *pool);
+
+struct slotmem_storage_method {
+/**
+ * call the callback on all worker slots
+ * @param s ap_slotmem_t to use.
+ * @param funct callback function to call for each element.
+ * @param data parameter for the callback function.
+ * @param pool is pool used to create scoreboard
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) (* slotmem)(ap_slotmem_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
+
+/**
+ * create a new slotmem with each item size is item_size.
+ * This would create shared memory, basically.
+ * @param pointer to store the address of the scoreboard.
+ * @param name is a key used for debugging and in mod_status output or allow another process to share this space.
+ * @param item_size size of each item
+ * @param item_num number of item to create.
+ * @param pool is pool used to create scoreboard
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) (* ap_slotmem_create)(ap_slotmem_t **new, const char *name, apr_size_t item_size, int item_num, apr_pool_t *pool);
+
+/**
+ * attach to an existing slotmem.
+ * This would attach to shared memory, basically.
+ * @param pointer to store the address of the scoreboard.
+ * @param name is a key used for debugging and in mod_status output or allow another process to share this space.
+ * @param item_size size of each item
+ * @param item_num max number of item.
+ * @param pool is pool to memory allocate.
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) (* ap_slotmem_attach)(ap_slotmem_t **new, const char *name, apr_size_t *item_size, int *item_num, apr_pool_t *pool);
+/**
+ * get the memory associated with this worker slot.
+ * @param s ap_slotmem_t to use.
+ * @param item_id item to return for 0 to item_num
+ * @param mem address to store the pointer to the slot
+ * @return APR_SUCCESS if all went well
+ */
+AP_DECLARE(apr_status_t) (* ap_slotmem_mem)(ap_slotmem_t *s, int item_id, void**mem);
+};
+
+typedef struct slotmem_storage_method slotmem_storage_method;
+
+#endif /*SLOTMEM_H*/
16 years, 7 months
JBoss Native SVN: r1598 - trunk/mod_cluster/native/include.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-14 03:42:15 -0400 (Wed, 14 May 2008)
New Revision: 1598
Modified:
trunk/mod_cluster/native/include/balancer.h
trunk/mod_cluster/native/include/context.h
trunk/mod_cluster/native/include/host.h
trunk/mod_cluster/native/include/node.h
Log:
Add storage as parameter.
Modified: trunk/mod_cluster/native/include/balancer.h
===================================================================
--- trunk/mod_cluster/native/include/balancer.h 2008-05-13 14:59:47 UTC (rev 1597)
+++ trunk/mod_cluster/native/include/balancer.h 2008-05-14 07:42:15 UTC (rev 1598)
@@ -116,7 +116,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) get_mem_balancer(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) get_mem_balancer(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* create a shared balancer table
* @param name to use to create the table.
@@ -124,7 +124,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) create_mem_balancer(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) create_mem_balancer(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* provider for the mod_proxy_cluster or mod_jk modules.
Modified: trunk/mod_cluster/native/include/context.h
===================================================================
--- trunk/mod_cluster/native/include/context.h 2008-05-13 14:59:47 UTC (rev 1597)
+++ trunk/mod_cluster/native/include/context.h 2008-05-14 07:42:15 UTC (rev 1598)
@@ -118,7 +118,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) get_mem_context(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) get_mem_context(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* create a shared context table
* @param name to use to create the table.
@@ -126,7 +126,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) create_mem_context(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) create_mem_context(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* provider for the mod_proxy_cluster or mod_jk modules.
Modified: trunk/mod_cluster/native/include/host.h
===================================================================
--- trunk/mod_cluster/native/include/host.h 2008-05-13 14:59:47 UTC (rev 1597)
+++ trunk/mod_cluster/native/include/host.h 2008-05-14 07:42:15 UTC (rev 1598)
@@ -111,7 +111,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) get_mem_host(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) get_mem_host(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* create a shared host table
* @param name to use to create the table.
@@ -119,7 +119,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) create_mem_host(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) create_mem_host(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* provider for the mod_proxy_cluster or mod_jk modules.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-05-13 14:59:47 UTC (rev 1597)
+++ trunk/mod_cluster/native/include/node.h 2008-05-14 07:42:15 UTC (rev 1598)
@@ -137,7 +137,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) get_mem_node(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) get_mem_node(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* create a shared node table
* @param name to use to create the table.
@@ -145,7 +145,7 @@
* @param p pool to use for allocations.
* @return address of struct used to access the table.
*/
-APR_DECLARE(mem_t *) create_mem_node(char *string, int *num, apr_pool_t *p);
+APR_DECLARE(mem_t *) create_mem_node(char *string, int *num, apr_pool_t *p, slotmem_storage_method *storage);
/**
* provider for the mod_proxy_cluster or mod_jk modules.
16 years, 7 months
JBoss Native SVN: r1597 - trunk/mod_cluster/native/include.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-13 10:59:47 -0400 (Tue, 13 May 2008)
New Revision: 1597
Added:
trunk/mod_cluster/native/include/balancer.h
trunk/mod_cluster/native/include/context.h
trunk/mod_cluster/native/include/host.h
trunk/mod_cluster/native/include/node.h
Log:
Include to handle the shared tables of mod_cluster.
Added: trunk/mod_cluster/native/include/balancer.h
===================================================================
--- trunk/mod_cluster/native/include/balancer.h (rev 0)
+++ trunk/mod_cluster/native/include/balancer.h 2008-05-13 14:59:47 UTC (rev 1597)
@@ -0,0 +1,151 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef BALANCER_H
+#define BALANCER_H
+
+/**
+ * @file balancer.h
+ * @brief balancer description Storage Module for Apache
+ *
+ * @defgroup MEM balancers
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define BALANCEREXE ".balancers"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+/* status of the balancer as read/store in httpd. */
+struct balancerinfo {
+ char balancer[40]; /* Name of the balancer */
+ int StickySession; /* 0 : Don't use, 1: Use it */
+ char StickySessionCookie[30];
+ char StickySessionPath[30];
+ int StickySessionRemove; /* 0 : Don't remove, 1: Remove it */
+ int StickySessionForce; /* 0: Don't force, 1: return error */
+ int Timeout;
+ int Maxattempts;
+
+ unsigned long updatetime; /* time of last received message */
+ int id; /* id in table */
+};
+typedef struct balancerinfo balancerinfo_t;
+
+
+/**
+ * Insert(alloc) and update a balancer record in the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+APR_DECLARE(apr_status_t) insert_update_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/**
+ * read a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to read from the shared table.
+ * @return address of the read balancer or NULL if error.
+ */
+APR_DECLARE(balancerinfo_t *) read_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/**
+ * get a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer address of the balancer read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_balancer(mem_t *s, balancerinfo_t **balancer, int ids);
+
+/**
+ * remove(free) a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/*
+ * get the ids for the used (not free) balancers in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_balancer(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_balancer(mem_t *s);
+
+/**
+ * attach to the shared balancer table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) get_mem_balancer(char *string, int *num, apr_pool_t *p);
+/**
+ * create a shared balancer table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) create_mem_balancer(char *string, int *num, apr_pool_t *p);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct balancer_storage_method {
+/**
+ * the balancer corresponding to the ident
+ * @param ids ident of the balancer to read.
+ * @param balancer address of pointer to return the balancer.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* read_balancer)(int ids, balancerinfo_t **balancer);
+/**
+ * read the list of ident of used balancers.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(int) (* get_ids_used_balancer)(int *ids);
+/**
+ * read the max number of balancers in the shared table
+ */
+APR_DECLARE(int) (*get_max_size_balancer)();
+};
+#endif /*BALANCER_H*/
Added: trunk/mod_cluster/native/include/context.h
===================================================================
--- trunk/mod_cluster/native/include/context.h (rev 0)
+++ trunk/mod_cluster/native/include/context.h 2008-05-13 14:59:47 UTC (rev 1597)
@@ -0,0 +1,153 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+/**
+ * @file context.h
+ * @brief context description Storage Module for Apache
+ *
+ * @defgroup MEM contexts
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define CONTEXTEXE ".contexts"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+/* Status of the application */
+#define ENABLED 1
+#define DISABLED 2
+#define STOPPED 3
+#define REMOVE 4 /* That status not stored but used by the logic to remove the entry */
+
+/* status of the context as read/store in httpd. */
+struct contextinfo {
+ char context[40]; /* Context where the application is mapped. */
+ int vhost; /* id of the correspond virtual host in hosts table */
+ int node; /* id of the correspond node in nodes table */
+ int status; /* status: ENABLED/DISABLED/STOPPED */
+
+ unsigned long updatetime; /* time of last received message */
+ int id; /* id in table */
+};
+typedef struct contextinfo contextinfo_t;
+
+
+/**
+ * Insert(alloc) and update a context record in the shared table
+ * @param pointer to the shared table.
+ * @param context context to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+APR_DECLARE(apr_status_t) insert_update_context(mem_t *s, contextinfo_t *context);
+
+/**
+ * read a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context context to read from the shared table.
+ * @return address of the read context or NULL if error.
+ */
+APR_DECLARE(contextinfo_t *) read_context(mem_t *s, contextinfo_t *context);
+
+/**
+ * get a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context address of the context read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_context(mem_t *s, contextinfo_t **context, int ids);
+
+/**
+ * remove(free) a context record from the shared table
+ * @param pointer to the shared table.
+ * @param context context to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_context(mem_t *s, contextinfo_t *context);
+
+/*
+ * get the ids for the used (not free) contexts in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of context existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_context(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_context(mem_t *s);
+
+/**
+ * attach to the shared context table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) get_mem_context(char *string, int *num, apr_pool_t *p);
+/**
+ * create a shared context table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) create_mem_context(char *string, int *num, apr_pool_t *p);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct context_storage_method {
+/**
+ * the context corresponding to the ident
+ * @param ids ident of the context to read.
+ * @param context address of pointer to return the context.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* read_context)(int ids, contextinfo_t **context);
+/**
+ * read the list of ident of used contexts.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(int) (* get_ids_used_context)(int *ids);
+/**
+ * read the max number of contexts in the shared table
+ */
+APR_DECLARE(int) (*get_max_size_context)();
+};
+#endif /*CONTEXT_H*/
Added: trunk/mod_cluster/native/include/host.h
===================================================================
--- trunk/mod_cluster/native/include/host.h (rev 0)
+++ trunk/mod_cluster/native/include/host.h 2008-05-13 14:59:47 UTC (rev 1597)
@@ -0,0 +1,146 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef HOST_H
+#define HOST_H
+
+/**
+ * @file host.h
+ * @brief host description Storage Module for Apache
+ *
+ * @defgroup MEM hosts
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define HOSTEXE ".hosts"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+/* status of the host as read/store in httpd. */
+struct hostinfo {
+ char host[40]; /* Alias element of the virtual host */
+ int vhost; /* id of the correspond virtual host */
+ int node; /* id of the node containing the virtual host */
+
+ unsigned long updatetime; /* time of last received message */
+ int id; /* id in table */
+};
+typedef struct hostinfo hostinfo_t;
+
+
+/**
+ * Insert(alloc) and update a host record in the shared table
+ * @param pointer to the shared table.
+ * @param host host to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+APR_DECLARE(apr_status_t) insert_update_host(mem_t *s, hostinfo_t *host);
+
+/**
+ * read a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host host to read from the shared table.
+ * @return address of the read host or NULL if error.
+ */
+APR_DECLARE(hostinfo_t *) read_host(mem_t *s, hostinfo_t *host);
+
+/**
+ * get a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host address of the host read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_host(mem_t *s, hostinfo_t **host, int ids);
+
+/**
+ * remove(free) a host record from the shared table
+ * @param pointer to the shared table.
+ * @param host host to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_host(mem_t *s, hostinfo_t *host);
+
+/*
+ * get the ids for the used (not free) hosts in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of host existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_host(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_host(mem_t *s);
+
+/**
+ * attach to the shared host table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) get_mem_host(char *string, int *num, apr_pool_t *p);
+/**
+ * create a shared host table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) create_mem_host(char *string, int *num, apr_pool_t *p);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct host_storage_method {
+/**
+ * the host corresponding to the ident
+ * @param ids ident of the host to read.
+ * @param host address of pointer to return the host.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* read_host)(int ids, hostinfo_t **host);
+/**
+ * read the list of ident of used hosts.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(int) (* get_ids_used_host)(int *ids);
+/**
+ * read the max number of hosts in the shared table
+ */
+APR_DECLARE(int) (*get_max_size_host)();
+};
+#endif /*HOST_H*/
Added: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h (rev 0)
+++ trunk/mod_cluster/native/include/node.h 2008-05-13 14:59:47 UTC (rev 1597)
@@ -0,0 +1,172 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef NODE_H
+#define NODE_H
+
+/**
+ * @file node.h
+ * @brief node description Storage Module for Apache
+ *
+ * @defgroup MEM nodes
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define NODEEXE ".nodes"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+/* configuration of the node received from jboss cluster. */
+struct nodemess {
+ char balancer[40]; /* name of the balancer */
+ char JVMRoute[20];
+ char Domain[20];
+ char Host[64];
+ char Port[7];
+ char Type[6];
+ int reversed; /* 1 : reversed... 0 : normal */
+
+ /* node conf part */
+ int flushpackets;
+ int flushwait;
+ int ping;
+ int smax;
+ int ttl
+
+ char strtime[8]; /* date when send by the node */
+
+ /* part updated in httpd */
+ int id; /* id in table and worker id */
+};
+typedef struct nodemess nodemess_t;
+
+#define SIZEOFSCORE 200 /* size of the proxy_worker_stat structure */
+
+/* status of the node as read/store in httpd. */
+struct nodeinfo {
+ /* config from jboss/tomcat */
+ nodemess_t mess;
+ /* filled by httpd */
+ unsigned long updatetime; /* time of last received message */
+ int offset; /* offset to the proxy_worker_stat structure */
+ char stat[SIZEOFSCORE]; /* to store the status */
+};
+typedef struct nodeinfo nodeinfo_t;
+
+
+/**
+ * Insert(alloc) and update a node record in the shared table
+ * @param pointer to the shared table.
+ * @param node node to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+APR_DECLARE(apr_status_t) insert_update_node(mem_t *s, nodeinfo_t *node, int *id);
+
+/**
+ * read a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node node to read from the shared table.
+ * @return address of the read node or NULL if error.
+ */
+APR_DECLARE(nodeinfo_t *) read_node(mem_t *s, nodeinfo_t *node);
+
+/**
+ * get a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node address of the node read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_node(mem_t *s, nodeinfo_t **node, int ids);
+
+/**
+ * remove(free) a node record from the shared table
+ * @param pointer to the shared table.
+ * @param node node to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_node(mem_t *s, nodeinfo_t *node);
+
+/*
+ * get the ids for the used (not free) nodes in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of node existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_node(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_node(mem_t *s);
+
+/**
+ * attach to the shared node table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) get_mem_node(char *string, int *num, apr_pool_t *p);
+/**
+ * create a shared node table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) create_mem_node(char *string, int *num, apr_pool_t *p);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct node_storage_method {
+/**
+ * the node corresponding to the ident
+ * @param ids ident of the node to read.
+ * @param node address of pointer to return the node.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* read_node)(int ids, nodeinfo_t **node);
+/**
+ * read the list of ident of used nodes.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(int) (* get_ids_used_node)(int *ids);
+/**
+ * read the max number of nodes in the shared table
+ */
+APR_DECLARE(int) (*get_max_size_node)();
+};
+#endif /*NODE_H*/
16 years, 7 months
JBoss Native SVN: r1596 - in trunk: mod_cluster and 3 other directories.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-13 08:58:49 -0400 (Tue, 13 May 2008)
New Revision: 1596
Added:
trunk/mod_cluster/
trunk/mod_cluster/docs/
trunk/mod_cluster/docs/README
trunk/mod_cluster/native/
trunk/mod_cluster/native/include/
trunk/mod_cluster/native/mod_manager/
trunk/mod_cluster/native/mod_proxy_cluster/
trunk/mod_cluster/native/mod_slotmem/
trunk/mod_cluster/test/
trunk/mod_cluster/test/java/
trunk/mod_cluster/test/native/
Log:
Directory structure.
Added: trunk/mod_cluster/docs/README
===================================================================
--- trunk/mod_cluster/docs/README (rev 0)
+++ trunk/mod_cluster/docs/README 2008-05-13 12:58:49 UTC (rev 1596)
@@ -0,0 +1,10 @@
+This is mod_cluster code (See http://wiki.jboss.org/wiki/ModClusterDesign).
+It is organized in the following subdirectories:
+docs (Documentation)
+native/mod_manager (manager part)
+native/mod_proxy_cluster (balancer for mod_proxy)
+native/include ( common includes like the table access layer API)
+native/mod_slotmem (shared memory provider).
+test/java (test utilities using httpclient).
+test/native (native test utilities).
+
16 years, 7 months