Changeset 10624 for trunk/FACT++/src
- Timestamp:
- 05/08/11 21:48:24 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/scheduler.cc
r10618 r10624 58 58 59 59 60 // config parameters 61 // mintime62 // runtimec63 // runtimep64 // repostime60 // config parameters: 61 // mintime 62 // runtimec 63 // runtimep 64 // repostime 65 65 66 66 // missing: … … 69 69 // calculate sun set/rise 70 70 // 71 // check for double std sources 72 // 73 // return errors 74 // get input from sendcommand 71 // return errors and other otherput from sendcommand to webinterface 75 72 76 73 // in which cases should the scheduler go in error state? … … 173 170 174 171 int fSessionId; 172 string fDBName; 175 173 176 174 … … 189 187 cout << "Scheduling for the period from " << startsched << " to " << stopsched << endl; 190 188 191 stringstream str;192 str << "Scheduling started -> Preview (id=" << fSessionId << ")";193 T::Message(str);194 195 189 static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))"); 196 190 // 2: user … … 216 210 const string passwd = what[4]; 217 211 const string server = what[5]; 218 const string db = what[9]; 212 string db = what[9]; 213 if (fDBName.size()!=0) 214 db = fDBName; 219 215 const int port = atoi(string(what[7]).c_str()); 216 217 stringstream dbnamemsg; 218 dbnamemsg << "Scheduling started -> using database " << fDBName << "."; 219 T::Message(dbnamemsg); 220 220 221 221 cout << "Connecting to '"; … … 633 633 */ 634 634 635 AutoScheduler(ostream &out=cout) : T(out, "SCHEDULER"), fNextIsPreview(true), fSessionId(-1) 635 AutoScheduler(ostream &out=cout) : T(out, "SCHEDULER"), fNextIsPreview(true), fSessionId(-1), fDBName("") 636 636 { 637 637 AddStateName(kSM_Scheduling, "Scheduling"); … … 662 662 { 663 663 case kSM_Scheduling: 664 if (evt.GetSize()>0) 665 fDBName = evt.GetString(); 664 666 //case kSM_Comitting: 665 667 //fSessionId = evt.GetInt(); … … 674 676 } 675 677 }; 678 676 679 677 680 // ------------------------------------------------------------------------ … … 771 774 } 772 775 773 //if (conf.Has("mintime"))774 // cout << "has mintime --------------------+" << conf.Get<int>("mintime")<< "+------------" << endl;775 776 776 if (conf.Has("database")) 777 { 777 778 database = conf.Get<string>("database").c_str(); 779 } 778 780 else 779 781 { … … 781 783 return -1; 782 784 } 783 784 785 785 786 if (conf.HasHelp() || conf.HasPrint()) -
trunk/FACT++/src/sendcommand.cc
r10589 r10624 2 2 #include <dic.hxx> 3 3 4 #include "Configuration.h" 5 4 6 using namespace std; 5 7 6 int main () {7 8 8 int value;9 9 10 value = DimClient::sendCommand("SCHEDULER/SCHEDULE", NULL, 0); 10 void SetupConfiguration(Configuration &conf) 11 { 12 const string n = conf.GetName()+".log"; 11 13 12 cout << "\n"; 13 cout << " The method sendCommand(...) will wait for the command to be actualy sent to the Server and return a completion code of : " << endl; 14 cout << " 1 - if it was successfully sent " << endl; 15 cout << " 0 - if it couldn't be delivered. " << endl; 14 //po::options_description config("Program options"); 15 po::options_description config("Configuration"); 16 config.add_options() 17 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 18 ("log,l", var<string>(n), "Write log-file") 19 //("no-dim,d", po_switch(), "Disable dim services") 20 //("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)") 21 ("dbname", var<string>(), "database name for scheduling preview") 22 ; 16 23 17 cout << "\n"; 18 cout << " The completion code is now: " << value << endl; 24 conf.AddEnv("dns", "DIM_DNS_NODE"); 19 25 20 return 0; 26 conf.AddOptions(config); 27 } 28 29 30 31 int main(int argc, const char* argv[]) 32 { 33 Configuration conf(argv[0]); 34 SetupConfiguration(conf); 35 36 po::variables_map vm; 37 try 38 { 39 vm = conf.Parse(argc, argv); 40 } 41 catch (std::exception &e) 42 { 43 #if BOOST_VERSION > 104000 44 po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e); 45 if (MO) 46 cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl; 47 else 48 #endif 49 cout << "Error: " << e.what() << endl; 50 cout << endl; 51 52 return -1; 53 } 54 55 const char* dbname; 56 if (conf.Has("dbname")) 57 dbname = conf.Get<string>("dbname").c_str(); 58 else 59 { 60 cout << "Please provide which database you want to use for scheduling using --dbname=<dbname>." << endl; 61 return -1; 62 } 63 64 65 if (conf.HasHelp() || conf.HasPrint()) 66 return -1; 67 68 // To allow overwriting of DIM_DNS_NODE set 0 to 1 69 setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1); 70 71 //int main () 72 //{ 73 74 int value; 75 76 value = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname); 77 //value = DimClient::sendCommand("SCHEDULER/SCHEDULE", NULL, 0); 78 79 cout << "\n"; 80 cout << " The method sendCommand(...) will wait for the command to be actualy sent to the Server and return a completion code of : " << endl; 81 cout << " 1 - if it was successfully sent " << endl; 82 cout << " 0 - if it couldn't be delivered. " << endl; 83 84 cout << "\n"; 85 cout << " The completion code is now: " << value << endl; 86 87 return 0; 21 88 22 89 }
Note:
See TracChangeset
for help on using the changeset viewer.