Jpp
JLigier.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 #include <sstream>
5 #include <deque>
6 #include <set>
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 #include "JLang/JMemory.hh"
11 #include "JLang/JSharedCounter.hh"
12 #include "JNet/JSocket.hh"
13 #include "JNet/JSocketChannel.hh"
14 #include "JNet/JServerSocket.hh"
15 #include "JNet/JSelect.hh"
16 #include "JNet/JControlHost.hh"
18 #include "JTools/JConstants.hh"
19 
20 
21 namespace JNET {
22 
23 
24  using namespace JPP;
25 
26 
27  template<class T> class JMemory_t : public JMalloc<T> {}; // Memory manager
28 
29  typedef JPrefix JPrefix_t;
31 
32 
33  /**
34  * Get total size of internet packet.
35  *
36  * \param prefix prefix
37  * \return number of bytes
38  */
39  inline int getSizeOfPacket(const JPrefix_t& prefix)
40  {
41  return prefix.getSize() + sizeof(JPrefix_t);
42  }
43 
44 
45  /**
46  * Set total size of internet packet.
47  *
48  * \param size number of bytes
49  * \param prefix prefix
50  */
51  inline void setSizeOfPacket(const int size, JPrefix_t& prefix)
52  {
53  prefix.setSize(size - sizeof(JPrefix_t));
54  }
55 
56 
57  /**
58  * Data structure of a ControlHost message.
59  * This data structure consists of a copy of the ControlHost prefix and
60  * an array of bytes (including the ControlHost prefix).
61  * A new array of bytes is created by the appropriate constructor.
62  * The allocated memory is released upon destruction of the last object of this class.
63  */
64  class JDispatch :
65  public JPrefix_t,
66  public JSharedCounter
67  {
68  public:
69 
71 
72  static long long int MEMORY_TOTAL; //!< Total size of data [Bytes]
73  static long long int MEMORY_LIMIT; //!< Limit size of data [Bytes]
74 
75  /**
76  * Default constructor.
77  */
79  JPrefix_t(),
81  buffer(NULL)
82  {}
83 
84 
85  /**
86  * Constructor.
87  * Note that the input data should contain a copy of the prefix.
88  *
89  * \param prefix prefix
90  * \param data data
91  */
92  JDispatch(const JPrefix_t& prefix,
93  const char* data) :
94  JPrefix_t(prefix),
96  {
97  create();
98 
99  memcpy(this->buffer, data, size());
100  }
101 
102 
103  /**
104  * Constructor.
105  * Note that the given message is appended to a copy of the prefix.
106  *
107  * \param tag tag
108  * \param message message
109  */
111  const std::string& message) :
112  JPrefix_t(tag, message.size()),
114  {
115  create();
116 
117  memcpy(this->buffer, static_cast<const JPrefix_t*>(this), sizeof(JPrefix_t));
118 
119  memcpy(this->buffer + sizeof(JPrefix_t), message.data(), message.size());
120  }
121 
122 
123  /**
124  * Copy constructor.
125  *
126  * \param message message
127  */
128  JDispatch(const JDispatch& message)
129  {
130  static_cast<JPrefix_t&>(*this) = message;
131 
132  buffer = message.buffer;
133 
134  attach(message);
135  }
136 
137 
138  /**
139  * Destructor.
140  */
142  {
143  if (detach())
144  release();
145  }
146 
147 
148  /**
149  * Assignment operator.
150  *
151  * \param message message
152  * \return this JDispatch
153  */
154  JDispatch& operator=(const JDispatch& message)
155  {
156  if (buffer != message.buffer) {
157 
158  if (detach()) {
159  release();
160  }
161 
162  buffer = message.buffer;
163 
164  attach(message);
165  }
166 
167  return *this;
168  }
169 
170 
171  /**
172  * Type conversion operator.
173  *
174  * \return socket output buffer
175  */
176  operator JSocketOutputBuffer () const
177  {
178  return JSocketOutputBuffer(this->data(), this->size());
179  }
180 
181 
182  /**
183  * Get size.
184  *
185  * \return number of bytes
186  */
187  int size() const
188  {
189  return getSizeOfPacket(static_cast<const JPrefix_t&>(*this));
190  }
191 
192 
193  /**
194  * Get data.
195  *
196  * \return pointer to data
197  */
198  const char* data() const
199  {
200  return buffer;
201  }
202 
203 
204  protected:
205  /**
206  * Allocate memory.
207  */
208  void create()
209  {
211 
212  if (buffer != NULL) {
213 
215 
216  MEMORY_TOTAL += size();
217 
218  } else {
219 
220  throw JMallocException("Not enough space in memory.");
221  }
222  }
223 
224 
225  /**
226  * Release memory.
227  */
228  void release()
229  {
231 
232  MEMORY_TOTAL -= size();
233  }
234 
235  char* buffer;
236  };
237 
238 
239  /**
240  * ControlHost client manager.
241  */
242  class JClient :
243  public JSocket
244  {
245  public:
246 
247 
248  static unsigned int QUEUE_LIMIT; //!< Maximum number of messages in queue
249 
250 
251  /**
252  * Default constructor.
253  */
255  JSocket(),
256  in (*this),
257  out(*this),
258  requestAll(false),
259  requestCounter(0)
260  {}
261 
262 
263  /**
264  * Constructor.
265  *
266  * \param socket socket
267  */
268  JClient(const JSocket& socket) :
269  JSocket(socket),
270  in (*this),
271  out(*this),
272  requestAll(false),
273  requestCounter(0)
274  {}
275 
276 
277  /**
278  * Get nick name.
279  *
280  * \return nick name
281  */
282  const std::string& getNickname() const
283  {
284  return nick_name;
285  }
286 
287 
288  /**
289  * Set nick name.
290  *
291  * \param nick_name nick name
292  */
293  void setNickname(const std::string& nick_name)
294  {
295  this->nick_name = nick_name;
296  }
297 
298 
299  /**
300  * Check request.
301  *
302  * \return true if request can be honoured; else false
303  */
304  bool checkRequest() const
305  {
306  return requestAll || requestCounter != 0;
307  }
308 
309 
310  /**
311  * Increment request by one.
312  */
314  {
315  ++requestCounter;
316  }
317 
318 
319  /**
320  * Decrement request by one.
321  */
323  {
324  --requestCounter;
325  }
326 
327 
328  /**
329  * Set no request.
330  */
332  {
333  requestAll = true;
334  }
335 
336 
337  /**
338  * Set subcription.
339  *
340  * \param subscription subscription
341  * \return true of OK; else false
342  */
343  bool setSubscription(const std::string& subscription)
344  {
345  using namespace std;
346 
347  subscriptionAll.clear();
348  subscriptionAny.clear();
349 
350  try {
351 
352  char c;
353  JTag tag;
354 
355  for (istringstream is(subscription); is >> c >> tag; ) {
356  if (c == SUBSCRIBE_ALL) subscriptionAll.insert(tag);
357  else if (c == SUBSCRIBE_ANY) subscriptionAny.insert(tag);
358  //else if (c == SUBSCRIBE_SHARED_MEMORY) subscriptionAny.insert(tag);
359  }
360  }
361  catch(const JControlHostException& error) {
362  return false;
363  }
364 
365  return true;
366  }
367 
368 
369  /**
370  * Check subscription for given prefix.
371  *
372  * \param prefix prefix
373  * \return true if subscription valid; else false
374  */
375  bool checkSubscriptionAll(const JPrefix_t& prefix) const
376  {
377  return subscriptionAll.find(prefix) != subscriptionAll.end();
378  }
379 
380 
381  /**
382  * Check subscription for given prefix.
383  *
384  * \param prefix prefix
385  * \return true if subscription valid; else false
386  */
387  bool checkSubscriptionAny(const JPrefix_t& prefix) const
388  {
389  return subscriptionAny.find(prefix) != subscriptionAny.end() && checkRequest() && queue.size() < QUEUE_LIMIT;
390  }
391 
392 
393  /**
394  * Check subscription for given prefix.
395  *
396  * \param prefix prefix
397  * \return true if subscription valid; else false
398  */
399  bool checkSubscription(const JPrefix_t& prefix) const
400  {
401  return checkSubscriptionAll(prefix) || checkSubscriptionAny(prefix);
402  }
403 
404 
405  /**
406  * Add message to client queues depending on subscription of each client.
407  * Note that adding a message may result in dropping (other) messages.
408  *
409  * \param message message
410  */
411  void add(const JDispatch& message)
412  {
413  if (checkSubscription(message)) {
414 
415  queue.push_back(message);
416 
417  if (queue.size() > QUEUE_LIMIT) {
418  drop();
419  }
420  }
421  }
422 
423 
424  /**
425  * Drop all messages for which the client has not the 'all' subscription.
426  */
427  void drop()
428  {
429  for (std::deque<JDispatch>::iterator i = queue.begin(); i != queue.end(); ) {
430  if (!checkSubscriptionAll(*i) && (i != queue.begin() || !out.isBusy()))
431  i = queue.erase(i);
432  else
433  ++i;
434  }
435  }
436 
437 
438  JSocketInputChannel_t in; //!< reader for incoming messages
439  JSocketNonblockingWriter out; //!< writer for outgoing messages
440  std::deque<JDispatch> queue; //!< queue for outgoing messages
441 
442  protected:
445  std::string nick_name;
448  };
449 
450 
451  /**
452  * List of ControlHost client managers.
453  */
454  class JClientList :
455  public std::vector<JClient>
456  {
457  public:
458  /**
459  * Default constructor.
460  */
462  std::vector<JClient>()
463  {}
464 
465 
466  /**
467  * Add message to client queues depending on subscription of each client.
468  *
469  * \param message message
470  */
471  void add(const JDispatch& message)
472  {
473  for (iterator i = this->begin(); i != this->end(); ++i) {
474  i->add(message);
475  }
476  }
477 
478 
479  /**
480  * Drop all messages from client queues for which the client has not the 'all' subscription.
481  */
482  void drop()
483  {
484  for (iterator i = this->begin(); i != this->end(); ++i) {
485  i->drop();
486  }
487  }
488  };
489 
490 
491  /**
492  * Print message.
493  *
494  * \param out output stream
495  * \param message message
496  * \return output stream
497  */
498  inline std::ostream& operator<<(std::ostream& out, const JDispatch& message)
499  {
500  return out << "(" << message.getTag() << "," << message.size() << ")";
501  }
502 
503 
504  /**
505  * Print socket.
506  *
507  * \param out output stream
508  * \param socket socket
509  * \return output stream
510  */
511  inline std::ostream& operator<<(std::ostream& out, const JSocket& socket)
512  {
513  return out << "[" << socket.getFileDescriptor() << "]";
514  }
515 
516 
517  /**
518  * Print socket status.
519  *
520  * \param out output stream
521  * \param status socket status
522  * \return output stream
523  */
524  inline std::ostream& operator<<(std::ostream& out, const JSocketStatus& status)
525  {
526  return out << "(" << status.isReady() << "," << status.getCounter() << ")";
527  }
528 
529 
530  /**
531  * Print socket input buffer.
532  *
533  * \param out output stream
534  * \param buffer socket buffer
535  * \return output stream
536  */
537  inline std::ostream& operator<<(std::ostream& out, const JSocketInputBuffer& buffer)
538  {
539  return out << "(" << buffer.isReady() << "," << buffer.getCounter() << "," << buffer.getSize() << ")";
540  }
541 
542 
543  long long int JDispatch::MEMORY_TOTAL = 0; //!< Total memory allocation.
544  long long int JDispatch::MEMORY_LIMIT; //!< Limit memory allocation.
545 
546  unsigned int JClient::QUEUE_LIMIT; //!< queue size limit
547 }
548 
549 
550 /**
551  * \file
552  *
553  * ControlHost server.
554  * \author mdejong
555  */
556 int main(int argc, char* argv[])
557 {
558  using namespace std;
559  using namespace JPP;
560 
561  int port;
562  int backlog;
563  int timeout_us;
564  int buffer_size;
565  int debug;
566 
567  try {
568 
569  JParser<> zap("ControlHost server.");
570 
571  zap['P'] = make_field(port) = DISPATCH_PORT;
572  zap['q'] = make_field(backlog) = 1024;
573  zap['T'] = make_field(timeout_us) = 1;
574  zap['s'] = make_field(buffer_size) = GIGABYTE;
575  zap['Q'] = make_field(JClient::QUEUE_LIMIT) = 100;
576  zap['M'] = make_field(JDispatch::MEMORY_LIMIT) = (JSYSTEM::getRAM() >> 1);
577  zap['d'] = make_field(debug) = 0;
578 
579  zap(argc, argv);
580  }
581  catch(const exception &error) {
582  FATAL(error.what() << endl);
583  }
584 
585 
586  JServerSocket server(port, backlog);
587  JSelect select;
588  JClientList clientList;
589 
590 
591  DEBUG("Port " << setw(10) << port << endl);
592  DEBUG("Memory limit " << setw(10) << JDispatch::MEMORY_LIMIT << endl);
593  DEBUG("Queue limit " << setw(10) << JClient::QUEUE_LIMIT << endl);
594 
595 
596  for ( ; ; ) {
597 
598  select.reset();
599  select.setReaderMask(server);
600 
601  for (JClientList::iterator client = clientList.begin(); client != clientList.end(); ++client) {
602 
603  if (!client->in.isReady()) {
604  select.setReaderMask(*client);
605  }
606 
607  if (client->out.isReset()) {
608 
609  if (!client->queue.empty()) {
610 
611  DEBUG("Client" << *client << ".set" << client->queue.front() << endl);
612 
613  client->out.set(client->queue.front());
614  client->decrementRequest();
615 
616  select.setWriterMask(*client);
617  }
618 
619  } else if (client->out.isBusy()) {
620 
621  select.setWriterMask(*client);
622  }
623  }
624 
625  if (select(timeout_us) > 0) {
626 
627  for (JClientList::iterator client = clientList.begin(); client != clientList.end(); ) {
628 
629  try {
630 
631  if (select.hasReaderMask(*client)) {
632 
633  try {
634  client->in.read();
635  }
636  catch(const exception& error) {
637 
638  ERROR("Remove (3) client" << *client << "<" << client->getNickname() << ">: " << error.what() << endl);
639 
640  if (client->getNickname() != "") {
641  clientList.add(JDispatch(DISPTAG_Died, client->getNickname()));
642  }
643 
644  client->shutdown();
645 
646  client = clientList.erase(client);
647 
648  continue;
649  }
650 
651  DEBUG("Client" << *client << ".read" << static_cast<const JSocketInputBuffer&>(client->in) << endl);
652  }
653 
654  if (client->in.isReady()) {
655 
656  DEBUG("Message" << *client << ' ' << client->in.prefix.c_str() << ' ' << client->in.size() << endl);
657 
658  bool special = JControlHost::maybe_special(client->in.prefix);
659 
660  if (special) {
661 
662  client->in.seekg(sizeof(JPrefix_t)); // skip prefix
663 
664  if (client->in.prefix.getTag() == DISPTAG_Subscribe) {
665 
666  client->setSubscription(string(client->in.getRemainingData(), client->in.getRemainingSize()));
667 
668  } else if (client->in.prefix.getTag() == DISPTAG_MyId) {
669 
670  client->setNickname(string(client->in.getRemainingData(), client->in.getRemainingSize()));
671 
672  clientList.add(JDispatch(DISPTAG_Born, client->getNickname()));
673 
674  } else if (client->in.prefix.getTag() == DISPTAG_Gime) {
675 
676  client->incrementRequest();
677 
678  } else if (client->in.prefix.getTag() == DISPTAG_Always) {
679 
680  client->setRequestAll();
681 
682  } else if (client->in.prefix.getTag() == DISPTAG_WhereIs) {
683 
684  string nick_name(client->in.getRemainingData(), client->in.getRemainingSize());
685  string buffer;
686 
687  for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
688  if (i->getNickname() == nick_name) {
689  buffer += " " + i->getHostname();
690  }
691  }
692 
693  JControlHost socket(*client);
694 
695  socket.PutFullString(DISPTAG_WhereIs, buffer.substr(buffer.empty() ? 0 : 1));
696 
697  DEBUG("Remove (1) client" << *client << endl);
698 
699  client->shutdown();
700 
701  client = clientList.erase(client);
702 
703  continue; // skip any action
704 
705  } else if (client->in.prefix.getTag() == DISPTAG_Debug) {
706 
707  istringstream is(string(client->in.getRemainingData(), client->in.getRemainingSize()));
708 
709  is >> debug;
710 
711  } else {
712 
713  special = false; // not a reserved tag.
714  }
715  }
716 
717  if (!special) {
718 
719  clientList.add(JDispatch(client->in.prefix, client->in.data()));
720 
722 
723  WARNING("Memory " << setw(10) << JDispatch::MEMORY_TOTAL << " > " << setw(10) << JDispatch::MEMORY_LIMIT << endl);
724 
725  clientList.drop();
726  }
727  }
728 
729  client->in.reset();
730  }
731 
732  if (select.hasWriterMask(*client)) {
733 
734  client->out.write();
735 
736  DEBUG("Client" << *client << ".write" << static_cast<const JSocketStatus&>(client->out) << endl);
737 
738  if (client->out.isReady()) {
739  client->out.reset();
740  client->queue.pop_front();
741  }
742  }
743 
744  ++client;
745  }
746  catch(const exception& error) {
747 
748  DEBUG("Remove (2) client" << *client << "<" << client->getNickname() << ">: " << error.what() << endl);
749 
750  if (client->getNickname() != "") {
751  clientList.add(JDispatch(DISPTAG_Died, client->getNickname()));
752  }
753 
754  client->shutdown();
755 
756  client = clientList.erase(client);
757  }
758  }
759 
760  if (select.hasReaderMask(server)) {
761 
762  JSocket socket;
763 
764  socket.accept(server.getFileDescriptor());
765 
766  socket.setSendBufferSize (buffer_size);
767  socket.setReceiveBufferSize(buffer_size);
768 
769  socket.setKeepAlive (true);
770  socket.setNonBlocking(true);
771 
772  DEBUG("New client" << socket << endl);
773 
774  clientList.push_back(JClient(socket));
775  }
776  }
777  }
778 }
JNET::JSocketBuffer
Auxiliary class for non-blocking socket I/O.
Definition: JSocketNonblocking.hh:22
JLANG::JSharedCounter::detach
bool detach()
Detach.
Definition: JSharedCounter.hh:63
JLANG::JAbstractFile::getFileDescriptor
int getFileDescriptor() const
Get file descriptor.
Definition: JAbstractFile.hh:75
JMemory.hh
JNET::DISPTAG_Debug
static const JTag DISPTAG_Debug("_Debug")
std::iterator
Definition: JSTDTypes.hh:18
JNET::JDispatch::~JDispatch
~JDispatch()
Destructor.
Definition: JLigier.cc:141
JNET::JClient::setNickname
void setNickname(const std::string &nick_name)
Set nick name.
Definition: JLigier.cc:293
JNET::DISPTAG_Subscribe
static const JTag DISPTAG_Subscribe("_Subscri")
Special ControlHost tags.
JNET::JClient::checkSubscriptionAny
bool checkSubscriptionAny(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition: JLigier.cc:387
JMessage.hh
JNET::JClient::incrementRequest
void incrementRequest()
Increment request by one.
Definition: JLigier.cc:313
JNET::JClient::JClient
JClient(const JSocket &socket)
Constructor.
Definition: JLigier.cc:268
main
int main(int argc, char *argv[])
Definition: JLigier.cc:556
JNET::JPrefix
ControlHost prefix.
Definition: JPrefix.hh:31
JNET::JDispatch::MEMORY_LIMIT
static long long int MEMORY_LIMIT
Limit size of data [Bytes].
Definition: JLigier.cc:73
JLANG::JControlHostException
Exception for ControlHost.
Definition: JException.hh:450
JNET::DISPTAG_WhereIs
static const JTag DISPTAG_WhereIs("_WhereIs")
JSelect.hh
JNET::JClient::requestCounter
int requestCounter
Definition: JLigier.cc:447
JNET::JSocketInputChannel_t
JSocketInputChannel< JPrefix_t > JSocketInputChannel_t
Definition: JLigier.cc:30
JLANG::JSharedCounter
Shared counter.
Definition: JSharedCounter.hh:19
JNET::setSizeOfPacket
void setSizeOfPacket(const int size, JPrefix_t &prefix)
Set total size of internet packet.
Definition: JLigier.cc:51
JNET::SUBSCRIBE_ALL
Definition: JControlHost.hh:40
JTOOLS::GIGABYTE
static const long long int GIGABYTE
Number of bytes in a megabyte.
Definition: JConstants.hh:81
JNET::JTag::getTag
const JTag & getTag() const
Get tag.
Definition: JTag.hh:82
std::vector
Definition: JSTDTypes.hh:12
JNET::JTag::tag
char tag[TAGSIZE]
Definition: JTag.hh:247
JNET::JClient
ControlHost client manager.
Definition: JLigier.cc:242
JServerSocket.hh
JNET::JSocketStatus::isReady
bool isReady() const
Check ready status.
Definition: JSocketStatus.hh:76
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JNET::JDispatch::operator=
JDispatch & operator=(const JDispatch &message)
Assignment operator.
Definition: JLigier.cc:154
JNET::JSocket
Socket class.
Definition: JSocket.hh:42
JLANG::JSharedCounter::attach
void attach(const JSharedCounter &object)
Attach this counter to given shared counter object.
Definition: JSharedCounter.hh:46
JNET
Interprocess communication.
Definition: JDataFilter.cc:67
JNET::JClient::checkSubscription
bool checkSubscription(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition: JLigier.cc:399
std::set
Definition: JSTDTypes.hh:13
JNET::JMemory_t
Definition: JLigier.cc:27
JNET::JClient::getNickname
const std::string & getNickname() const
Get nick name.
Definition: JLigier.cc:282
JNET::SUBSCRIBE_ANY
Definition: JControlHost.hh:41
JNET::JDispatch
Data structure of a ControlHost message.
Definition: JLigier.cc:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
ERROR
#define ERROR(A)
Definition: JMessage.hh:66
JNET::JDispatch::JDispatch
JDispatch(const JPrefix_t &prefix, const char *data)
Constructor.
Definition: JLigier.cc:92
JNET::JDispatch::release
void release()
Release memory.
Definition: JLigier.cc:228
JNET::JClientList
List of ControlHost client managers.
Definition: JLigier.cc:454
JNET::JClient::subscriptionAll
std::set< JTag > subscriptionAll
Definition: JLigier.cc:443
JNET::DISPTAG_Always
static const JTag DISPTAG_Always("_Always")
WARNING
#define WARNING(A)
Definition: JMessage.hh:65
JNET::JClient::setRequestAll
void setRequestAll()
Set no request.
Definition: JLigier.cc:331
debug
int debug
debug level
Definition: JSirene.cc:59
JNET::JControlHost::maybe_special
static bool maybe_special(const JTag &tag)
Check special ControlHost tags.
Definition: JControlHost.hh:269
JNET::JTag
ControlHost tag.
Definition: JTag.hh:35
JNET::JSocketBuffer::getSize
int getSize() const
Get size of pending data.
Definition: JSocketNonblocking.hh:55
JNET::DISPATCH_PORT
static const int DISPATCH_PORT
Default ControlHost port.
Definition: JHostname.hh:24
JConstants.hh
JLANG::JMalloc< T >::create
static T * create()
Create object in memory.
Definition: JMemory.hh:89
JLANG::JMallocException
Exception for failure of memory allocation.
Definition: JException.hh:288
JNET::JClient::decrementRequest
void decrementRequest()
Decrement request by one.
Definition: JLigier.cc:322
JNET::JSocketStatus::isBusy
bool isBusy() const
Check busy status.
Definition: JSocketStatus.hh:65
buffer_size
const static size_t buffer_size
Definition: clb_swiss_knife.cpp:169
JNET::JDispatch::MEMORY_TOTAL
static long long int MEMORY_TOTAL
Total size of data [Bytes].
Definition: JLigier.cc:72
JNET::JDispatch::JMemory_t
JMalloc< char > JMemory_t
Definition: JLigier.cc:70
JLANG::JSharedCounter::initialise
void initialise()
Initialise counter.
Definition: JSharedCounter.hh:33
JNET::JSocketStatus
Auxiliary class for non-blocking socket I/O.
Definition: JSocketStatus.hh:22
JNET::JClientList::add
void add(const JDispatch &message)
Add message to client queues depending on subscription of each client.
Definition: JLigier.cc:471
JNET::JClient::checkSubscriptionAll
bool checkSubscriptionAll(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition: JLigier.cc:375
JSharedCounter.hh
JNET::JClient::nick_name
std::string nick_name
Definition: JLigier.cc:445
JNET::JClient::add
void add(const JDispatch &message)
Add message to client queues depending on subscription of each client.
Definition: JLigier.cc:411
JNET::DISPTAG_Died
static const JTag DISPTAG_Died("Died")
JNET::JClient::setSubscription
bool setSubscription(const std::string &subscription)
Set subcription.
Definition: JLigier.cc:343
JParser.hh
JNET::JDispatch::buffer
char * buffer
Definition: JLigier.cc:235
JNET::JClient::checkRequest
bool checkRequest() const
Check request.
Definition: JLigier.cc:304
JSocketChannel.hh
JNET::JDispatch::JDispatch
JDispatch()
Default constructor.
Definition: JLigier.cc:78
JNET::JDispatch::data
const char * data() const
Get data.
Definition: JLigier.cc:198
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JControlHost.hh
JNET::JDispatch::JDispatch
JDispatch(const JTag &tag, const std::string &message)
Constructor.
Definition: JLigier.cc:110
JNET::JClient::QUEUE_LIMIT
static unsigned int QUEUE_LIMIT
Maximum number of messages in queue.
Definition: JLigier.cc:248
JNET::JDispatch::JDispatch
JDispatch(const JDispatch &message)
Copy constructor.
Definition: JLigier.cc:128
JNET::JClient::drop
void drop()
Drop all messages for which the client has not the 'all' subscription.
Definition: JLigier.cc:427
JNET::JClient::JClient
JClient()
Default constructor.
Definition: JLigier.cc:254
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
JNET::JSocketStatus::getCounter
int getCounter() const
Get number of I/O attempts.
Definition: JSocketStatus.hh:87
JNET::JDispatch::size
int size() const
Get size.
Definition: JLigier.cc:187
std
Definition: jaanetDictionary.h:36
JNET::JClientList::drop
void drop()
Drop all messages from client queues for which the client has not the 'all' subscription.
Definition: JLigier.cc:482
JNET::JClientList::JClientList
JClientList()
Default constructor.
Definition: JLigier.cc:461
JSocket.hh
JNET::operator<<
std::ostream & operator<<(std::ostream &out, const JDispatch &message)
Print message.
Definition: JLigier.cc:498
JNET::JClient::queue
std::deque< JDispatch > queue
queue for outgoing messages
Definition: JLigier.cc:440
JNET::JClient::in
JSocketInputChannel_t in
reader for incoming messages
Definition: JLigier.cc:438
JNET::JClient::out
JSocketNonblockingWriter out
writer for outgoing messages
Definition: JLigier.cc:439
JNET::JSocketOutputBuffer
JSocketBuffer< const char > JSocketOutputBuffer
Definition: JSocketNonblocking.hh:110
JSYSTEM::getRAM
unsigned long long int getRAM()
Get RAM of this CPU.
Definition: JSystemToolkit.hh:254
JNET::JPrefix::setSize
void setSize(const long long int length)
Set size.
Definition: JPrefix.hh:73
JNET::DISPTAG_Born
static const JTag DISPTAG_Born("Born")
JNET::JDispatch::create
void create()
Allocate memory.
Definition: JLigier.cc:208
JLANG::JMalloc< T >::release
static void release(T *p)
Release memory.
Definition: JMemory.hh:112
JNET::JClient::requestAll
bool requestAll
Definition: JLigier.cc:446
JNET::JPrefix_t
JPrefix JPrefix_t
Definition: JLigier.cc:29
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JLANG::JMalloc
Memory management class for create/release policy based on malloc()/free().
Definition: JMemory.hh:82
JNET::DISPTAG_MyId
static const JTag DISPTAG_MyId("_MyId")
JNET::JPrefix::getSize
int getSize() const
Get size.
Definition: JPrefix.hh:62
JNET::JSocketNonblockingWriter
Non-blocking socket writer.
Definition: JSocketNonblocking.hh:169
JNET::JClient::subscriptionAny
std::set< JTag > subscriptionAny
Definition: JLigier.cc:444
JSystemToolkit.hh
JNET::getSizeOfPacket
int getSizeOfPacket(const KM3NETDAQ::JDAQAbstractPreamble &preamble)
Get size of packeet.
Definition: JDataFilter.cc:76
JNET::JSocketInputChannel
Socket input channel.
Definition: JSocketChannel.hh:86
JNET::DISPTAG_Gime
static const JTag DISPTAG_Gime("_Gime")