ARC SDK
Basic Job Submission

C++

#include <arc/Logger.h>
#include <arc/UserConfig.h>
#include <arc/compute/Endpoint.h>
#include <arc/compute/Job.h>
#include <arc/compute/JobDescription.h>
#include <arc/compute/Submitter.h>
#include <arc/compute/JobInformationStorageXML.h>
int main() {
// Set up logging to stderr with level VERBOSE (a lot of output will be shown)
Arc::LogStream logcerr(std::cerr);
logcerr.setFormat(Arc::ShortFormat);
Arc::Logger logger(Arc::Logger::getRootLogger(), "jobsubmit");
// UserConfig contains information on credentials and default services to use.
// This form of the constructor is necessary to initialise the local job list.
Arc::UserConfig usercfg("", "");
// Simple job description which outputs hostname to stdout
std::string jobdesc("&(executable=/bin/hostname)(stdout=stdout)");
// Parse job description
std::list<Arc::JobDescription> jobdescs;
if (!Arc::JobDescription::Parse(jobdesc, jobdescs)) {
logger.msg(Arc::ERROR, "Invalid job description");
return 1;
}
/*
* Use 'Arc::JobDescription::ParseFromFile("helloworld.xrsl", jobdescs)'
* to parse job description from file.
*/
// Use top-level NorduGrid information index to find resources
Arc::Endpoint index("ldap://index1.nordugrid.org:2135/Mds-Vo-name=NorduGrid,o=grid",
"org.nordugrid.ldapegiis");
std::list<Arc::Endpoint> services(1, index);
// Do the submission
std::list<Arc::Job> jobs;
Arc::Submitter submitter(usercfg);
if (submitter.BrokeredSubmit(services, jobdescs, jobs) != Arc::SubmissionStatus::NONE) {
logger.msg(Arc::ERROR, "Failed to submit job");
return 1;
}
// Write information on submitted job to local job list (~/.arc/jobs.xml)
Arc::JobInformationStorageXML jobList(usercfg.JobListFile());
if (!jobList.Write(jobs)) {
logger.msg(Arc::WARNING, "Failed to write to local job list %s", usercfg.JobListFile());
}
// Job submitted ok
std::cout << "Job submitted with job id " << jobs.front().JobID << std::endl;
return 0;
}

Python

import arc
import sys
# Set up logging to stderr with level VERBOSE (a lot of output will be shown)
logstdout = arc.LogStream(sys.stdout)
logstdout.setFormat(arc.ShortFormat)
arc.Logger_getRootLogger().addDestination(logstdout)
arc.Logger_getRootLogger().setThreshold(arc.VERBOSE)
logger = arc.Logger(arc.Logger_getRootLogger(), "jobsubmit")
# UserConfig contains information on credentials and default services to use.
# This form of the constructor is necessary to initialise the local job list.
usercfg = arc.UserConfig("", "")
# Two simple job descriptions which output hostname to stdout
jobdescstring = "+(&(executable=/bin/hostname)(stdout=stdout))(&(executable=/bin/hostname)(stdout=stdout))"
# Parse job description
jobdescs = arc.JobDescriptionList()
if not arc.JobDescription_Parse(jobdescstring, jobdescs):
logger.msg(arc.ERROR, "Invalid job description")
sys.exit(1)
# Use 'arc.JobDescription_ParseFromFile("helloworld.xrsl", jobdescs)'
# to parse job description from file.
# Use top-level NorduGrid information index to find resources
index = arc.Endpoint("nordugrid.org", arc.Endpoint.REGISTRY, "org.nordugrid.archery")
services = arc.EndpointList(1, index)
# Do the submission
jobs = arc.JobList()
submitter = arc.Submitter(usercfg)
if submitter.BrokeredSubmit(services, jobdescs, jobs) != arc.SubmissionStatus.NONE:
logger.msg(arc.ERROR, "Failed to submit job")
sys.exit(1)
# Write information on submitted job to local job list (~/.arc/jobs.xml)
jobList = arc.JobInformationStorageSQLite(usercfg.JobListFile())
if not jobList.Write(jobs):
logger.msg(arc.WARNING, "Failed to write to local job list %s" % usercfg.JobListFile())
# Job submitted ok
sys.stdout.write("Job(s) submitted with job id(s):\n\t%s\n" % '\n\t'.join([str(j.JobID) for j in jobs]))

xRSL job description

&
(executable = "/bin/echo")
(arguments = "Hello World")
(stdout = "std.out")
(join = "yes")(* Join stdout and stderr into stdout*)
(cputime = 1)
(jobname = "Hello World")
(gmlog = "joblog")(* Grid manager log files should be included when retrieving job results (arcget) *)