~ubuntu-branches/debian/sid/nordugrid-arc/sid

« back to all changes in this revision

Viewing changes to src/hed/acc/JobDescriptionParser/XRSLParser.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121213164131-0fumka0jar8mxm07
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
    return true;
188
188
  }
189
189
 
 
190
  bool XRSLParser::ParseGridTimeAttribute(JobDescription& j) { // Must be called after the 'count' attribute has been parsed.
 
191
    std::map<std::string, std::string>::iterator itAtt;
 
192
    itAtt = j.OtherAttributes.find("nordugrid:xrsl;gridtime");
 
193
 
 
194
    if (itAtt == j.OtherAttributes.end()) {
 
195
      return true;
 
196
    }
 
197
 
 
198
    if (j.Resources.TotalCPUTime.range.max != -1) {
 
199
      logger.msg(ERROR, "The XRSL attributes gridtime and cputime cannot be specified together.");
 
200
      return false;
 
201
    }
 
202
    if (j.Resources.TotalWallTime.range.max != -1) {
 
203
      logger.msg(ERROR, "The XRSL attributes gridtime and walltime cannot be specified together.");
 
204
      return false;
 
205
    }
 
206
 
 
207
    j.Resources.TotalCPUTime.range = Period(itAtt->second, PeriodMinutes).GetPeriod();
 
208
    j.Resources.TotalCPUTime.benchmark = std::pair<std::string, double>("clock rate", 2800);
 
209
 
 
210
    int slots = (j.Resources.SlotRequirement.NumberOfSlots > 0 ? j.Resources.SlotRequirement.NumberOfSlots : 1);
 
211
    j.Resources.TotalWallTime.range = Period(itAtt->second, PeriodMinutes).GetPeriod()*slots;
 
212
    j.Resources.TotalWallTime.benchmark = std::pair<std::string, double>("clock rate", 2800);
 
213
 
 
214
    j.OtherAttributes.erase(itAtt);
 
215
    
 
216
    return true;
 
217
  }
 
218
 
190
219
  JobDescriptionParserResult XRSLParser::Parse(const std::string& source, std::list<JobDescription>& jobdescs, const std::string& language, const std::string& dialect) const {
191
220
    if (language != "" && !IsLanguageSupported(language)) {
192
221
      return false;
227
256
      if (dialect != "GRIDMANAGER" && !ParseJoinAttribute(jobdescs.back())) { // join is a client side attribute
228
257
        return false;
229
258
      }
 
259
      if (dialect != "GRIDMANAGER" && !ParseGridTimeAttribute(jobdescs.back())) { // gridtime is a client side attribute
 
260
        return false;
 
261
      }
230
262
      for (std::list<JobDescription>::iterator itJob = jobdescs.back().GetAlternatives().begin();
231
263
           itJob != jobdescs.back().GetAlternatives().end(); itJob++) {
232
264
        if (!ParseExecutablesAttribute(*itJob)) {
241
273
        if (dialect != "GRIDMANAGER" && !ParseJoinAttribute(*itJob)) { // join is a client side attribute
242
274
          return false;
243
275
        }
 
276
        if (dialect != "GRIDMANAGER" && !ParseGridTimeAttribute(*itJob)) { // gridtime is a client side attribute
 
277
          return false;
 
278
        }
244
279
      }
245
280
 
246
281
      std::stringstream ss;
247
282
      ss << **it;
248
283
      jobdescs.back().OtherAttributes["nordugrid:xrsl;clientxrsl"] = ss.str();
 
284
      SourceLanguage(jobdescs.back()) = (!language.empty() ? language : supportedLanguages.front());
 
285
      for (std::list<JobDescription>::iterator itAltJob = jobdescs.back().GetAlternatives().begin();
 
286
         itAltJob != jobdescs.back().GetAlternatives().end(); ++itAltJob) {
 
287
        itAltJob->OtherAttributes["nordugrid:xrsl;clientxrsl"] = ss.str();
 
288
        SourceLanguage(*itAltJob) = jobdescs.back().GetSourceLanguage();
 
289
      }
249
290
    }
250
291
 
251
292
    if(jobdescs.empty()) {
273
314
          return false;
274
315
        }
275
316
      }
276
 
 
277
 
      SourceLanguage(jobdescs.front()) = (!language.empty() ? language : supportedLanguages.front());
278
317
    }
