22
/// \mapname xRSL xRSL (nordugrid:xrsl)
23
/// The libarccompute library has full support for xRSL. The
24
/// reference manual is located <a href="http://www.nordugrid.org/documents/xrsl.pdf">here</a>.
25
/// By default the xRSL parser expects and produces user-side RSL (see
26
/// reference manual), however if GM-side RSL is passed as input or wanted as
27
/// output, then the "GRIDMANAGER" dialect should be used.
22
28
XRSLParser::XRSLParser(PluginArgument* parg)
23
29
: JobDescriptionParserPlugin(parg) {
24
30
supportedLanguages.push_back("nordugrid:xrsl");
625
/// TODO \mapattr inputfiles -> DataStagingType::InputFiles
608
626
if (c->Attr() == "inputfiles") {
609
627
std::list<std::list<std::string> > ll;
610
628
if (!SeqListValue(c, ll))
612
630
for (std::list<std::list<std::string> >::iterator it = ll.begin();
613
it != ll.end(); it++) {
614
std::list<std::string>::iterator it2 = it->begin();
616
// Check whether the first string exists in the list
617
if (it2 == it->end()) {
631
it != ll.end(); ++it) {
632
/* Each of the elements of the inputfiles attribute should have at
635
if (it->size() < 2) {
636
logger.msg(VERBOSE, "At least two values are needed for the 'inputfiles' attribute.");
640
if (it->front().empty()) {
641
logger.msg(VERBOSE, "filename cannot be empty.");
621
645
InputFileType file;
624
// Check whether the second string exists in the list
625
if (it2 == it->end()) {
631
std::string fileChecksum;
632
// The second string in the list (it2) might either be a URL or filesize.checksum.
634
std::string::size_type sep = it2->find('.');
635
if(sep == std::string::npos) {
636
if(!stringto(*it2, fileSize)) is_file = false;
638
fileChecksum = it2->substr(sep+1);
639
if(!stringto(it2->substr(0,sep), fileSize)) is_file = false;
646
file.Name = it->front();
648
// For USER dialect (default) the second string must be empty, a path to a file or an URL.
649
// For GRIDMANAGER dialect the second string in the list might either be a URL or filesize.checksum.
650
std::list<std::string>::iterator itValues = ++(it->begin());
651
bool is_size_and_checksum = false;
652
if (dialect == "GRIDMANAGER") {
654
std::string::size_type sep = itValues->find('.');
655
if(stringto(itValues->substr(0,sep), fileSize)) {
656
is_size_and_checksum = true;
657
file.FileSize = fileSize;
658
if(sep != std::string::npos) {
659
file.Checksum = itValues->substr(sep+1);
641
if(fileSize < 0) is_file = false;
663
if (!itValues->empty() && !is_size_and_checksum) {
648
668
URLLocation location;
649
for (it2++; it2 != it->end(); ++it2) {
669
for (++itValues; itValues != it->end(); ++itValues) {
650
670
// add any options and locations
651
671
// an option applies to the URL preceding it (main or location)
652
std::string::size_type pos = it2->find('=');
672
std::string::size_type pos = itValues->find('=');
653
673
if (pos == std::string::npos) {
654
logger.msg(ERROR, "Invalid URL option syntax in option %s for input file %s", *it2, file.Name);
674
logger.msg(ERROR, "Invalid URL option syntax in option %s for input file %s", *itValues, file.Name);
657
std::string attr_name(it2->substr(0, pos));
658
std::string attr_value(it2->substr(pos+1));
677
std::string attr_name(itValues->substr(0, pos));
678
std::string attr_value(itValues->substr(pos+1));
659
679
if (attr_name == "location") {
661
681
turl.AddLocation(location);
674
694
turl.AddLocation(location);
675
695
file.Sources.push_back(turl);
678
file.FileSize = fileSize;
679
file.Checksum = fileChecksum;
680
if(dialect != "GRIDMANAGER") file.Sources.push_back(URL(file.Name));
697
else if (itValues->empty()) {
698
file.Sources.push_back(URL(file.Name));
682
700
file.IsExecutable = false;
684
702
j.DataStaging.InputFiles.push_back(file);
685
for (std::list<JobDescription>::iterator it = j.GetAlternatives().begin();
686
it != j.GetAlternatives().end(); it++) {
687
it->DataStaging.InputFiles.push_back(file);
703
for (std::list<JobDescription>::iterator itAlt = j.GetAlternatives().begin();
704
itAlt != j.GetAlternatives().end(); ++itAlt) {
705
itAlt->DataStaging.InputFiles.push_back(file);
711
// Mapping documented above
693
712
if (c->Attr() == "executables") {
694
713
std::list<std::string> execs;
695
714
if (!ListValue(c, execs))
1412
1469
RSLBoolean r(RSLAnd);
1471
/// \mapattr executable <- ExecutableType::Path
1414
1472
if (!j.Application.Executable.Path.empty()) {
1415
1473
RSLList *l = new RSLList;
1416
1474
l->Add(new RSLLiteral(j.Application.Executable.Path));
1417
1475
r.Add(new RSLCondition("executable", RSLEqual, l));
1478
/// \mapattr arguments <- ExecutableType::Argument
1420
1479
if (!j.Application.Executable.Argument.empty()) {
1421
1480
RSLList *l = new RSLList;
1422
1481
for (std::list<std::string>::const_iterator it = j.Application.Executable.Argument.begin();
1425
1484
r.Add(new RSLCondition("arguments", RSLEqual, l));
1487
/// \mapattr stdin <- Input
1428
1488
if (!j.Application.Input.empty()) {
1429
1489
RSLList *l = new RSLList;
1430
1490
l->Add(new RSLLiteral(j.Application.Input));
1431
1491
r.Add(new RSLCondition("stdin", RSLEqual, l));
1494
/// \mapattr stdout <- Output
1434
1495
if (!j.Application.Output.empty()) {
1435
1496
RSLList *l = new RSLList;
1436
1497
l->Add(new RSLLiteral(j.Application.Output));
1437
1498
r.Add(new RSLCondition("stdout", RSLEqual, l));
1501
/// \mapattr stderr <- Error
1440
1502
if (!j.Application.Error.empty()) {
1441
1503
RSLList *l = new RSLList;
1442
1504
l->Add(new RSLLiteral(j.Application.Error));
1443
1505
r.Add(new RSLCondition("stderr", RSLEqual, l));
1508
/// \mapattr cputime <- TotalCPUTime
1446
1509
if (j.Resources.TotalCPUTime.range > -1) {
1447
1510
RSLList *l = new RSLList;
1448
1511
if(dialect == "GRIDMANAGER") {
1467
1531
r.Add(new RSLCondition("walltime", RSLEqual, l));
1534
/// \mapattr memory <- IndividualPhysicalMemory
1470
1535
if (j.Resources.IndividualPhysicalMemory > -1) {
1471
1536
RSLList *l = new RSLList;
1472
1537
l->Add(new RSLLiteral(tostring(j.Resources.IndividualPhysicalMemory)));
1473
1538
r.Add(new RSLCondition("memory", RSLEqual, l));
1541
/// \mapattr environment <- Environment
1476
1542
if (!j.Application.Environment.empty()) {
1477
1543
RSLList *l = new RSLList;
1478
1544
for (std::list< std::pair<std::string, std::string> >::const_iterator it = j.Application.Environment.begin();
1496
1563
RSLList *s = new RSLList;
1497
1564
s->Add(new RSLLiteral(it->Name));
1498
1565
if (it->Sources.empty() || (it->Sources.front().Protocol() == "file")) { // Local file
1499
std::string fsizechecksum = ".";
1500
if(it->FileSize != -1) fsizechecksum = tostring(it->FileSize)+fsizechecksum;
1501
if (!it->Checksum.empty()) fsizechecksum = fsizechecksum+it->Checksum;
1502
if(fsizechecksum == ".") fsizechecksum = "";
1566
std::string fsizechecksum;
1567
if(it->FileSize != -1) fsizechecksum = tostring(it->FileSize);
1568
if (!it->Checksum.empty()) fsizechecksum = "." + fsizechecksum+it->Checksum;
1503
1569
s->Add(new RSLLiteral(fsizechecksum));
1505
1571
s->Add(new RSLLiteral(it->Sources.front().fullstr()));
1557
1624
if (it->Sources.empty()) {
1558
1625
s->Add(new RSLLiteral(""));
1559
1626
} else if (it->Sources.front().Protocol() == "file" && it->FileSize != -1) {
1560
// This hides possibly unequal name and path of local file.
1561
// TODO: rethink, maybe it is better to loose FileSize instead of original path
1562
std::string fsizechecksum = tostring(it->FileSize);
1563
if (!it->Checksum.empty()) {
1564
fsizechecksum += "."+it->Checksum;
1566
s->Add(new RSLLiteral(fsizechecksum));
1627
s->Add(new RSLLiteral(it->Sources.front().Path()));
1569
1630
s->Add(new RSLLiteral(it->Sources.front().fullstr()));
1628
1689
} // (dialect == "GRIDMANAGER")
1691
/// \mapattr queue <- QueueName
1630
1692
if (!j.Resources.QueueName.empty()) {
1631
1693
RSLList *l = new RSLList;
1632
1694
l->Add(new RSLLiteral(j.Resources.QueueName));
1633
1695
r.Add(new RSLCondition("queue", RSLEqual, l));
1698
/// \mapattr rerun <- Rerun
1636
1699
if (j.Application.Rerun != -1) {
1637
1700
RSLList *l = new RSLList;
1638
1701
l->Add(new RSLLiteral(tostring(j.Application.Rerun)));
1639
1702
r.Add(new RSLCondition("rerun", RSLEqual, l));
1705
/// \mapattr priority <- Priority
1642
1706
if (j.Application.Priority != -1) {
1643
1707
RSLList *l = new RSLList;
1644
1708
l->Add(new RSLLiteral(tostring(j.Application.Priority)));
1645
1709
r.Add(new RSLCondition("priority", RSLEqual, l));
1712
/// TODO: dialect/units
1713
/// \mapattr lifetime <- SessionLifeTime
1648
1714
if (j.Resources.SessionLifeTime != -1) {
1649
1715
RSLList *l = new RSLList;
1650
1716
if(dialect == "GRIDMANAGER") {
1657
1723
r.Add(new RSLCondition("lifetime", RSLEqual, l));
1726
/// \mapattr disk <- DiskSpace
1660
1727
if (j.Resources.DiskSpaceRequirement.DiskSpace > -1) {
1661
1728
RSLList *l = new RSLList;
1662
1729
l->Add(new RSLLiteral(tostring(j.Resources.DiskSpaceRequirement.DiskSpace)));
1663
1730
r.Add(new RSLCondition("disk", RSLEqual, l));
1733
/// \mapattr runtimeenvironment <- RunTimeEnvironment
1666
1734
if (!j.Resources.RunTimeEnvironment.empty()) {
1667
1735
std::list<Software>::const_iterator itSW = j.Resources.RunTimeEnvironment.getSoftwareList().begin();
1668
1736
std::list<Software::ComparisonOperator>::const_iterator itCO = j.Resources.RunTimeEnvironment.getComparisonOperatorList().begin();
1766
/// \mapattr architecture <- Platform
1696
1767
if (!j.Resources.Platform.empty()) {
1697
1768
RSLList *l = new RSLList;
1698
1769
l->Add(new RSLLiteral(j.Resources.Platform));
1699
1770
r.Add(new RSLCondition("architecture", RSLEqual, l));
1773
/// \mapattr count <- NumberOfSlots
1702
1774
if (j.Resources.SlotRequirement.NumberOfSlots > -1) {
1703
1775
RSLList *l = new RSLList;
1704
1776
l->Add(new RSLLiteral(tostring(j.Resources.SlotRequirement.NumberOfSlots)));
1705
1777
r.Add(new RSLCondition("count", RSLEqual, l));
1780
/// \mapattr countpernode <- SlotsPerHost
1709
1781
if (j.Resources.SlotRequirement.SlotsPerHost > -1) {
1710
1782
if (j.Resources.SlotRequirement.NumberOfSlots <= -1) {
1711
1783
logger.msg(ERROR, "Cannot output XRSL representation: The Resources.SlotRequirement.NumberOfSlots attribute must be specified when the Resources.SlotRequirement.SlotsPerHost attribute is specified.");
1716
1788
r.Add(new RSLCondition("countpernode", RSLEqual, l));
1791
/// \mapattr exclusiveexecution <- ExclusiveExecution
1720
1792
if (j.Resources.SlotRequirement.ExclusiveExecution != SlotRequirementType::EE_DEFAULT) {
1721
1793
RSLList *l = new RSLList;
1722
1794
l->Add(new RSLLiteral(j.Resources.SlotRequirement.ExclusiveExecution == SlotRequirementType::EE_TRUE ? "yes" : "no"));
1723
1795
r.Add(new RSLCondition("exclusiveexecution", RSLEqual, l));
1798
/// \mapattr starttime <- ProcessingStartTime
1728
1799
if (j.Application.ProcessingStartTime != -1) {
1729
1800
RSLList *l = new RSLList;
1730
1801
l->Add(new RSLLiteral(j.Application.ProcessingStartTime.str(MDSTime)));
1731
1802
r.Add(new RSLCondition("starttime", RSLEqual, l));
1805
/// \mapattr gmlog <- LogDir
1734
1806
if (!j.Application.LogDir.empty()) {
1735
1807
RSLList *l = new RSLList;
1736
1808
l->Add(new RSLLiteral(j.Application.LogDir));
1737
1809
r.Add(new RSLCondition("gmlog", RSLEqual, l));
1812
/// \mapattr jobname <- JobName
1740
1813
if (!j.Identification.JobName.empty()) {
1741
1814
RSLList *l = new RSLList;
1742
1815
l->Add(new RSLLiteral(j.Identification.JobName));
1743
1816
r.Add(new RSLCondition("jobname", RSLEqual, l));
1819
/// \mapattr acl <- AccessControl
1746
1820
if (j.Application.AccessControl) {
1747
1821
RSLList *l = new RSLList;
1748
1822
std::string acl;
1860
/// \mapattr credentialserver <- CredentialService
1784
1861
if (!j.Application.CredentialService.empty()) {
1785
1862
RSLList *l = new RSLList;
1786
1863
l->Add(new RSLLiteral(j.Application.CredentialService.front().fullstr()));
1787
1864
r.Add(new RSLCondition("credentialserver", RSLEqual, l));
1867
/// \mapattr dryrun <- DryRun
1790
1868
if (j.Application.DryRun) {
1791
1869
RSLList *l = new RSLList;
1792
1870
l->Add(new RSLLiteral("yes"));
1793
1871
r.Add(new RSLCondition("dryrun", RSLEqual, l));
1796
1875
for (std::map<std::string, std::string>::const_iterator it = j.OtherAttributes.begin();
1797
1876
it != j.OtherAttributes.end(); it++) {
1798
1877
std::list<std::string> keys;