TProofNodeInfo.cxx

Go to the documentation of this file.
00001 // @(#)root/proof:$Id: TProofNodeInfo.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Paul Nilsson   7/12/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TProofNodeInfo                                                       //
00015 //                                                                      //
00016 // Implementation of PROOF node info.                                   //
00017 // The purpose of this class is to provide a complete node description  //
00018 // for masters, submasters and workers.                                 //
00019 //                                                                      //
00020 //////////////////////////////////////////////////////////////////////////
00021 
00022 #include "TObjArray.h"
00023 #include "TObjString.h"
00024 #include "TProofNodeInfo.h"
00025 
00026 ClassImp(TProofNodeInfo)
00027 
00028 // Macros used in decoding serialized info
00029 #define PNISETANY(a) \
00030   { if (os->String() != "-") { a; } \
00031     if (!(os = (TObjString *) nxos())) return; }
00032 #define PNISETSTRING(s) PNISETANY(s = os->GetName())
00033 #define PNISETINT(i) PNISETANY(i = os->String().Atoi())
00034 
00035 //______________________________________________________________________________
00036 TProofNodeInfo::TProofNodeInfo():
00037    fNodeType(kWorker),
00038    fPort(-1),
00039    fPerfIndex(100)
00040 {
00041    // Constructor.
00042 }
00043 
00044 //______________________________________________________________________________
00045 TProofNodeInfo::TProofNodeInfo(const char *str)
00046                : fNodeType(kWorker), fPort(-1), fPerfIndex(100)
00047 {
00048    // Constructor from a string containing all the information in a serialized
00049    // way. Used to decode thr information coming from the coordinator
00050    // <type>|<host@user>|<port>|<ord>|<id>|<perfidx>|<img>|<workdir>|<msd>|<cfg>
00051 
00052    // Needs a non empty string to do something
00053    if (!str || strlen(str) <= 0)
00054       return;
00055 
00056    // Tokenize
00057    TString ss(str);
00058    TObjArray *oa = ss.Tokenize("|");
00059    if (!oa)
00060       return;
00061    TIter nxos(oa);
00062    TObjString *os = (TObjString *) nxos();
00063    if (!os)
00064       return;
00065 
00066    // Node type
00067    PNISETANY(fNodeType = GetNodeType(os->GetName()));
00068 
00069    // Host and user name
00070    PNISETSTRING(fNodeName);
00071 
00072    // Port
00073    PNISETINT(fPort);
00074 
00075    // Ordinal
00076    PNISETSTRING(fOrdinal);
00077 
00078    // ID string
00079    PNISETSTRING(fId);
00080 
00081    // Performance index
00082    PNISETINT(fPerfIndex);
00083 
00084    // Image
00085    PNISETSTRING(fImage);
00086 
00087    // Working dir
00088    PNISETSTRING(fWorkDir);
00089 
00090    // Mass Storage Domain
00091    PNISETSTRING(fMsd);
00092 
00093    // Config file (master or submaster; for backward compatibility)
00094    PNISETSTRING(fConfig);
00095 }
00096 
00097 //______________________________________________________________________________
00098 TProofNodeInfo::TProofNodeInfo(const TProofNodeInfo &nodeInfo) : TObject(nodeInfo)
00099 {
00100    // Copy constructor.
00101 
00102    fNodeType  = nodeInfo.fNodeType;
00103    fNodeName  = nodeInfo.fNodeName;
00104    fWorkDir   = nodeInfo.fWorkDir;
00105    fOrdinal   = nodeInfo.fOrdinal;
00106    fImage     = nodeInfo.fImage;
00107    fId        = nodeInfo.fId;
00108    fConfig    = nodeInfo.fConfig;
00109    fMsd       = nodeInfo.fMsd;
00110    fPort      = nodeInfo.fPort;
00111    fPerfIndex = nodeInfo.fPerfIndex;
00112 }
00113 
00114 //______________________________________________________________________________
00115 void TProofNodeInfo::Assign(const TProofNodeInfo &n)
00116 {
00117    // Asssign content of node n to this node
00118 
00119    fNodeType  = n.fNodeType;
00120    fNodeName  = n.fNodeName;
00121    fWorkDir   = n.fWorkDir;
00122    fOrdinal   = n.fOrdinal;
00123    fImage     = n.fImage;
00124    fId        = n.fId;
00125    fConfig    = n.fConfig;
00126    fMsd       = n.fMsd;
00127    fPort      = n.fPort;
00128    fPerfIndex = n.fPerfIndex;
00129 }
00130 
00131 //______________________________________________________________________________
00132 void TProofNodeInfo::Print(const Option_t *opt) const
00133 {
00134    // Print the TProofNodeInfo structure.
00135 
00136    if (opt[0] == 'c' || opt[0] == 'C') {
00137       Printf("%d %s:%d %s %s", fNodeType, fNodeName.Data(), fPort,
00138                                fOrdinal.Data(), fWorkDir.Data());
00139    } else {
00140       Printf(" NodeType:      %d", fNodeType);
00141       Printf(" NodeName:      %s", fNodeName.Data());
00142       Printf(" WorkDir:       %s", fWorkDir.Data());
00143       Printf(" Ordinal:       %s", fOrdinal.Data());
00144       Printf(" Image:         %s", fImage.Data());
00145       Printf(" Id:            %s", fId.Data());
00146       Printf(" Config:        %s", fConfig.Data());
00147       Printf(" Msd:           %s", fMsd.Data());
00148       Printf(" Port:          %d", fPort);
00149       Printf(" Performance:   %d\n", fPerfIndex);
00150    }
00151 }
00152 
00153 //______________________________________________________________________________
00154 TProofNodeInfo::ENodeType TProofNodeInfo::GetNodeType(const TString &type)
00155 {
00156    // Static method returning node type. Allowed input: "master", "submaster",
00157    // or anything else which will be interpreted as worker.
00158 
00159    ENodeType enType;
00160 
00161    if (type == "M" || type == "master") {
00162       enType = kMaster;
00163    }
00164    else if (type == "S" || type == "submaster") {
00165       enType = kSubMaster;
00166    }
00167    else { // [worker/slave or condorworker]
00168       enType = kWorker;
00169    }
00170 
00171    return enType;
00172 }

Generated on Tue Jul 5 14:51:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1