GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4TaskHandler.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4TaskHandler.h"
15 
16 #include "TSystem.h"
17 
18 #include "TGo4Log.h"
19 #include "TGo4Thread.h"
20 #include "TGo4ThreadHandler.h"
21 #include "TGo4Socket.h"
22 #include "TGo4BufferQueue.h"
23 #include "TGo4RuntimeException.h"
24 #include "TGo4DataRunnable.h"
25 #include "TGo4StatusRunnable.h"
26 #include "TGo4CommandRunnable.h"
27 #include "TGo4ServerTask.h"
28 #include "TGo4TaskHandlerStatus.h"
29 
30 const UInt_t TGo4TaskHandler::fguCONNECTORPORT=5000; // port no of default connector 9229
31 // 5000 is the first number of ROOT portscan
32 const UInt_t TGo4TaskHandler::fguTRANSPORTCHECKDELAY=5000; // delay in ms for transport init check
33 
34 const UInt_t TGo4TaskHandler::fguSTATUSQUEUESIZE=1000;
35 const UInt_t TGo4TaskHandler::fguDATAQUEUESIZE=1000;
36 const UInt_t TGo4TaskHandler::fguCOMMANDQUEUESIZE=1000;
37 
38 
39 const Int_t TGo4TaskHandler::fgiPORTWAITCYCLES=150;//60
40 
41 const UInt_t TGo4TaskHandler::fguPORTWAITTIME=200;//500
42 
44 
45 const UInt_t TGo4TaskHandler::fguTHREADSTOPTIME=500;
46 
47 const char *TGo4TaskHandler::fgcCONNECT="CONNECT-VERSION-300";
48 const char *TGo4TaskHandler::fgcDISCONNECT="DISCONNECT-VERSION-300";
49 
50 const char *TGo4TaskHandler::fgcOK = "OK-VERSION-300";
51 const char *TGo4TaskHandler::fgcERROR = "ERROR-VERSION-300";
52 
53 const char *TGo4TaskHandler::fgcMASTER="Master-VERSION-300";
54 const char *TGo4TaskHandler::fgcSLAVE="Slave-VERSION-300";
55 
56 const char *TGo4TaskHandler::fgcCOMMANDTHREAD="COMMAND-";
57 const char *TGo4TaskHandler::fgcSTATUSTHREAD="STATUS-";
58 const char *TGo4TaskHandler::fgcDATATHREAD="DATA-";
59 
60 TNamed TGo4TaskHandler::fgxOBSERVERACCOUNT("observer","go4view");
61 TNamed TGo4TaskHandler::fgxCONTROLLERACCOUNT("controller","go4ctrl");
62 TNamed TGo4TaskHandler::fgxADMINISTRATORACCOUNT("admin","go4super");
63 
64 TGo4TaskHandler::TGo4TaskHandler(const char *name, TGo4ThreadManager *threadmanager, Bool_t clientmode, Bool_t mastermode,UInt_t negotiationport)
65 :TNamed(name,"This is a Go4 Task Handler"),
66 fbIsAborting(kFALSE), fiComPort(0),fiStatPort(0),fiDatPort(0),fiRole(kGo4ComModeController)
67 {
68  fbClientMode = clientmode;
69  fbMasterMode = mastermode;
70  if(!threadmanager) {
71  // error
72  TGo4Log::Debug(" TaskHandler -- constructor error, unspecified ThreadManager: aborting ");
73  //throw TGo4RuntimeException();
74  }
75 
76  // set port number for the client server negotiation channel:
77  if(negotiationport == 0)
78  {
79  // default: use taskhandler intrinsic port number
81  }
82  else
83  {
84  // use dynamic port number given by taskhandler owner
85  fuNegPort=negotiationport;
86  }
87 
88  fxThreadManager=threadmanager;
90  TString namebuffer;
91  fxInvoker = nullptr;
92  fxCommandQueue= new TGo4BufferQueue("Command"); // receiv commands
93  fxStatusQueue= new TGo4BufferQueue("Status"); // send status buffer
94  fxDataQueue= new TGo4BufferQueue("Data"); // send data
95 
99  namebuffer.Form("CommandRunnable of %s",GetName());
100  // command runnable receivermode: receiving as slave and sending as master
101  fxCommandRun=new TGo4CommandRunnable(namebuffer.Data(), fxThreadManager, this, !IsMasterMode());
102 
103  namebuffer.Form("StatusRunnable of %s",GetName());
104  // status runnable receivermode: sending as slave and receiving as master
105  fxStatusRun=new TGo4StatusRunnable(namebuffer.Data(), fxThreadManager, this, IsMasterMode());
106 
107  namebuffer.Form("DataRunnable of %s",GetName());
108  // data runnable receivermode: sending as slave and receiving as master
109  fxDataRun=new TGo4DataRunnable(namebuffer.Data(), fxThreadManager, this, IsMasterMode());
110 
111  // adding runnables to thread handler who takes over the responsibility...:
112  namebuffer.Form("%s%s",fgcCOMMANDTHREAD,GetName());
113  fxComName=namebuffer;
115  namebuffer.Form("%s%s",fgcSTATUSTHREAD,GetName());
116  fxStatName=namebuffer;
118  namebuffer.Form("%s%s",fgcDATATHREAD,GetName());
119  fxDatName=namebuffer;
121  if(IsClientMode())
122  TGo4Log::Debug(" New TaskHandler %s in client mode ",GetName());
123  else
124  TGo4Log::Debug(" New TaskHandler %s in server mode ",GetName());
125 
126  // adjust queue size to our wishes
130 }
131 
133 {
137  delete fxCommandTransport;
138  delete fxStatusTransport;
139  delete fxDataTransport;
140  delete fxCommandQueue;
141  delete fxStatusQueue;
142  delete fxDataQueue;
143 }
144 
146 {
147  if(fbClientMode)
148  {
149  // we are client and want access to the server task (connector runnable)
150  TGo4Socket *connector=new TGo4Socket(kTRUE); // raw socket transport
151  connector->Open(host,fuNegPort); // open connection to server's connector runnable
152  if(ServerLogin(connector, GetRole()))
153  {
154  // client and server know each other- we continue
155  TString myname=fxThreadManager->GetName();
156  connector->Send(myname.Data()); // tell server the client name
157  connector->Send(gSystem->HostName()); // tell server our machine hostname
158  return connector;
159  } //if(!strcmp(localbuffer,fgcOK))
160  else
161  {
162  // error: client does not match to server-- connect failed
163  connector->Send(Get_fgcERROR()); // send dummy strings, server will come out of receive
164  connector->Send(Get_fgcERROR()); // might check the errortext at server later
165 #ifdef _MSC_VER
166  gSystem->Sleep(1000);
167 #endif
168  connector->Close();
169  delete connector;
170  TGo4Log::Debug(" TaskHandler %s server connection ERROR ",GetName());
171  return nullptr;
172 
173  } // else if(!strcmp(localbuffer,fgcOK))
174  } //if(fbClientMode)
175 
176  // we _are_ a server task handler, shall not request to our own Server task
177  return nullptr;
178 }
179 
180 
181 Bool_t TGo4TaskHandler::Connect(const char *host, TGo4Socket *connector)
182 // establish connection of all three channels
183 {
184  TGo4Log::Debug(" TaskHandler %s connecting to host %s ...",GetName(),host);
185  char *recvchar;
186  if(fbClientMode)
187  {
189  SetAborting(kFALSE); // reset if we reconnect after exception disconnect
190  fxHostName=host;// remember hostname for later DisConnect
191  if(!connector)
192  {
193  // normal mode for client: we establish negotiation connection first
194  connector=ServerRequest(host); // get negotiation channel from server
195  }
196  if(connector)
197  {
198  // request was successful, we keep talking:
199  connector->Send(fgcCONNECT); // tell server we want to connect
200  recvchar=connector->RecvRaw("dummy");
201  if(!recvchar)
202  {
203  TGo4Log::Debug(" TaskHandler %s; Error on server connection, abortin... ",GetName());
204  connector->Close();
205  throw TGo4RuntimeException();
206  }
207  if(!strcmp(recvchar,Get_fgcERROR()))
208  {
209  // server refuses to connect us, we abort
210  TGo4Log::Debug(" TaskHandler %s; Server refuses Connection",GetName());
211  connector->Send(fgcOK); // tell server we are through
212 #ifdef _MSC_VER
213  gSystem->Sleep(1000);
214 #endif
215  connector->Close();
216  throw TGo4RuntimeException();
217  }
218  if(!ConnectClientChannel("Command",connector,fxCommandTransport,host))
219  {
220  TGo4Log::Debug(" TaskHandler %s; negotiation error, FAILED to open Command Channel",GetName());
221  throw TGo4RuntimeException();
222  }
223  if(!ConnectClientChannel("Status",connector,fxStatusTransport,host))
224  {
225  TGo4Log::Debug(" TaskHandler %s; negotiation error, FAILED to open Status Channel",GetName());
226  throw TGo4RuntimeException();
227  }
228  if(!ConnectClientChannel("Data",connector,fxDataTransport,host))
229  {
230  TGo4Log::Debug(" TaskHandler %s; negotiation error, FAILED to open Data Channel",GetName());
231  throw TGo4RuntimeException();
232  }
233  connector->Send(fgcOK); // tell server we finish negotiation
234 #ifdef _MSC_VER
235  gSystem->Sleep(1000);
236 #endif
237  connector->Close();
238  TGo4Log::Debug(" TaskHandler %s closed negotiation connection ",GetName());
239  delete connector;
240  }
241  else
242  {
243  // something failed
244  TGo4Log::Debug(" TaskHandler %s server connection ERROR ",GetName());
245  return kFALSE;
246  } // if(connector)
247  } //if(fbClientMode)
248  else
249  {
251  const char *client = GetName();
252  if(!connector) return kFALSE;
253  connector->Send(TGo4TaskHandler::fgcOK);
254  // first ok to initialize client, fgcERROR would abort client
255  if (!ConnectServerChannel("Command",connector, fxCommandTransport, host))
256  {
257  TGo4Log::Debug(" TaskHandler: Command channel connect ERROR for client %s ",client);
258  return kFALSE;
259  }
260  if (!ConnectServerChannel("Status",connector, fxStatusTransport, host))
261  {
262  TGo4Log::Debug(" TaskManager: Status channel connect ERROR for client %s ",client);
263  return kFALSE;
264  }
265  if (!ConnectServerChannel("Data",connector, fxDataTransport, host))
266  {
267  TGo4Log::Debug(" TaskManager: Data channel connect ERROR for client %s ",client);
268  return kFALSE;
269  }
270  } //if(fbClientMode)
271 
272  fiComPort = WaitGetPort(fxCommandTransport); // set port numbers for runnables
276 
277  return kTRUE;
278 }
279 
281 {
282  if(!connector) return kFALSE;
283  //std::cout <<"ServerLogin with mode "<<account << std::endl;
284  //std::cout <<"observer account is "<<TGo4TaskHandler::fgxOBSERVERACCOUNT.GetName()<<", "<<TGo4TaskHandler::fgxOBSERVERACCOUNT.GetTitle() << std::endl;
285  //std::cout <<"controller account is "<<TGo4TaskHandler::fgxCONTROLLERACCOUNT.GetName()<<", "<<TGo4TaskHandler::fgxCONTROLLERACCOUNT.GetTitle() << std::endl;
286  //std::cout <<"admin account is "<<TGo4TaskHandler::fgxADMINISTRATORACCOUNT.GetName()<<", "<<TGo4TaskHandler::fgxADMINISTRATORACCOUNT.GetTitle() << std::endl;
287 
288  connector->Send(fgcOK); // tell server that we are a valid client
289 
290  // tell server if we are master or slave:
291  if(fbMasterMode)
292  connector->Send(fgcMASTER);
293  else
294  connector->Send(fgcSLAVE);
295 
296  // now send accountname and password:
297  switch (account)
298  {
299  case kGo4ComModeObserver:
300  connector->Send(fgxOBSERVERACCOUNT.GetName());
301  connector->Send(fgxOBSERVERACCOUNT.GetTitle());
302  break;
303 
305  connector->Send(fgxCONTROLLERACCOUNT.GetName());
306  connector->Send(fgxCONTROLLERACCOUNT.GetTitle());
307  break;
308 
310  connector->Send(fgxADMINISTRATORACCOUNT.GetName());
311  connector->Send(fgxADMINISTRATORACCOUNT.GetTitle());
312  break;
313 
314  case kGo4ComModeRefused:
315  default:
316  connector->Send(Get_fgcERROR());
317  connector->Send(Get_fgcERROR());
318  break;
319  }
320 
321  char *recvchar = connector->RecvRaw("dummy");// handshake back if it is ok
322  if(recvchar && !strcmp(recvchar,fgcOK)) return kTRUE;
323  return kFALSE;
324 }
325 
326 Bool_t TGo4TaskHandler::DisConnect(Bool_t waitforclient)
327 {
328  TGo4Log::Debug(" TaskHandler %s disconnecting ",GetName());
329  //TGo4Task* task=dynamic_cast<TGo4Task*>(fxThreadManager);
330  if(fbClientMode)
331  {
332  if(!IsAborting())
333  {
334  // normal DisConnect mode:
335  // we are client, have to tell server to let us go...
336  TGo4Socket *connector=ServerRequest(GetHostName()); // get negotiation channel from server
337  if(connector)
338  {
339  // request was successful, we keep talking:
340  // task->StopWorkThreads();
341  // if(task->IsMaster())
342  // fxCommandQueue->Clear();// only clear command queue on master side,
343  // // otherwise we lose status messages from server
344  // task->WakeCommandQueue(TGo4Task::Get_fgiTERMID()); // will stop local command thread, and remote
345  // task->SendStopBuffers(); // only stop remote threads if login was successful!
347  connector->Send(fgcDISCONNECT); // tell server we want to disconnect
348  StopTransportThreads(kTRUE);// wait until threads are really stopped
349  CloseChannels();
350  connector->Send(fgcOK); // tell server we finished transports
351  // server will close its transport sockets after this
352 
353  connector->Send(fgcOK); // second ok to let server shutdown connector
354 #ifdef _MSC_VER
355  gSystem->Sleep(1000);
356 #endif
357  connector->Close();
358  delete connector;
359  }
360  else
361  {
362  // something failed
363  TGo4Log::Debug(" TaskHandler %s server disconnect login ERROR - Trying Fast DisConnect... ",GetName());
364  StopTransportThreads(kFALSE);
365  CloseChannels("force");
366  //return kFALSE;
367  }
368  }
369  else // if(!IsAborting())
370  {
371  // DisConnect after exception, fast Close without negotiations
372  TGo4Log::Debug(" TaskHandler %s Client Aborting mode: Fast DisConnect... ",GetName());
373  StopTransportThreads(kFALSE);
374  CloseChannels("force");
375  }
376  }
377  else
378  {
379  StopTransportThreads(waitforclient);// wait until threads are really stopped
380  CloseChannels();
381  }
382  return kTRUE;
383 }
384 
386 {
387  //TString option=opt;
388  //if(option=="force")
389  // {
390  // std::cout <<"sSSSSSSSSSSSS CloseChannels sending abort buffer" << std::endl;
391  // TGo4Task* task=dynamic_cast<TGo4Task*>(fxThreadManager);
392  // // provoke socket exception on receiver channels:
393  // if(fbMasterMode)
394  // {
395  // fxCommandTransport->SendBuffer(task->GetAbortBuffer());
396  // }
397  // else
398  // {
399  // fxDataTransport->SendBuffer(task->GetAbortBuffer());
400  // fxStatusTransport->SendBuffer(task->GetAbortBuffer());
401  //
402  // }
403  // }
404  fxDataTransport->Close(opt);
406  fxStatusTransport->Close(opt);
407  ClearQueues();
408 
409 }
410 
412 {
413  fxDataQueue->Clear();
415  fxStatusQueue->Clear();
416 
417 }
418 
420 {
421  TGo4TaskHandlerStatus* state= new TGo4TaskHandlerStatus(GetName());
422  // we are friend of our status class, may use private setters:
423  state->SetFlags(fbIsAborting);
426  return state;
427 }
428 
429 
430 
431 Bool_t TGo4TaskHandler::ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
432 {
433  char *revchar = nullptr;
434  Int_t waitresult = 0;
435  TGo4ServerTask *server = dynamic_cast<TGo4ServerTask *>(fxThreadManager);
436  if(!server)
437  {
438  TGo4Log::Debug(" TaskHandler: Channel %s open ERROR: no server task ",name);
439  return kFALSE;
440  }
441  if(!negotiator || !negotiator->IsOpen())
442  {
443  TGo4Log::Debug(" TaskHandler: Channel %s open ERROR: no negotiation channel", name);
444  return kFALSE;
445  }
446  if(!channel)
447  {
448  TGo4Log::Debug(" TaskHandler: Channel %s open ERROR: no TGo4Socket instance", name);
449  return kFALSE;
450  }
451  const char *client = GetName(); // taskhandler name is client name
452  // in server mode, we connect by the connector thread:
453  // need timer mechanism for proper registration of ROOT sockets (timer is main thread)
454  // only root sockets connected in main application thread will be cleaned up
455  server->SetConnect(channel, host,0,kTRUE);
456  // tell the ServerTask timer we want to connect; portscan. we keep server socket open for windows
457  waitresult = server->WaitForOpen(); // wait for the server Open() call by timer
458  if(waitresult < 0)
459  {
460  // open timeout
461  TGo4Log::Debug(" TaskHandler: Channel %s open TIMEOUT for client %s ",name, client);
462  return kFALSE;
463  }
464  else
465  {
466  // ok, proceed
467  }
468  Int_t port = WaitGetPort(channel);
469  if (port < 0)
470  {
471  TGo4Log::Debug(" TaskHandler: Channel %s getport TIMEOUT for client %s ",name, client);
472  return kFALSE;
473  }
474  negotiator->Send(TGo4TaskHandler::fgcOK); // tell client we are ready to connect
475  TString localbuffer;
476  localbuffer.Form("%d",port);
477  negotiator->Send(localbuffer.Data()); // tell client the port number;
478  revchar=negotiator->RecvRaw("dummy"); // wait for client connection ok
479  if(revchar && !strcmp(revchar,TGo4TaskHandler::fgcOK))
480  {
481  // o.k., client tells us connection is open, continue
482  }
483  else
484  {
485  // something went wrong, no ok
486  TGo4Log::Debug(" TaskHandler: Negotiation ERROR after Channel %s open for client %s ",
487  name, client);
488  return kFALSE;
489  //throw TGo4RuntimeException();
490  }
491 
492  waitresult=server->WaitForConnection(); // we also check ourselves if timer has returned from server open
493  if(waitresult < 0)
494  {
495  // connect timeout
496  TGo4Log::Debug(" TaskHandler: Channel %s connect TIMEOUT for client %s ", name, client);
497  return kFALSE;
498  }
499  else
500  {
501  // ok, proceed
502  }
503  TGo4Log::Debug(" TaskHandler: Channel %s for client %s open!",name, client);
504  return kTRUE;
505 }
506 
507 Bool_t TGo4TaskHandler::ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
508 {
509  //
510  char *recvchar = nullptr;
511  Int_t port = 0;
512  if(!negotiator || !negotiator->IsOpen())
513  {
514  TGo4Log::Debug(" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
515  return kFALSE;
516  }
517  if(!channel)
518  {
519  TGo4Log::Debug(" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
520  return kFALSE;
521  }
522 
523  recvchar = negotiator->RecvRaw("dummy");// get OK from server to connect first channel
524  if(recvchar && !strcmp(recvchar,fgcOK))
525  {
526  // get portnumber from server:
527  recvchar=negotiator->RecvRaw("dummy");
528  TString localbuffer = recvchar;
529  port=atoi(localbuffer.Data());
530  // std::cout <<"------- TaskHandler::Connect client tries port "<< port << "for Channel "<< name << std::endl;
531  channel->Open(host,port); // in client mode, we connect directly (main thread!)
532  TGo4Log::Debug(" TaskHandler %s: Channel %s open!",GetName(), name );
533  negotiator->Send(fgcOK); // tell server that open is ready
534  return kTRUE;
535  }
536  else
537  {
538  TGo4Log::Debug(" TaskHandler %s; negotiation error, FAILED to open Channel %s ",
539  GetName(), name);
540  return kFALSE;
541  //throw TGo4RuntimeException();
542  } // if(!strcmp(recvchar,fgcOK))
543 }
544 
546 {
547  Int_t count = 0, port = 0;
548  while(port == 0)
549  {
550  port = sock->GetPort(); // get dynamically bound port number of server socket
551  // std::cout <<"------- WaitGetPort has next portnumber "<< port << std::endl;
552  if(count>fgiPORTWAITCYCLES)
553  {
554  return -1;
555  }
556  else if(fxThreadManager->IsTerminating())
557  {
558  return -2;
559  }
560  else
561  {
563  ++count;
564  }
565  }
566  return port;
567 
568 }
569 
571 {
572  fxThreadHandler->Start(GetComName()); // start runnables
575 }
576 
578 {
579  Bool_t rev = kTRUE;
581  if(IsMasterMode())
582  {
583  TGo4BufferQueue *comq= dynamic_cast<TGo4BufferQueue*>(GetCommandQueue());
584  if(comq)
585  comq->Wake();
586  }
589  if(wait)
590  {
591  rev&=WaitThreadStop(GetComName());
592  rev&=WaitThreadStop(GetStatName());
593  rev&=WaitThreadStop(GetDatName());
594  }
595  return rev;
596 }
597 
598 Bool_t TGo4TaskHandler::WaitThreadStop(const char *name)
599 {
600  if(!name) return kFALSE;
601  TGo4Thread *thread=fxThreadHandler->GetThread(name);
602  if(!thread) return kFALSE;
603  Int_t t = 0;
604  Bool_t timeout = kFALSE;
605  while(!thread->IsWaiting())
606  {
607  TGo4Log::Debug(" TaskHandler Disconnect -- waiting for runnable %s to stop... ",name);
610  {
611  timeout = kTRUE;
612  break;
613  }
614  }
615  return !timeout;
616 }
617 
618 void TGo4TaskHandler::SetAdminAccount(const char *name, const char *passwd)
619 {
620  if(name) fgxADMINISTRATORACCOUNT.SetName(name);
621  if(passwd) fgxADMINISTRATORACCOUNT.SetTitle(passwd);
622 }
623 
624 void TGo4TaskHandler::SetCtrlAccount(const char *name, const char *passwd)
625 {
626  if(name) fgxCONTROLLERACCOUNT.SetName(name);
627  if(passwd) fgxCONTROLLERACCOUNT.SetTitle(passwd);
628 }
629 
630 void TGo4TaskHandler::SetObservAccount(const char *name, const char *passwd)
631 {
632  if(name) fgxOBSERVERACCOUNT.SetName(name);
633  if(passwd) fgxOBSERVERACCOUNT.SetTitle(passwd);
634 }
635 
637 {
638  return fgcOK;
639 }
640 
642 {
643  return fgcERROR;
644 }
645 
647 {
648  return fguPORTWAITTIME;
649 }
650 
652 {
653  return fgiPORTWAITCYCLES;
654 }
static const char * fgcSTATUSTHREAD
void SetPorts(UInt_t neg, Int_t com, Int_t stat, Int_t dat)
static const UInt_t fguDATAQUEUESIZE
Bool_t DisConnect(Bool_t waitforclient=kTRUE)
TGo4Thread * GetThread(const char *name)
static TNamed fgxADMINISTRATORACCOUNT
virtual Int_t Close(Option_t *opt="")
Definition: TGo4Socket.cxx:210
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=nullptr)
static UInt_t Get_fguPORTWAITTIME()
Bool_t IsOpen() const
Definition: TGo4Socket.h:37
static const char * fgcDATATHREAD
void SetMaxEntries(Int_t max)
Definition: TGo4Queue.h:45
Bool_t StopTransportThreads(Bool_t wait=kTRUE)
virtual Int_t Send(TObject *obj)
Definition: TGo4Socket.cxx:332
Int_t WaitForConnection()
TGo4Queue * fxDataQueue
Go4CommandMode_t
Definition: TGo4Command.h:27
static const UInt_t fguCOMMANDQUEUESIZE
static void SetObservAccount(const char *name, const char *passwd)
virtual void Wake()
Definition: TGo4Queue.cxx:86
TGo4ThreadManager * fxThreadManager
static const Int_t fgiPORTWAITCYCLES
static const UInt_t fguTRANSPORTCHECKDELAY
static const char * Get_fgcERROR()
static const char * fgcERROR
static const Int_t fgiTHREADSTOPCYCLES
static void Sleep(UInt_t millisecs)
Definition: TGo4Thread.cxx:295
static const char * Get_fgcOK()
TGo4DataRunnable * fxDataRun
static void SetCtrlAccount(const char *name, const char *passwd)
void SetAborting(Bool_t isaborting=kTRUE)
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
Definition: TGo4Socket.cxx:92
Bool_t NewThread(const char *name, TGo4Runnable *runnable)
static const UInt_t fguSTATUSQUEUESIZE
void SetConnect(TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
TGo4Queue * fxCommandQueue
TGo4StatusRunnable * fxStatusRun
Bool_t IsClientMode() const
TGo4Socket * fxCommandTransport
Bool_t WaitThreadStop(const char *name)
static void Debug(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:281
static const UInt_t fguPORTWAITTIME
TGo4CommandRunnable * fxCommandRun
const char * GetDatName() const
static const char * fgcCONNECT
const char * GetHostName() const
Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
Int_t GetPort() const
Definition: TGo4Socket.h:41
Bool_t IsWaiting() const
Definition: TGo4Thread.h:88
TGo4Socket * fxStatusTransport
virtual char * RecvRaw(const char *name=nullptr)
Definition: TGo4Socket.cxx:401
void Clear(Option_t *opt="") override
Definition: TGo4Queue.cxx:43
void SetFlags(Bool_t isaborting)
static const char * fgcOK
static const char * fgcCOMMANDTHREAD
Bool_t IsAborting() const
static const char * fgcMASTER
Bool_t Stop(const char *thname)
TGo4Socket * fxDataTransport
Bool_t ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
TGo4ThreadHandler * fxThreadHandler
Bool_t Start(const char *thname)
virtual TGo4TaskHandlerStatus * CreateStatus()
virtual ~TGo4TaskHandler()
TGo4ThreadHandler * GetWorkHandler() const
Bool_t IsMasterMode() const
TGo4Queue * GetCommandQueue() const
const char * GetStatName() const
static const UInt_t fguCONNECTORPORT
static TNamed fgxCONTROLLERACCOUNT
Go4CommandMode_t GetRole()
static const char * fgcSLAVE
static const UInt_t fguTHREADSTOPTIME
static TNamed fgxOBSERVERACCOUNT
static void SetAdminAccount(const char *name, const char *passwd)
Bool_t RemoveThread(const char *name)
Bool_t IsTerminating() const
static Int_t Get_fgiPORTWAITCYCLES()
static const char * fgcDISCONNECT
TGo4Queue * fxStatusQueue
TGo4CommandInvoker * fxInvoker
TGo4Socket * ServerRequest(const char *host="localhost")
Int_t WaitGetPort(TGo4Socket *sock)
const char * GetComName() const
void SetNames(const char *com, const char *stat, const char *dat, const char *host)
Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account)
void CloseChannels(Option_t *opt="")