LogService
libdadi: utility tools for distributed applications
|
00001 /****************************************************************************/ 00002 /* Header corresponding to the LogComponentComponent interface */ 00003 /* */ 00004 /* Author(s): */ 00005 /* - Georg Hoesch (hoesch@in.tum.de) */ 00006 /* - Cyrille Pontvieux (cyrille.pontvieux@edu.univ-fcomte.fr) */ 00007 /* */ 00008 /* This file is part of DIET . */ 00009 /* */ 00010 /* Copyright (C) 2000-2003 ENS Lyon, LIFC, INSA, INRIA and SysFera (2000) */ 00011 /* */ 00012 /* - Frederic.Desprez@ens-lyon.fr (Project Manager) */ 00013 /* - Eddy.Caron@ens-lyon.fr (Technical Manager) */ 00014 /* - Tech@sysfera.com (Maintainer and Technical Support) */ 00015 /* */ 00016 /* This software is a computer program whose purpose is to provide an */ 00017 /* distributed logging services. */ 00018 /* */ 00019 /* */ 00020 /* This software is governed by the CeCILL license under French law and */ 00021 /* abiding by the rules of distribution of free software. You can use, */ 00022 /* modify and/ or redistribute the software under the terms of the CeCILL */ 00023 /* license as circulated by CEA, CNRS and INRIA at the following URL */ 00024 /* "http://www.cecill.info". */ 00025 /* */ 00026 /* As a counterpart to the access to the source code and rights to copy, */ 00027 /* modify and redistribute granted by the license, users are provided */ 00028 /* only with a limited warranty and the software's author, the holder */ 00029 /* of the economic rights, and the successive licensors have only */ 00030 /* limited liability. */ 00031 /* */ 00032 /* In this respect, the user's attention is drawn to the risks */ 00033 /* associated with loading, using, modifying and/or developing or */ 00034 /* reproducing the software by the user in light of its specific status */ 00035 /* of free software, that may mean that it is complicated to */ 00036 /* manipulate, and that also therefore means that it is reserved for */ 00037 /* developers and experienced professionals having in-depth computer */ 00038 /* knowledge. Users are therefore encouraged to load and test the */ 00039 /* software's suitability as regards their requirements in conditions */ 00040 /* enabling the security of their systems and/or data to be ensured and, */ 00041 /* more generally, to use and operate it in the same conditions as */ 00042 /* regards security. */ 00043 /* */ 00044 /* The fact that you are presently reading this means that you have had */ 00045 /* knowledge of the CeCILL license and that you accept its terms. */ 00046 /* */ 00047 /****************************************************************************/ 00048 /* $Id$ 00049 * $Log$ 00050 * Revision 1.4 2010/12/13 12:21:14 kcoulomb 00051 * Clean types 00052 * 00053 * Revision 1.3 2010/12/03 12:40:27 kcoulomb 00054 * MAJ log to use forwarders 00055 * 00056 * Revision 1.2 2010/11/10 02:27:44 kcoulomb 00057 * Update the log to use the forwarder. 00058 * Programm run without launching forwarders but fails with forwarder. 00059 * 00060 * Revision 1.1 2004/01/09 11:07:12 ghoesch 00061 * Restructured the whole LogService source tree. 00062 * Added autotools make process. Cleaned up code. 00063 * Removed some testers. Ready to release. 00064 * 00065 ***************************************************************************/ 00066 00067 #ifndef _LOGCENTRALCOMPONENT_IMPL_HH_ 00068 #define _LOGCENTRALCOMPONENT_IMPL_HH_ 00069 00070 #include "LogTypes.hh" 00071 #include "LogComponent.hh" 00072 #include "ComponentList.hh" 00073 #include "FilterManagerInterface.hh" 00074 #include "TimeBuffer.hh" 00075 #include "FullLinkedList.hh" 00076 00077 #include "CorbaLogForwarder.hh" 00078 00079 00100 class LastPing { 00101 public: 00102 LastPing(); 00103 00104 LastPing(LastPing& newLastPing); 00105 00106 ~LastPing(); 00107 00108 LastPing& 00109 operator=(LastPing& newLastPing); 00110 00111 char* name; 00112 log_time_t time; 00113 log_time_t timeDifference; 00114 }; 00115 00116 typedef FullLinkedList<LastPing> LastPings; 00117 00118 class LogCentralComponent_impl 00119 : public POA_LogCentralComponent, 00120 public PortableServer::RefCountServantBase { 00121 public: 00122 LogCentralComponent_impl(ComponentList* componentList, 00123 FilterManagerInterface* filterManager, 00124 TimeBuffer* timeBuffer); 00125 00126 ~LogCentralComponent_impl(); 00127 00128 void 00129 test(); 00130 00151 CORBA::Short 00152 connectComponent(char*& componentName, 00153 const char* componentHostname, 00154 const char* message, 00155 const char* compConfigurator, 00156 const log_time_t& componentTime, 00157 tag_list_t& initialConfig); 00158 00159 00170 CORBA::Short 00171 disconnectComponent(const char* componentName, const char* message); 00172 00173 00178 void 00179 sendBuffer(const log_msg_buf_t& buffer); 00180 00186 bool 00187 isComponentExists(const char* name, ComponentList::ReadIterator* it); 00188 00195 void 00196 ping(const char* componentName); 00197 00203 void 00204 synchronize(const char* componentName, const log_time_t& componentTime); 00205 00209 // char* 00210 // getHostnameOf(const char* toto); 00211 00212 private: 00218 char* 00219 getGeneratedName(const char* hostname, ComponentList::ReadIterator* it); 00220 00221 class AliveCheckThread:public omni_thread { 00222 public: 00223 explicit AliveCheckThread(LogCentralComponent_impl* LCC); 00224 00225 ~AliveCheckThread(); 00229 void 00230 startThread(); 00234 void 00235 stopThread(); 00236 00237 private: 00238 void* 00239 run_undetached(void* params); 00240 00241 LogCentralComponent_impl* LCC; 00242 bool threadRunning; 00243 }; 00244 00245 friend class LogCentralComponent_impl::AliveCheckThread; 00246 00247 private: 00248 ComponentList* componentList; 00249 FilterManagerInterface* filterManager; 00250 TimeBuffer* timeBuffer; 00251 LastPings* lastPings; 00252 AliveCheckThread* aliveCheckThread; 00253 }; 00254 00255 00256 00257 class LogCentralComponentFwdrImpl 00258 : public POA_LogCentralComponentFwdr, 00259 public PortableServer::RefCountServantBase { 00260 public: 00261 LogCentralComponentFwdrImpl(CorbaLogForwarder_ptr fwdr, const char *objName); 00262 00263 ~LogCentralComponentFwdrImpl(); 00264 00265 CORBA::Short 00266 connectComponent(char*& componentName, 00267 const char* componentHostname, 00268 const char* message, 00269 const char* compConfigurator, 00270 const log_time_t& componentTime, 00271 tag_list_t& initialConfig); 00272 00273 CORBA::Short 00274 disconnectComponent(const char* componentName, const char* message); 00275 00276 void 00277 sendBuffer(const log_msg_buf_t& buffer); 00278 00279 void 00280 ping(const char* componentName); 00281 00282 00283 void 00284 synchronize(const char* componentName, const log_time_t& componentTime); 00285 00286 void 00287 test(); 00288 00289 protected: 00290 CorbaLogForwarder_ptr forwarder; 00291 char* objName; 00292 00293 private: 00294 ComponentList* componentList; 00295 FilterManagerInterface* filterManager; 00296 TimeBuffer* timeBuffer; 00297 LastPings* lastPings; 00298 }; 00299 00300 00301 class ComponentConfiguratorFwdr_impl 00302 : public POA_ComponentConfiguratorFwdr, 00303 public PortableServer::RefCountServantBase { 00304 public: 00305 ComponentConfiguratorFwdr_impl(CorbaLogForwarder_ptr fwdr, 00306 const char* objName); 00307 00308 ~ComponentConfiguratorFwdr_impl(); 00309 00310 void 00311 setTagFilter(const tag_list_t& tagList); 00312 00313 void 00314 addTagFilter(const tag_list_t& tagList); 00315 00316 void 00317 removeTagFilter(const tag_list_t& tagList); 00318 00319 void 00320 test(); 00321 00322 protected: 00323 CorbaLogForwarder_ptr forwarder; 00324 char* objName; 00325 }; 00326 00327 #endif