Changeset 11254


Ignore:
Timestamp:
07/05/11 10:25:26 (13 years ago)
Author:
tbretz
Message:
Changed SetConfiguration to EvalConfiguration; changed positional argument from schedule-database to new schedule; added --schedule to be able to just schedule something.
File:
1 edited

Legend:

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

    r11251 r11254  
    154154    };
    155155
    156     int fSessionId;
    157156    string fDatabase;
    158157    string fDBName;
     
    632631        T::Message("Scheduling done.");
    633632
    634         fSessionId = -1;
    635 
    636         return error ? T::kSM_Error : T::kSM_Ready;
     633        return error;
    637634    }
    638635
     
    655652    */
    656653
    657     AutoScheduler(ostream &out=cout) : T(out, "SCHEDULER"), fNextIsPreview(true), fSessionId(-1), fDBName("")
     654    AutoScheduler(ostream &out=cout) : T(out, "SCHEDULER"), fNextIsPreview(true), fDBName("")
    658655    {
    659656        AddStateName(kSM_Scheduling, "Scheduling", "Scheduling in progress.");
     
    678675            try
    679676            {
    680                 return Schedule();
     677                return Schedule() ? T::kSM_Error : T::kSM_Ready;
    681678            }
    682679            catch (const mysqlpp::Exception &e)
     
    689686        case T::kSM_Error:
    690687            return T::kSM_Ready;
    691 
    692         //case kSM_Comitting:
    693         //    return Commit();
    694688        }
    695689        return T::GetCurrentState();
     
    703697            if (evt.GetSize()>0)
    704698                fDBName = evt.GetText();
    705         //case kSM_Comitting:
    706             //fSessionId = evt.GetInt();
    707699            break;
    708700        }
     
    710702        return evt.GetTargetState();
    711703    }
    712     int Configure(const Event &)
    713     {
    714         return T::GetCurrentState();
    715     }
    716 
    717     bool SetConfiguration(const Configuration &conf)
    718     {
    719         fDatabase = conf.Get<string>("schedule-database");
     704
     705    int EvalConfiguration(const Configuration &conf)
     706    {
     707        fDatabase       = conf.Get<string>("schedule-database");
    720708        fDurationCalRun = conf.Get<int>("duration-cal-run");
    721709        fDurationPedRun = conf.Get<int>("duration-ped-run");
    722710        fDurationRepos  = conf.Get<int>("duration-repos");
    723711
    724         return true;
     712        if (!conf.Has("schedule"))
     713            return -1;
     714
     715        fDBName = conf.Get<string>("schedule");
     716        return Schedule();
    725717    }
    726718
     
    755747    // Start io_service.run to only use the commandHandler command detaching
    756748    AutoScheduler<S> io_service(wout);
    757     if (!io_service.SetConfiguration(conf))
     749    if (!io_service.EvalConfiguration(conf))
    758750        return -1;
    759751
     
    779771
    780772    AutoScheduler<S> io_service(wout);
    781     if (!io_service.SetConfiguration(conf))
     773    if (!io_service.EvalConfiguration(conf))
    782774        return -1;
    783775
     
    840832#endif
    841833                                           ,  "Database link as in\n\t[user:[password]@][server][:port][/database]\nOverwrites options from the default configuration file.")
     834        ("schedule",          var<string>(),  "")
    842835        ("mintime",           var<int>(),     "minimum observation time")
    843836        ("duration-cal-run",  var<int>()
     
    859852
    860853    po::positional_options_description p;
    861     p.add("schedule-database", 1); // The first positional options
     854    p.add("schedule", 1); // The first positional options
    862855
    863856    conf.AddEnv("dns", "DIM_DNS_NODE");
Note: See TracChangeset for help on using the changeset viewer.