65 :TNamed(name,
"This is a Go4 Task Handler"),
72 TGo4Log::Debug(
" TaskHandler -- constructor error, unspecified ThreadManager: aborting ");
77 if(negotiationport == 0)
99 namebuffer.Form(
"CommandRunnable of %s",GetName());
103 namebuffer.Form(
"StatusRunnable of %s",GetName());
107 namebuffer.Form(
"DataRunnable of %s",GetName());
156 connector->
Send(myname.Data());
157 connector->
Send(gSystem->HostName());
166 gSystem->Sleep(1000);
170 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
184 TGo4Log::Debug(
" TaskHandler %s connecting to host %s ...",GetName(),host);
200 recvchar=connector->
RecvRaw(
"dummy");
203 TGo4Log::Debug(
" TaskHandler %s; Error on server connection, abortin... ",GetName());
210 TGo4Log::Debug(
" TaskHandler %s; Server refuses Connection",GetName());
213 gSystem->Sleep(1000);
220 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Command Channel",GetName());
225 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Status Channel",GetName());
230 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Data Channel",GetName());
235 gSystem->Sleep(1000);
238 TGo4Log::Debug(
" TaskHandler %s closed negotiation connection ",GetName());
244 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
251 const char *client = GetName();
252 if(!connector)
return kFALSE;
257 TGo4Log::Debug(
" TaskHandler: Command channel connect ERROR for client %s ",client);
262 TGo4Log::Debug(
" TaskManager: Status channel connect ERROR for client %s ",client);
267 TGo4Log::Debug(
" TaskManager: Data channel connect ERROR for client %s ",client);
282 if(!connector)
return kFALSE;
321 char *recvchar = connector->
RecvRaw(
"dummy");
322 if(recvchar && !strcmp(recvchar,
fgcOK))
return kTRUE;
355 gSystem->Sleep(1000);
363 TGo4Log::Debug(
" TaskHandler %s server disconnect login ERROR - Trying Fast DisConnect... ",GetName());
372 TGo4Log::Debug(
" TaskHandler %s Client Aborting mode: Fast DisConnect... ",GetName());
433 char *revchar =
nullptr;
434 Int_t waitresult = 0;
438 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no server task ",name);
441 if(!negotiator || !negotiator->
IsOpen())
443 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel", name);
448 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance", name);
451 const char *client = GetName();
461 TGo4Log::Debug(
" TaskHandler: Channel %s open TIMEOUT for client %s ",name, client);
471 TGo4Log::Debug(
" TaskHandler: Channel %s getport TIMEOUT for client %s ",name, client);
476 localbuffer.Form(
"%d",port);
477 negotiator->
Send(localbuffer.Data());
478 revchar=negotiator->
RecvRaw(
"dummy");
486 TGo4Log::Debug(
" TaskHandler: Negotiation ERROR after Channel %s open for client %s ",
496 TGo4Log::Debug(
" TaskHandler: Channel %s connect TIMEOUT for client %s ", name, client);
503 TGo4Log::Debug(
" TaskHandler: Channel %s for client %s open!",name, client);
510 char *recvchar =
nullptr;
512 if(!negotiator || !negotiator->
IsOpen())
514 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
519 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
523 recvchar = negotiator->
RecvRaw(
"dummy");
524 if(recvchar && !strcmp(recvchar,
fgcOK))
527 recvchar=negotiator->
RecvRaw(
"dummy");
528 TString localbuffer = recvchar;
529 port=atoi(localbuffer.Data());
531 channel->
Open(host,port);
532 TGo4Log::Debug(
" TaskHandler %s: Channel %s open!",GetName(), name );
538 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Channel %s ",
547 Int_t count = 0, port = 0;
600 if(!name)
return kFALSE;
602 if(!thread)
return kFALSE;
604 Bool_t timeout = kFALSE;
607 TGo4Log::Debug(
" TaskHandler Disconnect -- waiting for runnable %s to stop... ",name);
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="")
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=nullptr)
static UInt_t Get_fguPORTWAITTIME()
void StartTransportThreads()
static const char * fgcDATATHREAD
void SetMaxEntries(Int_t max)
Bool_t StopTransportThreads(Bool_t wait=kTRUE)
virtual Int_t Send(TObject *obj)
Int_t WaitForConnection()
static const UInt_t fguCOMMANDQUEUESIZE
static void SetObservAccount(const char *name, const char *passwd)
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)
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)
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
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)
TGo4Socket * fxStatusTransport
virtual char * RecvRaw(const char *name=nullptr)
void Clear(Option_t *opt="") override
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="")