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);
Go4CommandMode_t
These values define command execution rights.
@ kGo4ComModeAdministrator
Class containing a pointer queue for TBuffers.
Runnable responsible for command exchange between transport (socket) and buffer (queue) In receiver m...
Runnable responsible for data object exchange between transport (socket) and buffer (queue) In receiv...
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Int_t WaitForConnection()
void SetConnect(TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
virtual Int_t Send(TObject *obj)
virtual Int_t Close(Option_t *opt="")
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
virtual char * RecvRaw(const char *name=nullptr)
Runnable responsible for status object exchange between transport (socket) and buffer (queue) In rece...
void SetPorts(UInt_t neg, Int_t com, Int_t stat, Int_t dat)
void SetNames(const char *com, const char *stat, const char *dat, const char *host)
void SetFlags(Bool_t isaborting)
void SetAborting(Bool_t isaborting=kTRUE)
sets the internal aborting state of this taskhandler instance; will be checked before an exception tr...
Bool_t IsClientMode() const
Check whether this instance is client or server taskhandler.
Int_t fiComPort
Command connection port number.
TGo4ThreadHandler * fxThreadHandler
link to external threadhandler which is used for the transport service threads (runnables); these run...
TGo4Socket * fxStatusTransport
static const char * fgcSTATUSTHREAD
Suffix for status thread name.
static TNamed fgxADMINISTRATORACCOUNT
This keeps account for admin connection.
Bool_t fbMasterMode
True if taskhandler runs in master mode (sends commands, receives data and status).
static UInt_t Get_fguPORTWAITTIME()
static const char * fgcCOMMANDTHREAD
Suffix for command thread name.
TGo4Socket * fxCommandTransport
Transport channels (e.g.
static void SetCtrlAccount(const char *name, const char *passwd)
Specify login name and password for controller account.
static const char * fgcCONNECT
Initial string for connect request (raw transport)
static const UInt_t fguCONNECTORPORT
Default port number of negotiation connection (raw transport)
Bool_t StopTransportThreads(Bool_t wait=kTRUE)
Stop all transport threads of this taskhandler (command, data, status).
UInt_t fuNegPort
Actual port number of negotiation connection (raw transport)
static const char * Get_fgcERROR()
Go4CommandMode_t fiRole
For server connection to client: This indicates role of connected client, if client is master.
TString fxComName
Remember name of command thread.
TGo4DataRunnable * fxDataRun
link to data runnable which is managed by thread handler 1 1
static void SetAdminAccount(const char *name, const char *passwd)
Specify login name and password for administrator account.
void CloseChannels(Option_t *opt="")
Close transport channels and clear queues.
virtual TGo4TaskHandlerStatus * CreateStatus()
create a status object with information on the current taskhandler state.
TString fxStatName
Remember name of status thread.
Bool_t IsAborting() const
Check whether this instance is currently being aborted.
Bool_t ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
method defining the connection protocol of one data transport channel (data, status,...
Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
Method defining the connection protocol of one data transport channel (data, status,...
Bool_t DisConnect(Bool_t waitforclient=kTRUE)
Closes the connections of all three transport channels.
static const char * fgcERROR
Error string for client connect negotiations (raw transport)
static TNamed fgxOBSERVERACCOUNT
This keeps account for observer connection.
static const UInt_t fguSTATUSQUEUESIZE
Maximum entries allowed for status queue.
static const char * fgcMASTER
Task identifier for client connect negotiations (raw transport)
void ClearQueues()
Clear all entries of queues.
Bool_t IsMasterMode() const
Check whether this instance is client or server taskhandler.
TGo4CommandInvoker * fxInvoker
Link to external command invoker instance used for direct command in client mode:
TGo4Queue * fxCommandQueue
Buffers (queues) for the three transport channels:
Bool_t fbIsAborting
True if taskhandler is being aborted e.g.
TGo4Queue * fxStatusQueue
TGo4Socket * fxDataTransport
static const char * fgcDISCONNECT
Initial string for disconnect request (raw transport)
static const char * fgcOK
Ok string for client connect negotiations (raw transport)
static const char * Get_fgcOK()
static const UInt_t fguCOMMANDQUEUESIZE
Maximum entries allowed for command queue.
static const UInt_t fguTHREADSTOPTIME
time for each threadstop wait cycle
static const Int_t fgiPORTWAITCYCLES
Cycles to wait for a nonzero portnumber.
static void SetObservAccount(const char *name, const char *passwd)
Specify login name and password for observer account.
Bool_t WaitThreadStop(const char *name)
Wait for the thread of name to be stopped.
void StartTransportThreads()
Start all transport threads of this taskhandler (command, data, status).
const char * GetHostName() const
TGo4ThreadManager * fxThreadManager
Link to threadmanager that owns the task handler, used for runnable ctors.
Int_t fiDatPort
Data connection port number.
Int_t WaitGetPort(TGo4Socket *sock)
Get actual local port number of specified Go4 socket.
TGo4Socket * ServerRequest(const char *host="localhost")
request to server at host to connect or disconnect us, returns negotiation channel
const char * GetComName() const
Bool_t fbClientMode
True if taskhandler runs in client mode.
TString fxHostName
Remember name of remote task handler.
Go4CommandMode_t GetRole()
static const UInt_t fguTRANSPORTCHECKDELAY
Delay time (ms) to wait between two checks of transport connection.
const char * GetDatName() const
TGo4StatusRunnable * fxStatusRun
link to status runnable which is managed by thread handler 1 1
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=nullptr)
establishes the connections of all three transport channels and starts the service threads
static const UInt_t fguDATAQUEUESIZE
Maximum entries allowed for data queue.
static const char * fgcSLAVE
Task identifier for client connect negotiations (raw transport)
static TNamed fgxCONTROLLERACCOUNT
This keeps account for controller connection.
static const char * fgcDATATHREAD
Suffix for data thread name.
TGo4Queue * GetCommandQueue() const
static const UInt_t fguPORTWAITTIME
Time for each waitgetport cycle.
TGo4CommandRunnable * fxCommandRun
link to command runnable which is managed by thread handler 1 1
static Int_t Get_fgiPORTWAITCYCLES()
Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account)
Negotiate login to requested server channel with account type.
const char * GetStatName() const
TString fxDatName
Remember name of data thread.
virtual ~TGo4TaskHandler()
Int_t fiStatPort
Status connection port number.
static const Int_t fgiTHREADSTOPCYCLES
cycles to wait for taskhandler thread stop on disconnection
Bool_t IsWaiting() const
true if Threadfunc is suspended to condition wait
static void Sleep(UInt_t millisecs)
wrapper for gSystem->Sleep with consecutive TThread::CancelPoint - necessary for proper pthread termi...