// @(#)root/proofx:$Id$
// Author: G. Ganis, Nov 2005

/*************************************************************************
 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TXProofMgr
#define ROOT_TXProofMgr


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TXProofMgr                                                           //
//                                                                      //
// The PROOF manager interacts with the PROOF server coordinator to     //
// create or destroy a PROOF session, attach to or detach from          //
// existing one, and to monitor any client activity on the cluster.     //
// At most one manager instance per server is allowed.                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TProofMgr
#include "TProofMgr.h"
#endif
#ifndef ROOT_TUrl
#include "TUrl.h"
#endif
#ifndef ROOT_TXHandler
#include "TXHandler.h"
#endif

//
// XPROOF client version: increase whenever a non backward compatible
// change occur
//  ->1      first version being tested by ALICE
const Int_t kXPROOF_Protocol = 1; 

class TStopwatch;
class TXSocket;

class TXProofMgr : public TProofMgr, public TXHandler {

private:

   TXSocket   *fSocket; // Connection to XRD

   Int_t Init(Int_t loglevel = -1);

   void CpProgress(const char *pfx, Long64_t bytes,
                   Long64_t size, TStopwatch *watch, Bool_t cr = kFALSE);
   TObjString *Exec(Int_t action,
                    const char *what, const char *how, const char *where);

public:
   TXProofMgr(const char *url, Int_t loglevel = -1, const char *alias = "");
   virtual ~TXProofMgr();

   Bool_t      HandleInput(const void *);
   Bool_t      HandleError(const void *in = 0);

   Bool_t      IsValid() const { return fSocket; }
   void        SetInvalid();

   TProof     *AttachSession(Int_t id, Bool_t gui = kFALSE)
                      { return TProofMgr::AttachSession(id, gui); }
   TProof     *AttachSession(TProofDesc *d, Bool_t gui = kFALSE);
   void        DetachSession(Int_t, Option_t * = "");
   void        DetachSession(TProof *, Option_t * = "");
   const char *GetMssUrl(Bool_t = kFALSE);
   TProofLog  *GetSessionLogs(Int_t ridx = 0, const char *stag = 0,
                              const char *pattern = "-v \"| SvcMsg\"",
                              Bool_t rescan = kFALSE);
   Bool_t      MatchUrl(const char *url);
   void        ShowROOTVersions();
   TList      *QuerySessions(Option_t *opt = "S");
   TObjString *ReadBuffer(const char *file, Long64_t ofs, Int_t len);
   TObjString *ReadBuffer(const char *file, const char *pattern);
   Int_t       Reset(Bool_t hard = kFALSE, const char *usr = 0);
   Int_t       SendMsgToUsers(const char *msg, const char *usr = 0);
   Int_t       SetROOTVersion(const char *tag);
   void        ShowWorkers();

   // Remote file system actions
   Int_t       Cp(const char *src, const char *dst = 0, const char *opts = 0);
   void        Find(const char *what = "~/", const char *how = "-type f", const char *where = 0);
   void        Grep(const char *what, const char *how = 0, const char *where = 0);
   void        Ls(const char *what = "~/", const char *how = 0, const char *where = 0);
   void        More(const char *what, const char *how = 0, const char *where = 0);
   Int_t       Rm(const char *what, const char *how = 0, const char *where = 0);
   void        Tail(const char *what, const char *how = 0, const char *where = 0);
   Int_t       Md5sum(const char *what, TString &sum, const char *where = 0);
   Int_t       Stat(const char *what, FileStat_t &st, const char *where = 0);

   Int_t       GetFile(const char *remote, const char *local, const char *opt = 0);
   Int_t       PutFile(const char *local, const char *remote, const char *opt = 0);

   ClassDef(TXProofMgr,0)  // XrdProofd PROOF manager interface
};

#endif
 TXProofMgr.h:1
 TXProofMgr.h:2
 TXProofMgr.h:3
 TXProofMgr.h:4
 TXProofMgr.h:5
 TXProofMgr.h:6
 TXProofMgr.h:7
 TXProofMgr.h:8
 TXProofMgr.h:9
 TXProofMgr.h:10
 TXProofMgr.h:11
 TXProofMgr.h:12
 TXProofMgr.h:13
 TXProofMgr.h:14
 TXProofMgr.h:15
 TXProofMgr.h:16
 TXProofMgr.h:17
 TXProofMgr.h:18
 TXProofMgr.h:19
 TXProofMgr.h:20
 TXProofMgr.h:21
 TXProofMgr.h:22
 TXProofMgr.h:23
 TXProofMgr.h:24
 TXProofMgr.h:25
 TXProofMgr.h:26
 TXProofMgr.h:27
 TXProofMgr.h:28
 TXProofMgr.h:29
 TXProofMgr.h:30
 TXProofMgr.h:31
 TXProofMgr.h:32
 TXProofMgr.h:33
 TXProofMgr.h:34
 TXProofMgr.h:35
 TXProofMgr.h:36
 TXProofMgr.h:37
 TXProofMgr.h:38
 TXProofMgr.h:39
 TXProofMgr.h:40
 TXProofMgr.h:41
 TXProofMgr.h:42
 TXProofMgr.h:43
 TXProofMgr.h:44
 TXProofMgr.h:45
 TXProofMgr.h:46
 TXProofMgr.h:47
 TXProofMgr.h:48
 TXProofMgr.h:49
 TXProofMgr.h:50
 TXProofMgr.h:51
 TXProofMgr.h:52
 TXProofMgr.h:53
 TXProofMgr.h:54
 TXProofMgr.h:55
 TXProofMgr.h:56
 TXProofMgr.h:57
 TXProofMgr.h:58
 TXProofMgr.h:59
 TXProofMgr.h:60
 TXProofMgr.h:61
 TXProofMgr.h:62
 TXProofMgr.h:63
 TXProofMgr.h:64
 TXProofMgr.h:65
 TXProofMgr.h:66
 TXProofMgr.h:67
 TXProofMgr.h:68
 TXProofMgr.h:69
 TXProofMgr.h:70
 TXProofMgr.h:71
 TXProofMgr.h:72
 TXProofMgr.h:73
 TXProofMgr.h:74
 TXProofMgr.h:75
 TXProofMgr.h:76
 TXProofMgr.h:77
 TXProofMgr.h:78
 TXProofMgr.h:79
 TXProofMgr.h:80
 TXProofMgr.h:81
 TXProofMgr.h:82
 TXProofMgr.h:83
 TXProofMgr.h:84
 TXProofMgr.h:85
 TXProofMgr.h:86
 TXProofMgr.h:87
 TXProofMgr.h:88
 TXProofMgr.h:89
 TXProofMgr.h:90
 TXProofMgr.h:91
 TXProofMgr.h:92
 TXProofMgr.h:93
 TXProofMgr.h:94
 TXProofMgr.h:95
 TXProofMgr.h:96
 TXProofMgr.h:97
 TXProofMgr.h:98
 TXProofMgr.h:99
 TXProofMgr.h:100
 TXProofMgr.h:101
 TXProofMgr.h:102
 TXProofMgr.h:103
 TXProofMgr.h:104
 TXProofMgr.h:105