18 #include "TObjArray.h" 22 #include "TGo4LockGuard.h" 35 UInt_t negotiationport,
36 Bool_t createconnector)
37 : TNamed(name,
"This is a Go4TaskManager"),
38 fuTaskCount(0),fuNegotiationPort(0), fbClientIsRemoved(kFALSE), fbHasControllerConnection(kFALSE)
42 if(negotiationport == 0)
60 TGo4Log::Debug(
"TaskManager: Created negotiation channel in ctor");
62 fxTransport->
Open(
"Server mode does not need hostname", negotiationport, kTRUE);
83 char *recvchar =
nullptr;
84 TString cliname, hostname;
97 std::cerr <<
" TaskManager TIMEOUT ERROR opening socket connection !!! Terminating..." << std::endl;
107 std::cerr <<
" TaskManager TIMEOUT ERROR retrieving port number !!! Terminating..." << std::endl;
121 std::cout <<
" Waiting for client connection on PORT: "<<
fuNegotiationPort << std::endl;
122 TGo4Log::Debug(
" TaskManager is waiting to serve client request on port %d ... ",
126 if(connectwaitseconds < 0)
130 return connectwaitseconds;
175 TGo4Log::Debug(
" TaskManager: client %s received invalid login, closing negotiation port ", cliname.Data());
182 TGo4Log::Debug(
" TaskManager: Finished negotiations with client %s ", cliname.Data());
192 TGo4Log::Debug(
" TaskManager: Waiting for timer Close() of negotiation to client %s ... ", cliname.Data());
194 TGo4Log::Debug(
" TaskManager: Finished negotiations with client %s ", cliname.Data());
198 TGo4Log::Debug(
" TaskManager: ERROR on closing down negotiation channel, client %s ", cliname.Data());
236 Bool_t matching = kFALSE;
245 TGo4Log::Debug(
" TaskManager: Client does not match Server, Login failed!!!");
258 TGo4Log::Debug(
" TaskManager: Client logged in as 2nd controller, will be observer");
268 TGo4Log::Warn(
" TaskManager: Client logged in as 2nd controller, will be observer");
271 TGo4Log::Debug(
" TaskManager: Client logged in as administrator");
288 TString cliname = client;
289 if (!
AddClient(cliname.Data(),host,role)) rev = 1;
296 TGo4Log::Info(
"TaskManager is disconnecting client %s %s ...", name, clientwait ?
"with waiting" :
"with no wait!" );
313 TString tname = taskhandler->GetName();
320 TGo4Log::Debug(
" TaskManager %s; negotiation ERROR after client disconnect!", GetName());
332 if (iscontrollertask)
335 TGo4Log::Debug(
" TaskManager: client %s has been disconnected. ", tname.Data());
338 TGo4Log::Debug(
" TaskManager: client %s disconnect ERROR %d occured !! ", tname.Data(), rev);
342 TGo4Log::Debug(
" TaskManager: FAILED to disonnect client -- no such client! ");
352 TGo4Log::Warn(
" !!! TaskManager::AddClient ERROR: client of name %s is already existing !!! ",client);
359 TGo4Log::Info(
" TaskManager: Succesfully added new client %s (host %s, ports %d,%d,%d) ",
370 TGo4Log::Error(
" TaskManager: ERROR on connecting new client %s (host %s)", client, host);
420 if (taskhandler == currenttaskhandler) {
Bool_t DisConnect(Bool_t waitforclient=kTRUE)
virtual Int_t StartWorkThreads()
static TNamed fgxADMINISTRATORACCOUNT
Bool_t AddTaskHandler(TGo4TaskHandler *han)
virtual Int_t Close(Option_t *opt="")
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=nullptr)
static UInt_t Get_fguPORTWAITTIME()
virtual ~TGo4TaskManager()
TGo4TaskHandler * NextTaskHandler(Bool_t reset=kFALSE)
virtual Int_t Send(TObject *obj)
Int_t WaitForConnection()
Int_t ConnectClient(const char *client, const char *host, Go4CommandMode_t role=kGo4ComModeController)
UInt_t GetNegotiationPort()
static void Info(const char *text,...) GO4_PRINTF_ARGS
void SetDisConnect(TGo4Socket *trans)
void SendStopBuffers(const char *taskname=nullptr)
static const char * Get_fgcERROR()
Bool_t fbHasControllerConnection
static void Sleep(UInt_t millisecs)
static const char * Get_fgcOK()
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
void SetConnect(TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
TGo4ServerTask * fxServer
Go4CommandMode_t ClientLogin()
static const UInt_t fguDISCONTIME
Int_t GetStatPort() const
Bool_t RemoveTaskHandler(const char *name)
static void Debug(const char *text,...) GO4_PRINTF_ARGS
static const char * fgcCONNECT
Int_t DisConnectClient(const char *name, Bool_t clientwait=kTRUE)
virtual char * RecvRaw(const char *name=nullptr)
TGo4TaskHandler * GetTaskHandler(const char *name)
static const char * fgcMASTER
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
static void Error(const char *text,...) GO4_PRINTF_ARGS
Bool_t AddClient(const char *client, const char *host, Go4CommandMode_t role)
static const Int_t fgiDISCONCYCLES
static const UInt_t fguCONNECTORPORT
static TNamed fgxCONTROLLERACCOUNT
Go4CommandMode_t GetRole()
static const char * fgcSLAVE
void SetRole(Go4CommandMode_t role)
static TNamed fgxOBSERVERACCOUNT
TGo4TaskHandler * GetLastTaskHandler()
Bool_t IsTerminating() const
static Int_t Get_fgiPORTWAITCYCLES()
TGo4TaskHandler * GetCurrentTaskHandler()
Int_t WaitForClientRemoved()
static const char * fgcDISCONNECT
void SetCurrentTask(const char *name)
static const char * GetModeDescription(Go4CommandMode_t mode)
static void Warn(const char *text,...) GO4_PRINTF_ARGS
TGo4TaskHandler * NewTaskHandler(const char *name)