52int getDebugEnum(
const char *
what);
 
   53Int_t getXrootdPid(
Int_t port, 
const char *subdir = 
"xpdtut");
 
   54Int_t checkXrootdAt(
Int_t port, 
const char *host = 
"localhost");
 
   55Int_t checkXproofdAt(
Int_t port, 
const char *host = 
"localhost");
 
   57Int_t killXrootdAt(
Int_t port, 
const char *
id = 0);
 
   76const char *refloc = 
"proof://localhost:40000";
 
   78TProof *getProof(
const char *url = 
"proof://localhost:40000", 
Int_t nwrks = -1, 
const char *dir = 0,
 
   91      while (s.Tokenize(t, from , 
" ")) {
 
   97      if (vopts.
IsNull()) vopts = 
"valgrind_opts:--leak-check=full --track-origins=yes";
 
   99      Printf(
"getProof: valgrind run: '%s' (opts: '%s')", vopt.
Data(), vopts.
Data());
 
  104   TUrl uu(url), uref(refloc);
 
  105   Bool_t ext = (strcmp(uu.GetHost(), uref.GetHost()) ||
 
  106                 (uu.GetPort() != uref.GetPort())) ? 
kTRUE : 
kFALSE;
 
  109      if (!strcmp(url, 
"lite://") || !url[0]) {
 
  110         if (!url[0]) uu.SetUrl(
"lite://");
 
  111         if (dir && strlen(dir) > 0) 
gEnv->
SetValue(
"Proof.Sandbox", dir);
 
  112         TString swrk(
"<default> workers");
 
  114            uu.SetOptions(
Form(
"workers=%d", nwrks));
 
  115            swrk.Form(
"%d workers", nwrks);
 
  119         Printf(
"getProof: trying to open a PROOF-Lite session with %s", swrk.Data());
 
  121         Printf(
"getProof: trying to open a session on the external cluster at '%s'", url);
 
  124      if (
p && 
p->IsValid()) {
 
  126         if (ext && !lite && nwrks > 0) {
 
  127            Printf(
"getProof: WARNING: started/attached a session on external cluster (%s):" 
  128                   " 'nwrks=%d' ignored", url, nwrks);
 
  130         if (ext && !lite && dir && strlen(dir) > 0) {
 
  131            Printf(
"getProof: WARNING: started/attached a session on external cluster (%s):" 
  132                   " 'dir=\"%s\"' ignored", url, dir);
 
  134         if (ext && !strcmp(opt,
"force")) {
 
  135            Printf(
"getProof: WARNING: started/attached a session on external cluster (%s):" 
  136                   " 'opt=\"force\"' ignored", url);
 
  139            Printf(
"getProof: WARNING: started/attached a session on external cluster (%s):" 
  140                   " 'dyn=kTRUE' ignored", url);
 
  143         Printf(
"getProof: could not get/start a valid session at %s", url);
 
  153   Printf(
"getProof: local PROOF not yet supported on Windows, sorry!");
 
  165               Printf(
"getProof: unable to create the working area at the requested path: '%s'" 
  166                      " - cannot continue", tutdir.
Data());
 
  168               Printf(
"getProof: working area at the requested path '%s'" 
  169                      " created but it is not writable - cannot continue", tutdir.
Data());
 
  177            Printf(
"getProof: working area at the requested path '%s'" 
  178                      " exists but is not writable - cannot continue", tutdir.
Data());
 
  184      Printf(
"getProof: working area not specified temp ");
 
  191         Printf(
"getProof: could not get user info");
 
  197      tutdir += 
"/.getproof";
 
  201            Printf(
"getProof: unable to get a writable working area (tried: %s)" 
  202                  " - cannot continue", tutdir.
Data());
 
  207   Printf(
"getProof: working area (tutorial dir): %s", tutdir.
Data());
 
  212      datasetdir = 
Form(
"%s/dataset", tutdir.
Data());
 
  216            Printf(
"getProof: unable to get a writable dataset directory (tried: %s)" 
  217                   " - cannot continue", datasetdir.
Data());
 
  220         Printf(
"getProof: dataset dir: %s", datasetdir.
Data());
 
  226   u.SetProtocol(
"proof");
 
  227   if (!strcmp(uu.GetHost(), uref.GetHost()) && (uu.GetPort() != uref.GetPort()))
 
  228      u.SetPort(uu.GetPort());
 
  229   Int_t lportp = u.GetPort();
 
  230   Int_t lportx = lportp + 1;
 
  246   if ((rc = checkXproofdAt(lportp)) == 1) {
 
  247      Printf(
"getProof: something else the a XProofd service is running on" 
  248             " port %d - cannot continue", lportp);
 
  251   } 
else if (rc == 0) {
 
  255      pid = getXrootdPid(lportx);
 
  256      Printf(
"getProof: daemon found listening on dedicated ports {%d,%d} (pid: %d)",
 
  257              lportx, lportp, pid);
 
  258      if (isatty(0) == 0 || isatty(1) == 0) {
 
  262         if (!strcmp(opt,
"ask")) {
 
  263            char *answer = (
char *) Getline(
"getProof: would you like to restart it (N,Y)? [N] ");
 
  264            if (answer && (answer[0] == 
'Y' || answer[0] == 
'y'))
 
  268      if (!strcmp(opt,
"force"))
 
  274         Printf(
"getProof: cleaning existing instance ...");
 
  276         cmd = 
Form(
"kill -9 %d", pid);
 
  278            Printf(
"getProof: problems stopping xrootd process %d (%d)", pid, rc);
 
  280         Printf(
"getProof: wait 5 secs so that previous connections are cleaned ...");
 
  290         Printf(
"getProof: xproofd not found: please check the environment!");
 
  295      cmd = 
Form(
"rm -fr %s/xpdtut %s %s %s %s", tutdir.
Data(), workarea.
Data(),
 
  296                                                 xpdcf.Data(), xpdpid.Data(), proofsessions.Data());
 
  300      FILE *fcf = fopen(xpdcf.Data(), 
"w");
 
  302         Printf(
"getProof: could not create config file for XPD (%s)", xpdcf.Data());
 
  305      fprintf(fcf,
"### Use admin path at %s/admin to avoid interferences with other users\n", tutdir.
Data());
 
  306      fprintf(fcf,
"xrd.adminpath %s/admin\n", tutdir.
Data());
 
  307#if defined(R__MACOSX) 
  308      fprintf(fcf,
"### Use dedicated socket path under /tmp to avoid length problems\n");
 
  309      fprintf(fcf,
"xpd.sockpathdir /tmp/xpd-sock\n");
 
  311      fprintf(fcf,
"### Load the XrdProofd protocol on port %d\n", lportp);
 
  312      fprintf(fcf,
"xrd.protocol xproofd libXrdProofd.so\n");
 
  313      fprintf(fcf,
"xpd.port %d\n", lportp);
 
  315         fprintf(fcf,
"### Force number of local workers\n");
 
  316         fprintf(fcf,
"xpd.localwrks %d\n", nwrks);
 
  318      fprintf(fcf,
"### Root path for working dir\n");
 
  319      fprintf(fcf,
"xpd.workdir %s\n", workarea.
Data());
 
  320      fprintf(fcf,
"### Allow different users to connect\n");
 
  321      fprintf(fcf,
"xpd.multiuser 1\n");
 
  322      fprintf(fcf,
"### Limit the number of query results kept in the master sandbox\n");
 
  323      fprintf(fcf,
"xpd.putrc ProofServ.UserQuotas: maxquerykept=2\n");
 
  324      fprintf(fcf,
"### Limit the number of sessions kept in the sandbox\n");
 
  325      fprintf(fcf,
"xpd.putrc Proof.MaxOldSessions: 1\n");
 
  327         fprintf(fcf,
"### Use dataset directory under the tutorial dir\n");
 
  328         fprintf(fcf,
"xpd.datasetsrc file url:%s opt:-Cq:Av:As:\n", datasetdir.
Data());
 
  331         fprintf(fcf,
"### Use dynamic, per-job scheduling\n");
 
  332         fprintf(fcf,
"xpd.putrc Proof.DynamicStartup 1\n");
 
  334      fprintf(fcf,
"### For internal file serving use the xrootd protocol on the same port\n");
 
  335      fprintf(fcf,
"xpd.xrootd libXrdXrootd-4.so\n");
 
  336      fprintf(fcf,
"### Set the local data server for the temporary output files accordingly\n");
 
  337      fprintf(fcf,
"xpd.putenv LOCALDATASERVER=root://%s:%d\n", 
gSystem->
HostName(), lportp);
 
  339      Printf(
"getProof: xproofd config file at %s", xpdcf.Data());
 
  342      Printf(
"getProof: xproofd log file at %s", xpdlogprt.Data());
 
  343      cmd = 
Form(
"%s -c %s -b -l %s -n xpdtut -p %d",
 
  344               xpd, xpdcf.Data(), xpdlog.Data(), lportp);
 
  345      Printf(
"(NB: any error line from XrdClientSock::RecvRaw and XrdClientMessage::ReadRaw should be ignored)");
 
  347         Printf(
"getProof: problems starting xproofd (%d)", rc);
 
  353      Printf(
"getProof: waiting for xproofd to start ...");
 
  356      pid = getXrootdPid(lportp);
 
  357      Printf(
"getProof: xproofd pid: %d", pid);
 
  360      FILE *fpid = fopen(xpdpid.Data(), 
"w");
 
  362         Printf(
"getProof: could not create pid file for XPD");
 
  364         fprintf(fpid,
"%d\n", pid);
 
  368   Printf(
"getProof: start / attach the PROOF session ...");
 
  372   if (!
p || !(
p->IsValid())) {
 
  373      Printf(
"getProof: starting local session failed");
 
  384Int_t getXrootdPid(
Int_t port, 
const char *subdir)
 
  388   Printf(
"getXrootdPid: Xrootd/Proof not supported on Windows, sorry!");
 
  394   const char *com = 
"-eo pid,comm";
 
  395#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 
  396   const char *com = 
"ax -w -w";
 
  398   const char *com = 
"-w -w -eo pid,command";
 
  401   if (subdir && strlen(subdir) > 0) {
 
  402      cmd.
Form(
"ps %s | grep xrootd | grep \"\\-p %d\" | grep %s", com, port, subdir);
 
  404      cmd.
Form(
"ps %s | grep xrootd | grep \"\\-p %d\"", com, port);
 
  408      char line[2048], rest[2048];
 
  409      while (fgets(
line, 
sizeof(
line), fp)) {
 
  410         sscanf(
line,
"%d %s", &pid, rest);
 
  420Int_t checkXrootdAt(
Int_t port, 
const char *host)
 
  430   if (!(s.IsValid())) {
 
  432         Printf(
"checkXrootdAt: could not open connection to %s:%d", host, port);
 
  437   memset(&initHS, 0, 
sizeof(initHS));
 
  440   int len = 
sizeof(initHS);
 
  441   s.SendRaw(&initHS, 
len);
 
  445   int readCount = s.RecvRaw(&
type, 
len); 
 
  446   if (readCount != 
len) {
 
  448         Printf(
"checkXrootdAt: 1st: wrong number of bytes read: %d (expected: %d)",
 
  458      readCount = s.RecvRaw(&xbody, 
len); 
 
  459      if (readCount != 
len) {
 
  461            Printf(
"checkXrootdAt: 2nd: wrong number of bytes read: %d (expected: %d)",
 
  466   } 
else if (
type == 8) {
 
  469         Printf(
"checkXrootdAt: server is ROOTD");
 
  474         Printf(
"checkXrootdAt: unknown server type: %d", 
type);
 
  481Int_t checkXproofdAt(
Int_t port, 
const char *host)
 
  491   if (!(s.IsValid())) {
 
  493         Printf(
"checkXproofdAt: could not open connection to %s:%d", host, port);
 
  498   memset(&initHS, 0, 
sizeof(initHS));
 
  500   int len = 
sizeof(initHS);
 
  501   s.SendRaw(&initHS, 
len);
 
  506   s.SendRaw(&dum[0], 
sizeof(dum));
 
  510   int readCount = s.RecvRaw(&
type, 
len); 
 
  511   if (readCount != 
len) {
 
  513         Printf(
"checkXproofdAt: 1st: wrong number of bytes read: %d (expected: %d)",
 
  523      readCount = s.RecvRaw(&xbody, 
len); 
 
  524      if (readCount != 
len) {
 
  526            Printf(
"checkXproofdAt: 2nd: wrong number of bytes read: %d (expected: %d)",
 
  534   } 
else if (
type == 8) {
 
  537         Printf(
"checkXproofdAt: server is PROOFD");
 
  542         Printf(
"checkXproofdAt: unknown server type: %d", 
type);
 
  556   Printf(
"startXrootdAt: Xrootd not supported on Windows, sorry!");
 
  563   if ((rc = checkXrootdAt(port)) == 1) {
 
  565      Printf(
"startXrootdAt: some other service running on port %d - cannot proceed ", port);
 
  568   } 
else if (rc == 0) {
 
  576         Printf(
"startXrootdAt: xrootd service already available on port %d: ", port);
 
  577         char *answer = (
char *) Getline(
"startXrootdAt: would you like to restart it (N,Y)? [N] ");
 
  578         if (answer && (answer[0] == 
'Y' || answer[0] == 
'y')) {
 
  585         Printf(
"startXrootdAt: cleaning existing instance ...");
 
  588         Int_t pid = getXrootdPid(port, 
"xrd-basic");
 
  593            Printf(
"startXrootdAt: problems stopping xrootd process %d (%d)", pid, rc);
 
  601            Printf(
"startXrootdAt: could not assert dir for log file");
 
  606      cmd.
Form(
"xrootd -d -p %d -b -l /tmp/xrd-basic/xrootd.log", port);
 
  607      if (exportdirs && strlen(exportdirs) > 0) {
 
  610         while (dirs.Tokenize(
d, from, 
" ")) {
 
  619         Printf(
"startXrootdAt: problems executing starting command (%d)", rc);
 
  623      Printf(
"startXrootdAt: waiting for xrootd to start ...");
 
  626      if ((rc = checkXrootdAt(port)) != 0) {
 
  627         Printf(
"startXrootdAt: xrootd service not available at %d (rc = %d) - startup failed",
 
  631      Printf(
"startXrootdAt: basic xrootd started!");
 
  645   Printf(
"killXrootdAt: Xrootd not supported on Windows, sorry!");
 
  649   Int_t pid = -1, rc= 0;
 
  650   if ((pid = getXrootdPid(port, 
id)) > 0) {
 
  655         Printf(
"killXrootdAt: problems stopping xrootd process %d (%d)", pid, rc);
 
  663int getDebugEnum(
const char *
what)
 
  671   while (sws.Tokenize(sw, from , 
"|")) {
 
  676      } 
else if (sw == 
"Packetizer") {
 
  678      } 
else if (sw == 
"Loop") {
 
  680      } 
else if (sw == 
"Selector") {
 
  682      } 
else if (sw == 
"Output") {
 
  684      } 
else if (sw == 
"Input") {
 
  686      } 
else if (sw == 
"Global") {
 
  688      } 
else if (sw == 
"Package") {
 
  690      } 
else if (sw == 
"Feedback") {
 
  692      } 
else if (sw == 
"Condor") {
 
  694      } 
else if (sw == 
"Draw") {
 
  696      } 
else if (sw == 
"Asyn") {
 
  698      } 
else if (sw == 
"Cache") {
 
  700      } 
else if (sw == 
"Collect") {
 
  702      } 
else if (sw == 
"Dataset") {
 
  704      } 
else if (sw == 
"Submerger") {
 
  706      } 
else if (sw == 
"Monitoring") {
 
  708      } 
else if (sw == 
"All") {
 
  710      } 
else if (!sw.
IsNull()) {
 
  711         Printf(
"WARNING: requested debug enum name '%s' does not exist: assuming 'All'", sw.
Data());
 
UShort_t host2net(UShort_t x)
 
UShort_t net2host(UShort_t x)
 
winID h TVirtualViewer3D TVirtualGLPainter p
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
 
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
 
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
 
R__EXTERN TSystem * gSystem
 
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
 
This class controls a Parallel ROOT Facility, PROOF, cluster.
 
static TProof * Open(const char *url=0, const char *conffile=0, const char *confdir=0, Int_t loglevel=0)
Start a PROOF session on a specific cluster.
 
static void AddEnvVar(const char *name, const char *value)
Add an variable to the list of environment variables passed to proofserv on the master and slaves.
 
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
 
const char * Data() const
 
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
 
TString & Remove(Ssiz_t pos)
 
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
 
virtual const char * Getenv(const char *env)
Get environment variable.
 
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
 
virtual Int_t Exec(const char *shellcmd)
Execute a command.
 
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
 
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
 
virtual int ClosePipe(FILE *pipe)
Close the pipe.
 
virtual const char * HostName()
Return the system's host name.
 
virtual Int_t GetUid(const char *user=nullptr)
Returns the user's id. If user = 0, returns current user's id.
 
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
 
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
 
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
 
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
 
This class represents a WWW compatible URL.