use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TestLoadJobs method setUp.
@Before
public void setUp() throws Exception {
logger.setLevel(Level.INFO);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
List<JobInfo> jobs = scheduler.getJobs(0, 1000, criteria(true, true, true, true), SORT_BY_ID_ASC).getList();
for (JobInfo job : jobs) {
scheduler.removeJob(job.getJobId());
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TaskUsingCredentialsTest method jobs_using_third_party_credentials.
private void jobs_using_third_party_credentials() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
scheduler.putThirdPartyCredential("MY_APP_PASSWORD", "superpassword");
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
if (OperatingSystem.getOperatingSystem() == org.objectweb.proactive.utils.OperatingSystem.unix) {
NativeTask nativeTask = new NativeTask();
nativeTask.setCommandLine("echo", "$credentials_MY_APP_PASSWORD");
job.addTask(nativeTask);
}
JobId jobId = scheduler.submit(job);
schedulerHelper.waitForEventJobFinished(jobId);
JobResult jobResult = schedulerHelper.getJobResult(jobId);
for (TaskResult taskResult : jobResult.getAllResults().values()) {
assertTrue("task " + taskResult.getTaskId().getReadableName() + " did not print the credential", taskResult.getOutput().getAllLogs(false).contains("superpassword"));
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class TestGlobalSpace method testGlobalSpace.
@Test
public void testGlobalSpace() throws Throwable {
File in = tmpFolder.newFolder("input_space");
String inPath = in.getAbsolutePath();
File out = tmpFolder.newFolder("output_space");
String outPath = out.getAbsolutePath();
writeFiles(inFiles, inPath);
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.setInputSpace(in.toURI().toURL().toString());
job.setOutputSpace(out.toURI().toURL().toString());
JavaTask A = new JavaTask();
A.setExecutableClassName("org.ow2.proactive.scheduler.examples.EmptyTask");
A.setName("A");
for (String[] file : inFiles) {
A.addInputFiles(file[0], InputAccessMode.TransferFromInputSpace);
A.addOutputFiles(file[0] + ".glob.A", OutputAccessMode.TransferToGlobalSpace);
}
A.setPreScript(new SimpleScript(scriptA, "groovy"));
A.setForkEnvironment(new ForkEnvironment());
job.addTask(A);
JavaTask B = new JavaTask();
B.setExecutableClassName("org.ow2.proactive.scheduler.examples.EmptyTask");
B.setName("B");
B.addDependence(A);
for (String[] file : inFiles) {
B.addInputFiles(file[0] + ".glob.A", InputAccessMode.TransferFromGlobalSpace);
B.addOutputFiles(file[0] + ".out", OutputAccessMode.TransferToOutputSpace);
}
B.setPreScript(new SimpleScript(scriptB, "groovy"));
B.setForkEnvironment(new ForkEnvironment());
job.addTask(B);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobId id = scheduler.submit(job);
schedulerHelper.waitForEventJobFinished(id);
assertFalse(schedulerHelper.getJobResult(id).hadException());
/**
* check: inFiles > IN > LOCAL A > GLOBAL > LOCAL B > OUT
*/
for (String[] inFile : inFiles) {
File f = new File(outPath + File.separator + inFile[0] + ".out");
assertTrue("File does not exist: " + f.getAbsolutePath(), f.exists());
Assert.assertEquals("Original and copied files differ", inFile[1], FileUtils.readFileToString(f));
f.delete();
File inf = new File(inPath + File.separator + inFile[0]);
inf.delete();
}
/**
* check that the file produced is accessible in the global user space via the scheduler API
*/
String globalURI = scheduler.getGlobalSpaceURIs().get(0);
assertTrue(globalURI.startsWith("file:"));
String globalPath = new File(new URI(globalURI)).getAbsolutePath();
FileSystemManager fsManager = VFSFactory.createDefaultFileSystemManager();
for (String[] file : inFiles) {
FileObject outFile = fsManager.resolveFile(globalURI + "/" + file[0] + ".glob.A");
log("Checking existence of " + outFile.getURL());
assertTrue(outFile.getURL() + " exists", outFile.exists());
File outFile2 = new File(globalPath, file[0] + ".glob.A");
log("Checking existence of " + outFile2);
assertTrue(outFile2 + " exists", outFile2.exists());
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class BaseSchedulerDBTest method initTest.
@Before
public void initTest() throws Exception {
if (System.getProperty("pa.scheduler.home") == null) {
PASchedulerProperties.SCHEDULER_HOME.updateProperty(ClasspathUtils.findSchedulerHome());
}
System.out.println("Scheduler home : " + PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
PASchedulerProperties.TASK_FORK.updateProperty("true");
CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
if (inMemory) {
dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
} else {
Configuration config = new Configuration().configure(new File(this.getClass().getResource("/functionaltests/config/hibernate-unit.cfg.xml").toURI()));
dbManager = new SchedulerDBManager(config, true);
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class SmartProxyImpl method init.
private void init(String url, Credentials credentials, CredData credData) throws SchedulerException, LoginException {
if (this.connectionInfo == null) {
this.connectionInfo = new ConnectionInfo(url, null, null, null, false);
}
this.connectionInfo.setUrl(url);
this.credentials = credentials;
this.credData = credData;
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
if (this.credentials != null) {
this.credentials = credentials;
this.credData = null;
} else if (this.credData != null) {
this.credData = credData;
try {
this.credentials = Credentials.createCredentials(credData, pubKey);
} catch (KeyException e) {
throw new InternalSchedulerException(e);
}
} else {
throw new IllegalStateException("No valid credential available to connect to the scheduler");
}
this.schedulerProxy = auth.login(this.credentials);
jobTracker.loadJobs();
setInitialized(true);
registerAsListener();
syncAwaitedJobs();
}
Aggregations