67 :TNamed(name,
"This is a Go4 Task Handler"),
75 TGo4Log::Debug(
" TaskHandler -- constructor error, unspecified ThreadManager: aborting ");
84 if(negotiationport==0)
106 namebuffer.Form(
"CommandRunnable of %s",GetName());
110 namebuffer.Form(
"StatusRunnable of %s",GetName());
114 namebuffer.Form(
"DataRunnable of %s",GetName());
166 connector->
Send(myname.Data());
167 connector->
Send(gSystem->HostName());
176 gSystem->Sleep(1000);
180 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
199 TGo4Log::Debug(
" TaskHandler %s connecting to host %s ...",GetName(),host);
215 recvchar=connector->
RecvRaw(
"dummy");
218 TGo4Log::Debug(
" TaskHandler %s; Error on server connection, abortin... ",GetName());
225 TGo4Log::Debug(
" TaskHandler %s; Server refuses Connection",GetName());
228 gSystem->Sleep(1000);
235 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Command Channel",GetName());
240 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Status Channel",GetName());
245 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Data Channel",GetName());
250 gSystem->Sleep(1000);
253 TGo4Log::Debug(
" TaskHandler %s closed negotiation connection ",GetName());
259 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
266 const char* client=GetName();
267 if(connector==0)
return kFALSE;
272 TGo4Log::Debug(
" TaskHandler: Command channel connect ERROR for client %s ",client);
277 TGo4Log::Debug(
" TaskManager: Status channel connect ERROR for client %s ",client);
282 TGo4Log::Debug(
" TaskManager: Data channel connect ERROR for client %s ",client);
297 if(connector==0)
return kFALSE;
335 char * recvchar=connector->
RecvRaw(
"dummy");
336 if(recvchar && !strcmp(recvchar,
fgcOK))
return kTRUE;
370 gSystem->Sleep(1000);
378 TGo4Log::Debug(
" TaskHandler %s server disconnect login ERROR - Trying Fast DisConnect... ",GetName());
387 TGo4Log::Debug(
" Client Aborting mode: Fast DisConnect... ",GetName());
456 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no server task ",name);
459 if(negotiator==0 || !negotiator->
IsOpen())
461 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
466 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
469 const char* client=GetName();
479 TGo4Log::Debug(
" TaskHandler: Channel %s open TIMEOUT for client %s ",name, client);
489 TGo4Log::Debug(
" TaskHandler: Channel %s getport TIMEOUT for client %s ",name, client);
495 localbuffer.Form(
"%d",port);
496 negotiator->
Send(localbuffer.Data());
498 revchar=negotiator->
RecvRaw(
"dummy");
506 TGo4Log::Debug(
" TaskHandler: Negotiation ERROR after Channel %s open for client %s ",
516 TGo4Log::Debug(
" TaskHandler: Channel %s connect TIMEOUT for client %s ", name, client);
523 TGo4Log::Debug(
" TaskHandler: Channel %s for client %s open!",name, client);
532 if(negotiator==0 || !negotiator->
IsOpen())
534 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
539 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
543 recvchar=negotiator->
RecvRaw(
"dummy");
544 if(recvchar && !strcmp(recvchar,
fgcOK))
547 recvchar=negotiator->
RecvRaw(
"dummy");
548 TString localbuffer = recvchar;
549 port=atoi(localbuffer.Data());
551 channel->
Open(host,port);
552 TGo4Log::Debug(
" TaskHandler %s: Channel %s open!",GetName(), name );
558 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Channel %s ",
624 if(name==0)
return kFALSE;
626 if(thread==0)
return kFALSE;
628 Bool_t timeout=kFALSE;
631 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)
const char * GetDatName() const
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="")
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
Bool_t IsAborting() const
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
Bool_t IsClientMode() const
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)
TGo4Queue * GetCommandQueue() const
static const UInt_t fguSTATUSQUEUESIZE
void SetConnect(TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
TGo4Queue * fxCommandQueue
TGo4StatusRunnable * fxStatusRun
TGo4Socket * fxCommandTransport
Bool_t WaitThreadStop(const char *name)
static const UInt_t fguPORTWAITTIME
TGo4CommandRunnable * fxCommandRun
static const char * fgcCONNECT
Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
TGo4Socket * fxStatusTransport
TGo4ThreadHandler * GetWorkHandler() const
void SetFlags(Bool_t isaborting)
static const char * fgcOK
const char * GetComName() const
const char * GetStatName() const
static const char * fgcCOMMANDTHREAD
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)
const char * GetHostName() const
TGo4ThreadHandler * fxThreadHandler
Bool_t Start(const char *thname)
virtual TGo4TaskHandlerStatus * CreateStatus()
virtual ~TGo4TaskHandler()
Bool_t IsMasterMode() 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
virtual char * RecvRaw(const char *name=0)
TGo4Queue * fxStatusQueue
TGo4CommandInvoker * fxInvoker
TGo4Socket * ServerRequest(const char *host="localhost")
virtual void Clear(Option_t *opt="")
Int_t WaitGetPort(TGo4Socket *sock)
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=0)
void SetNames(const char *com, const char *stat, const char *dat, const char *host)
Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account)
static void Debug(const char *text,...)
void CloseChannels(Option_t *opt="")