16 #include "Riostream.h"
17 #include "TObjArray.h"
21 #include "TGo4LockGuard.h"
34 UInt_t negotiationport,
35 Bool_t createconnector)
36 : TNamed(name,
"This is a Go4TaskManager"),
37 fuTaskCount(0),fuNegotiationPort(0), fbClientIsRemoved(kFALSE), fbHasControllerConnection(kFALSE)
41 if(negotiationport==0)
60 TGo4Log::Debug(
"TaskManager: Created negotiation channel in ctor");
85 TString cliname, hostname;
100 std::cerr <<
" TaskManager TIMEOUT ERROR opening socket connection !!! Terminating..." << std::endl;
110 std::cerr <<
" TaskManager TIMEOUT ERROR retrieving port number !!! Terminating..." << std::endl;
125 std::cout <<
" Waiting for client connection on PORT: "<<
fuNegotiationPort << std::endl;
126 TGo4Log::Debug(
" TaskManager is waiting to serve client request on port %d ... ",
130 if(connectwaitseconds<0)
134 return connectwaitseconds;
179 TGo4Log::Debug(
" TaskManager: ServeClient received invalid login, closing negotiation port ", cliname.Data());
186 TGo4Log::Debug(
" TaskManager: Finished negotiations with client %s ", cliname.Data());
196 TGo4Log::Debug(
" TaskManager: Waiting for timer Close() of negotiation to client %s ... ", cliname.Data());
198 TGo4Log::Debug(
" TaskManager: Finished negotiations with client %s ", cliname.Data());
202 TGo4Log::Debug(
" TaskManager: ERROR on closing down negotiation channel, client %s ", cliname.Data());
237 Bool_t matching=kFALSE;
248 TGo4Log::Debug(
" TaskManager: Client does not match Server, Login failed!!!");
265 TGo4Log::Debug(
" TaskManager: Client logged in as 2nd controller, will be observer");
280 TGo4Log::Warn(
" TaskManager: Client logged in as 2nd controller, will be observer");
285 TGo4Log::Debug(
" TaskManager: Client logged in as administrator");
303 TString cliname=client;
304 if (!
AddClient(cliname.Data(),host,role)) rev=1;
311 TGo4Log::Info(
"TaskManager is disconnecting client %s %s ...", name, clientwait ?
"with waiting" :
"with no wait!" );
329 TString tname=taskhandler->GetName();
338 TGo4Log::Debug(
" TaskManager %s; negotiation ERROR after client disconnect!",GetName());
343 if(!taskhandler->
DisConnect(clientwait))rev+=1;
351 TGo4Log::Debug(
" TaskManager: client %s has been disconnected. ", tname.Data());
356 TGo4Log::Debug(
" TaskManager: client %s disconnect ERROR %d occured !! ", tname.Data(),rev);
364 TGo4Log::Debug(
" TaskManager: FAILED to disonnect client -- no such client! ");
375 TGo4Log::Warn(
" !!! TaskManager::AddClient ERROR: client of name %s is already exisiting !!! ",client);
383 TGo4Log::Info(
" TaskManager: Succesfully added new client %s (host %s, ports %d,%d,%d) ",
395 TGo4Log::Error(
" TaskManager: ERROR on connecting new client %s (host %s)", client, host);
458 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="")
static UInt_t Get_fguPORTWAITTIME()
Int_t GetStatPort() const
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()
void SetDisConnect(TGo4Socket *trans)
static const char * Get_fgcERROR()
static void Warn(const char *text,...)
Bool_t fbHasControllerConnection
static void Sleep(UInt_t millisecs)
static const char * Get_fgcOK()
void SendStopBuffers(const char *taskname=0)
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
Bool_t RemoveTaskHandler(const char *name)
static const char * fgcCONNECT
Int_t DisConnectClient(const char *name, Bool_t clientwait=kTRUE)
TGo4TaskHandler * GetTaskHandler(const char *name)
static const char * fgcMASTER
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
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
virtual char * RecvRaw(const char *name=0)
void SetCurrentTask(const char *name)
static const char * GetModeDescription(Go4CommandMode_t mode)
static void Error(const char *text,...)
TGo4TaskHandler * NewTaskHandler(const char *name)
static void Info(const char *text,...)
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=0)
static void Debug(const char *text,...)