/* * queue a Ping request for this route */ int ebxml_qping (XML *xml, int route) { QUEUE *q; QUEUEROW *r; int pl; char *ch, buf[MAX_PATH], pid[PTIMESZ]; /* * queue it up */ ch = cfg_route (xml, route, "Queue"); debug ("queuing ping for %s\n", ch); if ((q = queue_find (ch)) == NULL) { error ("Can't find queue for %s\n", ch); return (-1); } ppid (pid); debug ("prepping new row\n"); r = queue_row_alloc (q); sprintf (buf, "%s-%s", cfg_route (xml, route, "Name"), pid); queue_field_set (r, "MESSAGEID", buf); queue_field_set (r, "PAYLOADFILE", ""); queue_field_set (r, "DESTINATIONFILENAME", ""); queue_field_set (r, "ROUTEINFO", cfg_route (xml, route, "Name")); queue_field_set (r, "SERVICE", "urn:oasis:names:tc:ebxml-msg:service"); queue_field_set (r, "ACTION", "Ping"); queue_field_set (r, "ARGUMENTS", cfg_route (xml, route, "Arguments")); queue_field_set (r, "MESSAGERECIPIENT", cfg_route (xml, route, "Recipient")); queue_field_set (r, "ENCRYPTION","no"); queue_field_set (r, "SIGNATURE", "no"); queue_field_set (r, "PUBLICKEYLDAPADDRESS", ""); queue_field_set (r, "PUBLICKEYLDAPBASEDN", ""); queue_field_set (r, "PUBLICKEYLDAPDN", ""); queue_field_set (r, "CERTIFICATEURL",""); queue_field_set (r, "PROCESSINGSTATUS", "queued"); queue_field_set (r, "TRANSPORTSTATUS", ""); queue_field_set (r, "PRIORITY", "0"); debug ("pushing the queue\n"); if (pl = queue_push (r) < 1) { error ("Failed queueing ping for %s\n", cfg_route (xml, route, "Name")); pl = -1; } queue_row_free (r); info ("ebXML Ping for %s queueing completed\n", cfg_route (xml, route, "Name")); return (0); }
/* * A folder polling processor for ebxml queues - register this with * the fpoller. * * This initializes and pushes a queue row. Once queued it moves * the file to a processed point. * * xml - sender's configuration * prefix - xml path to this folder map * fname - file to be queued */ int ebxml_fprocessor (XML *xml, char *prefix, char *fname) { struct stat st; QUEUE *q; QUEUEROW *r; char *ch; int pl; char qname[MAX_PATH], pid[PTIMESZ], buf[MAX_PATH]; if (stat (fname, &st)) { warn ("Can't access %s\n", fname); return (-1); } if (st.st_size == 0) { warn ("File %s empty... discarding\n", fname); unlink (fname); return (-1); } info ("Queuing ebXML folder %s for %s\n", fname, prefix); pl = strlen (prefix); /* * prep a file name */ ppid (pid); sprintf (qname, "%s.%s", basename (fname), pid); /* * move file to processed folder */ ppathf (buf, xml_getf (xml, "%sProcessed", prefix), "%s", qname); if (rename (fname, buf)) { error ("Couldn't move %s to %s - %s\n", fname, buf, strerror (errno)); return (-1); } /* * queue it up */ ch = xml_getf (xml, "%sQueue", prefix); if ((q = queue_find (ch)) == NULL) { error ("Can't find queue for %s\n", ch); return (-1); } r = queue_row_alloc (q); sprintf (buf, "%s-%s", xml_getf (xml, "%sName", prefix), pid); queue_field_set (r, "MESSAGEID", buf); queue_field_set (r, "PAYLOADFILE", qname); queue_field_set (r, "DESTINATIONFILENAME", basename (fname)); queue_field_set (r, "ROUTEINFO", xml_getf (xml, "%sRoute", prefix)); queue_field_set (r, "SERVICE", xml_getf (xml, "%sService", prefix)); queue_field_set (r, "ACTION", xml_getf (xml, "%sAction", prefix)); queue_field_set (r, "ARGUMENTS", xml_getf (xml, "%sArguments", prefix)); queue_field_set (r, "MESSAGERECIPIENT", xml_getf (xml, "%sRecipient", prefix)); queue_field_set (r, "ENCRYPTION", *xml_getf (xml, "%sEncryption.Type", prefix) ? "yes" : "no"); queue_field_set (r, "SIGNATURE", "no"); queue_field_set (r, "PUBLICKEYLDAPADDRESS", ""); queue_field_set (r, "PUBLICKEYLDAPBASEDN", ""); queue_field_set (r, "PUBLICKEYLDAPDN", ""); queue_field_set (r, "CERTIFICATEURL", xml_getf (xml, "%sEncryption.Unc", prefix)); queue_field_set (r, "PROCESSINGSTATUS", "queued"); queue_field_set (r, "TRANSPORTSTATUS", ""); queue_field_set (r, "PRIORITY", "0"); if (pl = queue_push (r) < 1) { error ("Failed queueing %s\n", fname); pl = -1; } queue_row_free (r); info ("ebXML folder %s for %s queueing completed\n", fname, prefix); return (pl); }
void Foam::argList::parse ( bool checkArgs, bool checkOpts, bool initialise ) { // Help/documentation options: // -help print the usage // -doc display application documentation in browser // -srcDoc display source code in browser if ( options_.found("help") || options_.found("doc") || options_.found("srcDoc") ) { if (options_.found("help")) { printUsage(); } // Only display one or the other if (options_.found("srcDoc")) { displayDoc(true); } else if (options_.found("doc")) { displayDoc(false); } ::exit(0); } // Print the usage message and exit if the number of arguments is incorrect if (!check(checkArgs, checkOpts)) { FatalError.exit(); } if (initialise) { string dateString = clock::date(); string timeString = clock::clockTime(); // Print the banner once only for parallel runs if (Pstream::master() && bannerEnabled) { IOobject::writeBanner(Info, true) << "Build : " << Foam::FOAMbuild << nl << "Exec : " << argListStr_.c_str() << nl << "Date : " << dateString.c_str() << nl << "Time : " << timeString.c_str() << nl << "Host : " << hostName() << nl << "PID : " << pid() << endl; } jobInfo.add("startDate", dateString); jobInfo.add("startTime", timeString); jobInfo.add("userName", userName()); jobInfo.add("foamVersion", word(FOAMversion)); jobInfo.add("code", executable_); jobInfo.add("argList", argListStr_); jobInfo.add("currentDir", cwd()); jobInfo.add("PPID", ppid()); jobInfo.add("PGID", pgid()); // Add build information - only use the first word { std::string build(Foam::FOAMbuild); std::string::size_type found = build.find(' '); if (found != std::string::npos) { build.resize(found); } jobInfo.add("foamBuild", build); } } // Case is a single processor run unless it is running parallel int nProcs = 1; // Roots if running distributed fileNameList roots; // If this actually is a parallel run if (parRunControl_.parRun()) { // For the master if (Pstream::master()) { // Establish rootPath_/globalCase_/case_ for master getRootCase(); // See if running distributed (different roots for different procs) label dictNProcs = -1; fileName source; if (options_.found("roots")) { source = "-roots"; IStringStream is(options_["roots"]); roots = readList<fileName>(is); if (roots.size() != 1) { dictNProcs = roots.size()+1; } } else { source = rootPath_/globalCase_/"system/decomposeParDict"; IFstream decompDictStream(source); if (!decompDictStream.good()) { FatalError << "Cannot read " << decompDictStream.name() << exit(FatalError); } dictionary decompDict(decompDictStream); dictNProcs = readLabel ( decompDict.lookup("numberOfSubdomains") ); if (decompDict.lookupOrDefault("distributed", false)) { decompDict.lookup("roots") >> roots; } } // Convenience: // when a single root is specified, use it for all processes if (roots.size() == 1) { const fileName rootName(roots[0]); roots.setSize(Pstream::nProcs()-1, rootName); // adjust dictNProcs for command-line '-roots' option if (dictNProcs < 0) { dictNProcs = roots.size()+1; } } // Check number of processors. // nProcs => number of actual procs // dictNProcs => number of procs specified in decompositionDict // nProcDirs => number of processor directories // (n/a when running distributed) // // - normal running : nProcs = dictNProcs = nProcDirs // - decomposition to more processors : nProcs = dictNProcs // - decomposition to fewer processors : nProcs = nProcDirs if (dictNProcs > Pstream::nProcs()) { FatalError << source << " specifies " << dictNProcs << " processors but job was started with " << Pstream::nProcs() << " processors." << exit(FatalError); } // Distributed data if (roots.size()) { if (roots.size() != Pstream::nProcs()-1) { FatalError << "number of entries in roots " << roots.size() << " is not equal to the number of slaves " << Pstream::nProcs()-1 << exit(FatalError); } forAll(roots, i) { roots[i].expand(); } // Distribute the master's argument list (with new root) bool hadCaseOpt = options_.found("case"); for ( int slave = Pstream::firstSlave(); slave <= Pstream::lastSlave(); slave++ ) { options_.set("case", roots[slave-1]/globalCase_); OPstream toSlave(Pstream::scheduled, slave); toSlave << args_ << options_; } options_.erase("case"); // Restore [-case dir] if (hadCaseOpt) { options_.set("case", rootPath_/globalCase_); } } else { // Possibly going to fewer processors. // Check if all procDirs are there. if (dictNProcs < Pstream::nProcs()) { label nProcDirs = 0; while ( isDir ( rootPath_/globalCase_/"processor" + name(++nProcDirs) ) ) {} if (nProcDirs != Pstream::nProcs()) { FatalError << "number of processor directories = " << nProcDirs << " is not equal to the number of processors = " << Pstream::nProcs() << exit(FatalError); } } // Distribute the master's argument list (unaltered) for ( int slave = Pstream::firstSlave(); slave <= Pstream::lastSlave(); slave++ ) { OPstream toSlave(Pstream::scheduled, slave); toSlave << args_ << options_; } } }