Changeset 10895 for trunk/FACT++/src


Ignore:
Timestamp:
06/01/11 10:05:49 (13 years ago)
Author:
tbretz
Message:
Removed the obsolete gHasWhiteList/fHasBlackList; removed the obsolete debugging of the configuration (debug options for the configuration options already exist in the Configuration class); replaces sprintf by strcpy; removes explicit check from SERVICE_LIST ShouldSubscribe; always print informations about the lists in PRINT even if they are empty
File:
1 edited

Legend:

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

    r10887 r10895  
    440440    set<string> fGrouping;
    441441    ///configuration flags
    442     bool fHasBlackList;
    443     bool fHasWhiteList;
    444442    bool fDebugIsOn;
    445443    float fStatsPeriodDuration;
     
    602600bool DataLogger::ShouldSubscribe(const string& server, const string& service)
    603601{
    604     if (service == "SERVICE_LIST")
     602    if (fWhiteList.size()>0 &&
     603        (fWhiteList.find(server + "/") == fWhiteList.end()) &&
     604        (fWhiteList.find(server + "/" + service) == fWhiteList.end()) &&
     605        (fWhiteList.find("/" + service) == fWhiteList.end()))
    605606        return false;
    606     if (fHasWhiteList && (fWhiteList.find(server + "/") == fWhiteList.end()) &&
    607                          (fWhiteList.find(server + "/" + service) == fWhiteList.end()) &&
    608                          (fWhiteList.find("/" + service) == fWhiteList.end()))
    609         return false;
    610     if (fHasBlackList && ((fBlackList.find(server + "/") != fBlackList.end()) ||
    611                           (fBlackList.find(server + "/" + service) != fBlackList.end()) ||
    612                           (fBlackList.find("/" + service) != fBlackList.end())))
     607
     608    if (((fBlackList.find(server + "/") != fBlackList.end()) ||
     609         (fBlackList.find(server + "/" + service) != fBlackList.end()) ||
     610         (fBlackList.find("/" + service) != fBlackList.end())))
    613611        return false;
    614612
     
    10061004    AddEvent(fConfigRunNumber, "I", kSM_Ready, kSM_NightlyOpen, kSM_WaitingRun, kSM_BadRunConfig, kSM_Logging)
    10071005            (boost::bind(&DataLogger::ConfigureRunNumber, this, _1))
    1008             ("configure the run number. cannot be done in logging state");
     1006            ("Configure the run number. Cannot be done in logging state");
    10091007
    10101008     //Provide a logging command
     
    10561054
    10571055     //black/white list
    1058      fHasBlackList = false;
    1059      fHasWhiteList = false;
    10601056     fBlackList.clear();
    10611057     fWhiteList.clear();
     
    10791075     AddEvent(fStartStopOpenedFiles, "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    10801076              (boost::bind(&DataLogger::SetOpenedFilesOnOff ,this, _1))
    1081               ("Can be used to switch the service off which distributes information about the open files.");
     1077              ("Switch off the service which distributes information about the open files.");
    10821078
    10831079     AddEvent(fStartStopNumSubsAndFits, "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    10841080             (boost::bind(&DataLogger::SetNumSubsAndFitsOnOff, this, _1))
    1085              ("Can be used to switch the service off which distributes information about the number of subscriptions and open files.");
     1081             ("Switch off the service which distributes information about the number of subscriptions and open files.");
    10861082
    10871083     fDestructing = false;
     
    16971693            Message(" -> "+it2->first);
    16981694    }
    1699     if (fHasBlackList)
    1700     {
    1701         Message("------------- BLOCK LIST ----------------");
    1702         for (set<string>::iterator it=fBlackList.begin(); it != fBlackList.end(); it++)
    1703             Message(*it);
    1704     }
    1705     if (fHasWhiteList)
    1706     {
    1707             Message("----------- ALLOW LIST ------------------");
    1708             for (set<string>::iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++)
    1709                 Message(*it);
    1710     }
    1711     if (fGrouping.size() != 0)
    1712     {
    1713             Message("--------- GROUPING LIST -----------------");
    1714             Message("The following servers and/or services will be grouping under a single run fits file:");
    1715             for (set<string>::iterator it=fGrouping.begin(); it != fGrouping.end(); it++)
    1716                 Message(*it);
    1717     }
     1695
     1696    Message("------------- BLOCK LIST ----------------");
     1697    for (set<string>::iterator it=fBlackList.begin(); it != fBlackList.end(); it++)
     1698        Message(*it);
     1699    if (fBlackList.size()==0)
     1700        Message(" <empty>");
     1701
     1702    Message("----------- ALLOW LIST ------------------");
     1703    for (set<string>::iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++)
     1704        Message(*it);
     1705    if (fWhiteList.size()==0)
     1706        Message(" <empty>");
     1707
     1708    Message("--------- GROUPING LIST -----------------");
     1709    Message("The following servers and/or services will be grouping under a single run fits file:");
     1710    for (set<string>::iterator it=fGrouping.begin(); it != fGrouping.end(); it++)
     1711        Message(*it);
     1712    if (fGrouping.size()==0)
     1713        Message(" <no grouping>");
     1714
    17181715    Message("-----------------------------------------");
    17191716    Message("------ END OF DATA LOGGER STATE ---------");
     
    22772274    groupTable->makeThisCurrent();
    22782275    //create appropriate buffer.
    2279     unsigned char* fitsBuffer = new unsigned char[8 + 3 + 2*maxCharLength + 1]; //+1 for trailling character
    2280     memset(fitsBuffer, 0, 8 + 3 + 2*maxCharLength + 1);
     2276    const unsigned int n = 8 + 3 + 2*maxCharLength + 1; //+1 for trailling character
     2277
     2278    unsigned char* fitsBuffer = new unsigned char[n];
     2279    memset(fitsBuffer, 0, n);
     2280
    22812281    char* startOfExtension = reinterpret_cast<char*>(fitsBuffer);
    2282     char* startOfURI = reinterpret_cast<char*>(&fitsBuffer[8]);
    2283     char* startOfLocation = reinterpret_cast<char*>(&fitsBuffer[8 + 3]);
    2284     char* startOfName = reinterpret_cast<char*>(&fitsBuffer[8+3+maxCharLength]);
    2285 
    2286     sprintf(startOfExtension, "%s", "BINTABLE");
    2287     sprintf(startOfURI, "%s", "URL");
     2282    char* startOfURI       = reinterpret_cast<char*>(&fitsBuffer[8]);
     2283    char* startOfLocation  = reinterpret_cast<char*>(&fitsBuffer[8 + 3]);
     2284    char* startOfName      = reinterpret_cast<char*>(&fitsBuffer[8+3+maxCharLength]);
     2285
     2286    strcpy(startOfExtension, "BINTABLE");
     2287    strcpy(startOfURI,       "URL");
     2288
    22882289    int i=1;
    22892290    for (map<string, vector<string> >::iterator it=filesToGroup.begin(); it!=filesToGroup.end(); it++)
     
    22922293            strcpy(startOfLocation, it->first.c_str());
    22932294            strcpy(startOfName, jt->c_str());
     2295
    22942296            if (fDebugIsOn)
    22952297            {
     
    22982300                Debug(str);
    22992301            }
     2302
    23002303            int status = 0;
    23012304            fits_write_tblbytes(groupFile->fitsPointer(), i, 1, 8+3+2*maxCharLength, fitsBuffer, &status);
     
    24202423    fBlackList.clear();
    24212424    fWhiteList.clear();
     2425
    24222426    if (conf.Has("block"))
    24232427    {
    2424         vector<string> vec = conf.Get<vector<string>>("block");
    2425         if (vec.size() != 0)
    2426         {
    2427             fHasBlackList = true;
    2428             if (fDebugIsOn)
    2429                 Debug("Setting BLOCK list:");
    2430         }
    2431         for (vector<string>::iterator it = vec.begin(); it != vec.end(); it++)
    2432         {
    2433             fBlackList.insert(*it);
    2434             if (fDebugIsOn)
    2435                 Debug("                   " + *it);
    2436         }
    2437 //Adding entries that should ALWAYS be ignored, because of Dim: otherwise the DataLogger would crash
     2428        const vector<string> vec = conf.Get<vector<string>>("block");
     2429
     2430        fBlackList.insert(vec.begin(), vec.end());
     2431
     2432        //Adding entries that should ALWAYS be ignored
    24382433        fBlackList.insert("DATA_LOGGER/");
    24392434        fBlackList.insert("/SERVICE_LIST");
    24402435        fBlackList.insert("DIS_DNS/");
    24412436    }
     2437
    24422438    if (conf.Has("allow"))
    24432439    {
    2444         vector<string> vec = conf.Get<vector<string>>("allow");
    2445         if (vec.size() != 0)
    2446         {
    2447             fHasWhiteList = true;
    2448             if (fDebugIsOn)
    2449                 Debug("Setting ALLOW list:");
    2450         }
    2451         for (vector<string>::iterator it=vec.begin(); it != vec.end(); it++)
    2452         {
    2453             fWhiteList.insert(*it);
    2454             if (fDebugIsOn)
    2455                 Debug("                   " + *it);
    2456         }
    2457     }
     2440        const vector<string> vec = conf.Get<vector<string>>("allow");
     2441        fWhiteList.insert(vec.begin(), vec.end());
     2442    }
     2443
    24582444    //Set the grouping
    24592445    if (conf.Has("group"))
    24602446    {
    2461         vector<string> vec = conf.Get<vector<string>>("group");
    2462         if (vec.size() != 0)
    2463             if (fDebugIsOn)
    2464                 Debug("Setting GROUPING list:");
    2465         for (vector<string>::iterator it=vec.begin(); it != vec.end(); it++)
    2466         {
    2467             fGrouping.insert(*it);
    2468             if (fDebugIsOn)
    2469                 Debug("                   " + *it);
    2470         }
     2447        const vector<string> vec = conf.Get<vector<string>>("group");
     2448        fGrouping.insert(vec.begin(), vec.end());
    24712449    }
    24722450    return true;
Note: See TracChangeset for help on using the changeset viewer.