LogService
libdadi: utility tools for distributed applications
LogForwarder.hh
1 /****************************************************************************/
2 /* Log forwarder implementation */
3 /* */
4 /* Author(s): */
5 /* - Gael Le Mahec (gael.le.mahec@ens-lyon.fr) */
6 /* */
7 /* This file is part of DIET . */
8 /* */
9 /* Copyright (C) 2000-2003 ENS Lyon, LIFC, INSA, INRIA and SysFera (2000) */
10 /* */
11 /* - Frederic.Desprez@ens-lyon.fr (Project Manager) */
12 /* - Eddy.Caron@ens-lyon.fr (Technical Manager) */
13 /* - Tech@sysfera.com (Maintainer and Technical Support) */
14 /* */
15 /* This software is a computer program whose purpose is to provide an */
16 /* distributed logging services. */
17 /* */
18 /* */
19 /* This software is governed by the CeCILL license under French law and */
20 /* abiding by the rules of distribution of free software. You can use, */
21 /* modify and/ or redistribute the software under the terms of the CeCILL */
22 /* license as circulated by CEA, CNRS and INRIA at the following URL */
23 /* "http://www.cecill.info". */
24 /* */
25 /* As a counterpart to the access to the source code and rights to copy, */
26 /* modify and redistribute granted by the license, users are provided */
27 /* only with a limited warranty and the software's author, the holder */
28 /* of the economic rights, and the successive licensors have only */
29 /* limited liability. */
30 /* */
31 /* In this respect, the user's attention is drawn to the risks */
32 /* associated with loading, using, modifying and/or developing or */
33 /* reproducing the software by the user in light of its specific status */
34 /* of free software, that may mean that it is complicated to */
35 /* manipulate, and that also therefore means that it is reserved for */
36 /* developers and experienced professionals having in-depth computer */
37 /* knowledge. Users are therefore encouraged to load and test the */
38 /* software's suitability as regards their requirements in conditions */
39 /* enabling the security of their systems and/or data to be ensured and, */
40 /* more generally, to use and operate it in the same conditions as */
41 /* regards security. */
42 /* */
43 /* The fact that you are presently reading this means that you have had */
44 /* knowledge of the CeCILL license and that you accept its terms. */
45 /* */
46 /****************************************************************************/
47 
48 #ifndef LOGFORWARDER_HH
49 #define LOGFORWARDER_HH
50 
51 #include <list>
52 #include <map>
53 #include <string>
54 #include <omnithread.h>
55 #include "CorbaLogForwarder.hh"
56 #include "commonLogTypes.hh"
57 
58 
60  public PortableServer::RefCountServantBase {
61 public:
62  ~LogForwarder();
63 
64  explicit LogForwarder(const std::string& name);
65  /* DIET object factory methods. */
66 
68  getCompoConf(const char* name);
69 
71  getToolMsgReceiver(const char* name);
72 
74  getLogCentralComponent(const char* name);
75 
77  getLogCentralTool(const char* name);
78 
79  /* Common methods implementations. */
80  void
81  ping(const char* compoName, const char* objName);
82 
83  /* To determine if the call is from another forwarder and
84  * modify the object name.
85  */
86  static bool
87  remoteCall(std::string& objName);
88 
89  /* CORBA remote management implementation. */
90  void
91  bind(const char* objName, const char* ior);
92 
93  void
94  unbind(const char* objName);
95 
97  getBindings(const char* ctxt);
98 
99  /* Connect the peer forwarder. */
100  void
101  connectPeer(const char* ior, const char* host, const ::CORBA::Long port);
102 
103  /* Set this forwarder peer object (not CORBA). */
104  void
105  setPeer(CorbaLogForwarder_ptr peer);
106 
107  CorbaLogForwarder_var
108  getPeer();
109 
110  char*
111  getIOR();
112 
113  /* Object caches management functions. */
114  void
115  removeObjectFromCache(const std::string& name);
116 
117  void
118  cleanCaches();
119 
120  char*
121  getName();
122 
123  char*
124  getPeerName();
125 
126  char*
127  getHost();
128 
129  char*
130  getPeerHost();
131 
132  LogSeqString* routeTree();
133 
134  /* Utility function. */
135  std::list<std::string>
136  otherForwarders() const;
137 
138  /* LogComponentFwdr implementation. */
139  void
140  setTagFilter(const ::tag_list_t& tagList, const char* objName);
141 
142  void
143  addTagFilter(const ::tag_list_t& tagList, const char* objName);
144 
145  void
146  removeTagFilter(const ::tag_list_t& tagList, const char* objName);
147 
148  void
149  test(const char* objName);
150 
158  short
159  disconnectTool(const char* toolName, const char* objName);
160 
168  tag_list_t*
169  getDefinedTags(const char* objName);
170 
178  getDefinedComponents(const char* objName);
179 
180 
188  short
189  addFilter(const char* toolName, const filter_t& filter, const char* objName);
190 
191 
192  void
193  sendMsg(const log_msg_buf_t& msgBuf, const char* objName);
194 
204  short
205  connectTool(char*& toolName, const char* msgReceiver, const char* objName);
206 
207  short
208  flushAllFilters(const char* toolName, const char* objName);
209 
210  short
211  removeFilter(const char* toolName, const char* filterName,
212  const char* objName);
213 
214 
215 
216  /* Utility fonctions to extract name & context from context/name. */
217  static std::string
218  getName(const std::string& namectxt);
219 
220  static std::string
221  getCtxt(const std::string& namectxt);
222 
223  short
224  connectComponent(char*&, const char*, const char*, const char*,
225  const log_time_t&, tag_list_t&, const char*);
226 
227 
228  short
229  disconnectComponent(const char* componentName, const char* message,
230  const char* objName);
231 
232 
233  void
234  sendBuffer(const log_msg_buf_t &buffer, const char* objName);
235 
236 
237  void
238  synchronize(const char* componentName, const log_time_t& componentTime,
239  const char* objName);
240 
241 private:
242  /* When a new forwarder object is created, we cache it.
243  * Because this kind of object contains only the object
244  * name and a reference to this forwarder, there is no
245  * risk to cache it, even if the object is restarted or
246  * disappear.
247  */
248  std::map<std::string, ::CORBA::Object_ptr> objectCache;
249  /* We also maintain a list of activated servant objects. */
250  std::map<std::string, PortableServer::ServantBase*> servants;
251 
252  ::CORBA::Object_ptr
253  getObjectCache(const std::string& name);
254 
255  /* The forwarder associated to this one. */
256  CorbaLogForwarder_var peer;
257  /* Mutexes */
258  omni_mutex peerMutex; // To wait for the peer initialization
259  omni_mutex cachesMutex; // Protect access to caches
260 
261  std::string peerName;
262  std::string name;
263  std::string host;
264 };
265 
266 #endif
short connectTool(char *&toolName, const char *msgReceiver, const char *objName)
short addFilter(const char *toolName, const filter_t &filter, const char *objName)
Definition: LogForwarder.hh:59
Definition: LogComponent.hh:135
short disconnectTool(const char *toolName, const char *objName)
Definition: LogTypes.hh:57
tag_list_t * getDefinedTags(const char *objName)
Definition: LogTypes.hh:107
Definition: LogTool.hh:274
Definition: CorbaLogForwarder.hh:141
Definition: CorbaLogForwarder.hh:229
Definition: LogTypes.hh:221
Definition: LogTool.hh:73
Definition: LogTool.hh:157
Definition: commonLogTypes.hh:515
component_list_t * getDefinedComponents(const char *objName)
Definition: LogTypes.hh:335
Definition: LogComponent.hh:258