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*/