Ignore:
Timestamp:
May 8, 2011, 9:48:24 PM (9 years ago)
Author:
dorner
Message:
implemented --dbname and its evaluation for the scheduler
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/sendcommand.cc

    r10589 r10624  
    22#include <dic.hxx>
    33
     4#include "Configuration.h"
     5
    46using namespace std;
    57
    6 int main () {
    78
    8 int value;
    99
    10 value = DimClient::sendCommand("SCHEDULER/SCHEDULE", NULL, 0);
     10void SetupConfiguration(Configuration &conf)
     11{
     12    const string n = conf.GetName()+".log";
    1113
    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        ;
    1623
    17 cout << "\n";
    18 cout << " The completion code is now:       " << value << endl;
     24    conf.AddEnv("dns", "DIM_DNS_NODE");
    1925
    20 return 0;
     26    conf.AddOptions(config);
     27}
     28
     29
     30
     31int 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;
    2188
    2289}
Note: See TracChangeset for help on using the changeset viewer.