<commit_before>// @(#)root/proof:$Name:  $:$Id: TProofNodeInfo.cxx,v 1.1 2005/12/09 01:12:17 rdm Exp $
// Author: <NAME>   7/12/2005

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

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TProofNodeInfo                                                       //
//                                                                      //
// Implementation of PROOF node info.                                   //
// The purpose of this class is to provide a complete node description  //
// for masters, submasters and workers.                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TObjArray.h"
#include "TObjString.h"
#include "TProofNodeInfo.h"

ClassImp(TProofNodeInfo)

// Macros used in decoding serialized info
#define PNISETANY(a) \
  { if (os->String() != "-") { a; } \
    if (!(os = (TObjString *) nxos())) return; }
#define PNISETSTRING(s) PNISETANY(s = os->GetName())
#define PNISETINT(i) PNISETANY(i = os->String().Atoi())

//______________________________________________________________________________
TProofNodeInfo::TProofNodeInfo():
   fNodeType(kWorker),
   fPort(-1),
   fPerfIndex(100)
{
   // Constructor.
}

//______________________________________________________________________________
TProofNodeInfo::TProofNodeInfo(const char *str)
               : fNodeType(kWorker), fPort(-1), fPerfIndex(100)
{
   // Constructor from a string containing all the information in a serialized
   // way. Used to decode thr information coming from the coordinator
   // <type>|<host@user>|<port>|<ord>|<id>|<perfidx>|<img>|<workdir>|<msd>|<cfg>

   // Needs a non empty string to do something
   if (!str || strlen(str) <= 0)
      return;

   // Tokenize
   TString ss(str);
   TObjArray *oa = ss.Tokenize("|");
   if (!oa)
      return;
   TIter nxos(oa);
   TObjString *os = (TObjString *) nxos();
   if (!os)
      return;

   // Node type
   PNISETANY(fNodeType = GetNodeType(os->GetName()));

   // Host and user name
   PNISETSTRING(fNodeName);

   // Port
   PNISETINT(fPort);

   // Ordinal
   PNISETSTRING(fOrdinal);

   // ID string
   PNISETSTRING(fId);

   // Performance index
   PNISETINT(fPerfIndex);

   // Image
   PNISETSTRING(fImage);

   // Working dir<commit_msg>From Gerri: - make sure that fImage defaults to the host name<commit_after>// @(#)root/proof:$Name:  $:$Id: TProofNodeInfo.cxx,v 1.2 2006/03/16 08:49:28 rdm Exp $
// Author: <NAME>   7/12/2005

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

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TProofNodeInfo                                                       //
//                                                                      //
// Implementation of PROOF node info.                                   //
// The purpose of this class is to provide a complete node description  //
// for masters, submasters and workers.                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TObjArray.h"
#include "TObjString.h"
#include "TProofNodeInfo.h"

ClassImp(TProofNodeInfo)

// Macros used in decoding serialized info
#define PNISETANY(a) \
  { if (os->String() != "-") { a; } \
    if (!(os = (TObjString *) nxos())) return; }
#define PNISETSTRING(s) PNISETANY(s = os->GetName())
#define PNISETINT(i) PNISETANY(i = os->String().Atoi())

//______________________________________________________________________________
TProofNodeInfo::TProofNodeInfo():
   fNodeType(kWorker),
   fPort(-1),
   fPerfIndex(100)
{
   // Constructor.
}

//______________________________________________________________________________
TProofNodeInfo::TProofNodeInfo(const char *str)
               : fNodeType(kWorker), fPort(-1), fPerfIndex(100)
{
   // Constructor from a string containing all the information in a serialized
   // way. Used to decode thr information coming from the coordinator
   // <type>|<host@user>|<port>|<ord>|<id>|<perfidx>|<img>|<workdir>|<msd>|<cfg>

   // Needs a non empty string to do something
   if (!str || strlen(str) <= 0)
      return;

   // Tokenize
   TString ss(str);
   TObjArray *oa = ss.Tokenize("|");
   if (!oa)
      return;
   TIter nxos(oa);
   TObjString *os = (TObjString *) nxos();
   if (!os)
      return;

   // Node type
   PNISETANY(fNodeType = GetNodeType(os->GetName()));

   // Host and user name
   PNISETSTRING(fNodeName);

   // Default image is the node name
   fImage = fNodeName;
   fImage.Remove(0, fImage.Index("@")+1);

   // Port
   PNISETINT(fPort);

   // Ordinal
   PNISETSTRING(fOrdinal);

   // ID string
   PNISETSTRING(fId);

   // Performance index
   PNISETINT(fPerfIndex);

   // Image
   PNISETSTRING(fImage);

   // Working dir
{'fraction_non_alphanumeric': 0.20889109238142456, 'fraction_numerical': 0.013551479094364568, 'mean_word_length': 1.5940848692670382, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3599942', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1519, 'n_words': 369}