65 :TNamed(name,
"This is a Go4 Task Handler"),
73 TGo4Log::Debug(
" TaskHandler -- constructor error, unspecified ThreadManager: aborting ");
82 if(negotiationport==0)
104 namebuffer.Form(
"CommandRunnable of %s",GetName());
108 namebuffer.Form(
"StatusRunnable of %s",GetName());
112 namebuffer.Form(
"DataRunnable of %s",GetName());
164 connector->
Send(myname.Data());
165 connector->
Send(gSystem->HostName());
174 gSystem->Sleep(1000);
178 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
192 TGo4Log::Debug(
" TaskHandler %s connecting to host %s ...",GetName(),host);
208 recvchar=connector->
RecvRaw(
"dummy");
211 TGo4Log::Debug(
" TaskHandler %s; Error on server connection, abortin... ",GetName());
218 TGo4Log::Debug(
" TaskHandler %s; Server refuses Connection",GetName());
221 gSystem->Sleep(1000);
228 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Command Channel",GetName());
233 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Status Channel",GetName());
238 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Data Channel",GetName());
243 gSystem->Sleep(1000);
246 TGo4Log::Debug(
" TaskHandler %s closed negotiation connection ",GetName());
252 TGo4Log::Debug(
" TaskHandler %s server connection ERROR ",GetName());
259 const char* client=GetName();
260 if(connector==0)
return kFALSE;
265 TGo4Log::Debug(
" TaskHandler: Command channel connect ERROR for client %s ",client);
270 TGo4Log::Debug(
" TaskManager: Status channel connect ERROR for client %s ",client);
275 TGo4Log::Debug(
" TaskManager: Data channel connect ERROR for client %s ",client);
290 if(connector==0)
return kFALSE;
329 char * recvchar=connector->
RecvRaw(
"dummy");
330 if(recvchar && !strcmp(recvchar,
fgcOK))
return kTRUE;
364 gSystem->Sleep(1000);
372 TGo4Log::Debug(
" TaskHandler %s server disconnect login ERROR - Trying Fast DisConnect... ",GetName());
381 TGo4Log::Debug(
" Client Aborting mode: Fast DisConnect... ",GetName());
447 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no server task ",name);
450 if(negotiator==0 || !negotiator->
IsOpen())
452 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
457 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
460 const char* client=GetName();
470 TGo4Log::Debug(
" TaskHandler: Channel %s open TIMEOUT for client %s ",name, client);
480 TGo4Log::Debug(
" TaskHandler: Channel %s getport TIMEOUT for client %s ",name, client);
485 localbuffer.Form(
"%d",port);
486 negotiator->
Send(localbuffer.Data());
488 revchar=negotiator->
RecvRaw(
"dummy");
496 TGo4Log::Debug(
" TaskHandler: Negotiation ERROR after Channel %s open for client %s ",
506 TGo4Log::Debug(
" TaskHandler: Channel %s connect TIMEOUT for client %s ", name, client);
513 TGo4Log::Debug(
" TaskHandler: Channel %s for client %s open!",name, client);
522 if(negotiator==0 || !negotiator->
IsOpen())
524 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no negotiation channel ",name);
529 TGo4Log::Debug(
" TaskHandler: Channel %s open ERROR: no TGo4Socket instance ",name);
533 recvchar=negotiator->
RecvRaw(
"dummy");
534 if(recvchar && !strcmp(recvchar,
fgcOK))
537 recvchar=negotiator->
RecvRaw(
"dummy");
538 TString localbuffer = recvchar;
539 port=atoi(localbuffer.Data());
541 channel->
Open(host,port);
542 TGo4Log::Debug(
" TaskHandler %s: Channel %s open!",GetName(), name );
548 TGo4Log::Debug(
" TaskHandler %s; negotiation error, FAILED to open Channel %s ",
615 if(name==0)
return kFALSE;
617 if(thread==0)
return kFALSE;
619 Bool_t timeout=kFALSE;
622 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="")