50 char *tempstring =
new char[strlen(s) + 1];
51 strcpy(tempstring, s);
53 char* tokenp = strtok(tempstring, tok);
56 tokenp = strtok(0, tok);
62 slist =
new string[num];
64 strcpy(tempstring, s);
65 tokenp = strtok(tempstring, tok);
67 slist[num++] = tokenp;
68 tokenp = strtok(0, tok);
83 : NumSMPs(0), FileSMPs(0), MySMP(0), ConfigOK(false) {
89 ERRORMSG(
"Null base filename in DiscConfig constructor." <<
endl);
105 while (smpiter != smpend) {
106 if ((*smpiter)->BaseFileNum > 0)
107 delete [] (*smpiter)->BaseFileName;
114 while (nodeiter != nodeend)
115 delete (*nodeiter++);
124 unsigned int nodesmp =
NodeList[node]->SMPIndex;
128 unsigned int numnodes =
SMPList[nodesmp]->NodeList.size();
151 const string& machine) {
157 if (s.length() == 0 || machine.length() == 0)
162 char *sptrbase = (
char*) scpy.c_str();
165 if (s.length() > 2 && s[0] ==
'.' && s[1] ==
'/')
169 char *sptr = sptrbase;
170 while (*sptr !=
'\0') {
175 if (sptr != sptrbase) {
184 while (*tok1 !=
'(' && *tok1 !=
'\0') ++tok1;
185 while (*tok2 !=
')' && *tok2 !=
'\0') ++tok2;
186 if (*tok1 ==
'\0' || *tok2 ==
'\0' || *tok2 <= *tok1) {
187 ERRORMSG(
"Unbalanced parenthesis in DiscConfig config file in line ");
195 string token(tok1 + 1);
198 }
else if (token ==
"node" || token ==
"n" || token ==
"N") {
204 char *env = getenv(token.c_str());
208 ERRORMSG(
"Unknown wildcard name '" << token.c_str()<<
"' in line ");
217 sptr = sptrbase = tok2 + 1;
222 if (sptr != sptrbase)
236 const string& machine,
258 for (
unsigned int sptr=0; sptr < smpd->
BaseFileNum; ++sptr) {
259 if (strcmp(basename.c_str(), (smpd->
BaseFileName[sptr]).c_str()) == 0) {
260 WARNMSG(
"DiscConfig: Duplicate configuration file entry '" << basename);
261 WARNMSG(
"' for host " << machine <<
" ... second one ignored." <<
endl);
271 WARNMSG(
"DiscConfig: Cannot write to more than one file per");
272 WARNMSG(
" SMP. Only the first file listed for host '");
299 const int bufferSize = 1024;
300 char bufferstore[bufferSize];
305 string NodeNameItems;
321 if (gethostname(
name, 1023) != 0) {
322 WARNMSG(
"DiscConfig: Could not get hostname. Using localhost." <<
endl);
323 strcpy(
name,
"localhost");
325 NodeNameItems =
name;
347 if ((inC = fopen(
ConfigFile.c_str(),
"r")) != 0) {
349 while (fgets(bufferstore, bufferSize, inC) != 0) {
351 buffer = bufferstore;
352 while (*buffer ==
' ' || *buffer ==
'\t' || *buffer ==
'\n')
354 if (*buffer ==
'#' || *buffer ==
'\0')
356 ConfigItems += buffer;
364 if (ConfigItems.length() == 0) {
371 NodeNameItems +=
" 0";
373 while (unreceived-- > 0) {
380 sprintf(
name,
" %s %d", nodename.c_str(), node);
381 NodeNameItems +=
name;
398 for (
int is=0; is < conflinenum; ++is) {
404 ERRORMSG(
"Wrong number of parameters in DiscConfig config file ");
409 if (tokens[1].c_str()[tokens[1].length() - 1] !=
'/')
411 tokens[1] += BaseFile;
412 if (tokens[0] ==
"*") {
414 WildCard = tokens[1];
420 if (smpiter !=
SMPMap.end())
421 smpd = (*smpiter).second;
436 if (
SMPMap.size() < 1 && WildCard.length() == 0) {
437 ERRORMSG(
"No hostname/directory pairs found in DiscConfig config file ");
448 int node = atoi(nodenames[2*in + 1].c_str());
449 string machine = nodenames[2*in];
454 if (smpiter !=
SMPMap.end()) {
456 smpdata = (*smpiter).second;
474 int firstSMPWithFiles = (-1);
476 for (smpa =
SMPMap.begin() ; smpa !=
SMPMap.end(); ++smpa) {
478 SMPData *smpdata = (*smpa).second;
485 if (firstSMPWithFiles < 0 && smpdata->BaseFileNum > 0)
486 firstSMPWithFiles = smpdata->
SMPIndex;
497 ERRORMSG(
"' was listed in the config file\n");
505 for ( ; nodea != smpdata->
NodeList.end(); ++nodea)
518 for (smpa =
SMPMap.begin() ; smpa !=
SMPMap.end(); ++smpa) {
519 SMPData *smpdata = (*smpa).second;
523 SMPList[firstSMPWithFiles]->InformSMPList.push_back(smpdata->
SMPIndex);
542 msg <<
"DiscConfig SMP Summary:" <<
endl;
543 for (
unsigned int smp=0; smp <
numSMPs(); ++smp) {
547 msg <<
" FileList =";
548 for (
unsigned int fl=0; fl <
getNumFiles(smp); ++fl)
551 msg <<
" OtherSMPList =";
555 msg <<
" NodeList =";
562 msg <<
"DiscConfig Node Summary:" <<
endl;
void putMessage(Message &m, const T &t)
void getMessage(Message &m, T &t)
#define DF_MAKE_HOST_MAP_TAG
Inform & endl(Inform &inf)
std::string::iterator iterator
bool send(Message *, int node, int tag, bool delmsg=true)
virtual int broadcast_others(Message *, int, bool delmsg=true)
Message * receive_block(int &node, int &tag)
int next_tag(int t, int s=1000)
unsigned int getNodeSMPIndex(unsigned int n) const
unsigned int getOtherSMP(unsigned int sn) const
std::vector< SMPData * > SMPList
std::string replace_wildcards(const std::string &s, const std::string &machine)
vmap< std::string, SMPData * > SMPMap
const std::string & getConfigFile() const
unsigned int getSMPBox0() const
unsigned int getNumNodes() const
unsigned int fileSMPs() const
unsigned int getNumOtherSMP() const
unsigned int numSMPs() const
std::vector< NodeData * > NodeList
unsigned int getSMPNode(unsigned int n) const
const std::string & getSMPHost() const
unsigned int getNumSMPNodes() const
const std::string & getFilename(unsigned int fn) const
unsigned int mySMP() const
void add_SMP_directory(SMPData *&, const std::string &s, const std::string &m, bool)
void printDebug(Inform &)
const std::string & getNodeHost(unsigned int n) const
DiscConfig(const char *, const char *, bool)
static int dc_tokenize_string(const char *s, const char *tok, std::string *&)
unsigned int getNumFiles() const
bool parse_config(const char *, bool)
unsigned int pNodesPerSMP(unsigned int node) const
std::string BaseFileNameStringList
std::string * BaseFileName
std::vector< int > NodeList
static void abort(const char *=0)
static Communicate * Comm
rep_type::iterator iterator
std::pair< Key, T > value_type