SessionLog.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _eyedb_sesslog_
00026 #define _eyedb_sesslog_
00027 
00028 #include <eyedbconfig.h>
00029 
00030 #include <eyedb/eyedb.h>
00031 #include <eyedbsm/eyedbsm.h>
00032 #include "eyedbsm/transaction.h"
00033 #include "eyedbsm/mutex.h"
00034 #include <eyedblib/m_mem.h>
00035 
00036 namespace eyedb {
00037 
00038   class SessionHead;
00039   class ClientInfo;
00040 
00041   class ClientSessionLog {
00042 
00043   public:
00044     ClientSessionLog(ClientInfo *);
00045 
00046     ClientInfo *getClientInfo() {return clinfo;}
00047 
00048     void addDatabase(const char *name, const char *userauth, int flags);
00049     void suppressDatabase(const char *name, const char *userauth, int flags);
00050 
00051     ~ClientSessionLog();
00052 
00053   private:
00054     ClientInfo *clinfo;
00055   };
00056 
00057   class SessionLog {
00058 
00059   public:
00060     // open constructor
00061     SessionLog(const char *host, const char *port, const char *logdir,
00062                Bool writing);
00063 
00064     // create constructor
00065     SessionLog(const char *logdir, const char *version,
00066                int nports, const char *hosts[], const char *ports[],
00067                const char *voldir,
00068                const char *logdev, int loglevel);
00069 
00070     SessionLog(const SessionLog &);
00071 
00072     Status add(const char *hostname, const char *portname,
00073                const char *username, const char *progname, int pid,
00074                ClientSessionLog *&);
00075 
00076     Bool isUp() const;
00077 
00078     void suppress(ClientSessionLog *);
00079 
00080     Status stopServers(Bool force);
00081 
00082     void display(FILE *fd, Bool nolock = False);
00083 
00084     void remove();
00085 
00086     Status getStatus() const {return status;}
00087 
00088     static void release();
00089 
00090     ~SessionLog();
00091 
00092   private:
00093     void init(const char *host, const char *port, const char *logdir,
00094               Bool writing);
00095     char *host;
00096     char *port;
00097     char *logdir;
00098     eyedbsm::XMHandle *xm_connlog;
00099     m_Map *m_connlog;
00100     char *addr_connlog;
00101     SessionHead *connhead;
00102     Status status;
00103     Bool islocked;
00104     static SessionLog *sesslog;
00105     int file_cnt;
00106     char **files;
00107     void *vd;
00108 #ifdef HAVE_SEMAPHORE_POLICY_SYSV_IPC
00109     Status init_sems();
00110 #endif
00111 
00112     Status openRealize(const char *host, const char *port, const char *logdir,
00113                        Bool create, Bool writing);
00114     char *makeFile(const char *host, const char *port, const char *_logdir);
00115     int get_nb_clients();
00116   };
00117 
00118 }
00119 
00120 #endif

Generated on Mon Dec 22 18:16:08 2008 for eyedb by  doxygen 1.5.3