279
318
    else {
280
319
      // action is not expected in client side job request
287
326
          jobdescs.clear();
288
327
          return false;
289
328
        }
290
 
        SourceLanguage(*it) = (!language.empty() ? language : supportedLanguages.front());
291
329
      }
292
330
    }
293
331
 
824
862
        std::string time;
825
863
        if (!SingleValue(c, time))
826
864
          return false;
827
 
        if(dialect == "GRIDMANAGER") {
828
 
          j.Resources.TotalCPUTime.range = Period(time, PeriodSeconds).GetPeriod();
829
 
        } else {
830
 
          j.Resources.TotalCPUTime.range = Period(time, PeriodMinutes).GetPeriod();
831
 
          for (std::list<JobDescription>::iterator it = j.GetAlternatives().begin();
832
 
               it != j.GetAlternatives().end(); it++) {
833
 
            it->Resources.TotalCPUTime.range = j.Resources.TotalCPUTime.range;
834
 
            it->Resources.TotalCPUTime.benchmark = std::pair<std::string, double>("clock rate", 2800);
835
 
          }
 
865
 
 
866
        /* Store value in the OtherAttributes member and set it later when all
 
867
         * the attributes it depends on has been parsed.
 
868
         */
 
869
        j.OtherAttributes["nordugrid:xrsl;gridtime"] = time;
 
870
        for (std::list<JobDescription>::iterator it = j.GetAlternatives().begin();
 
871
             it != j.GetAlternatives().end(); it++) {
 
872
          it->OtherAttributes["nordugrid:xrsl;gridtime"] = time;
836
873
        }
837
874
 
838
 
        j.Resources.TotalCPUTime.benchmark = std::pair<std::string, double>("clock rate", 2800);
839
875
        return true;
840
876
      }
841
877
 
991
1027
        std::string acl;
992
1028
        if (!SingleValue(c, acl))
993
1029
          return false;
 
1030
 
994
1031
        XMLNode node(acl);
995
 
 
 
1032
        if (!node) {
 
1033
          logger.msg(ERROR, "The value of the acl XRSL attribute isn't valid XML.");
 
1034
          return false;
 
1035
        }
 
1036
        
996
1037
        node.New(j.Application.AccessControl);
997
1038
        for (std::list<JobDescription>::iterator it = j.GetAlternatives().begin();
998
1039
             it != j.GetAlternatives().end(); it++) {
1150
1191
        std::string count;
1151
1192
        if (!SingleValue(c, count))
1152
1193
          return false;
1153
 
        j.Resources.SlotRequirement.SlotsPerHost = stringtoi(count);
 
1194
        j.Resources.SlotRequirement.NumberOfSlots = stringtoi(count);
1154
1195
        for (std::list<JobDescription>::iterator it = j.GetAlternatives().begin();
1155
 
             it != j.GetAlternatives().end(); it++) {
1156
 
          it->Resources.SlotRequirement.SlotsPerHost = j.Resources.SlotRequirement.SlotsPerHost;
 
1196
             it != j.GetAlternatives().end(); ++it) {
 
1197
          it->Resources.SlotRequirement.NumberOfSlots = j.Resources.SlotRequirement.NumberOfSlots;
1157
1198
        }
1158
1199
        return true;
1159
1200
      }
1607
1648
      r.Add(new RSLCondition("architecture", RSLEqual, l));
1608
1649
    }
1609
1650
 
1610
 
    if (j.Resources.SlotRequirement.SlotsPerHost > -1) {
 
1651
    if (j.Resources.SlotRequirement.NumberOfSlots > -1) {
1611
1652
      RSLList *l = new RSLList;
1612
 
      l->Add(new RSLLiteral(tostring(j.Resources.SlotRequirement.SlotsPerHost)));
 
1653
      l->Add(new RSLLiteral(tostring(j.Resources.SlotRequirement.NumberOfSlots)));
1613
1654
      r.Add(new RSLCondition("count", RSLEqual, l));
1614
1655
    }
1615
1656
 
1634
1675
    if (j.Application.AccessControl) {
1635
1676
      RSLList *l = new RSLList;
1636
1677
      std::string acl;
1637
 
      j.Application.AccessControl.GetXML(acl, true);
 
1678
      j.Application.AccessControl.GetXML(acl, false);
1638
1679
      l->Add(new RSLLiteral(acl));
1639
1680
      r.Add(new RSLCondition("acl", RSLEqual, l));
1640
1681
    }