use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class SchedulerClientTest method testDataSpaceNodeClientPushDelete.
@Test(timeout = MAX_WAIT_TIME)
public void testDataSpaceNodeClientPushDelete() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = nodeClientJob("/functionaltests/descriptors/dataspace_client_node_push_delete.groovy", "/functionaltests/descriptors/dataspace_client_node_fork.groovy", null);
JobId jobId = submitJob(job, client);
TaskResult tres = client.waitForTask(jobId.toString(), "NodeClientTask", TimeUnit.MINUTES.toMillis(5));
System.out.println(tres.getOutput().getAllLogs(false));
Assert.assertNotNull(tres);
Assert.assertEquals("OK", tres.value());
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class SchedulerClientTest method testJobSubmissionWithGenericInfo.
@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionWithGenericInfo() throws Throwable {
ISchedulerClient client = clientInstance();
// Create a generic infos map
String jobSubmissionGenericInfoKey = "job_generic_info";
String jobSubmissionGenericInfoValue = "!*job generic info value*!";
Map<String, String> genericInfosMap = Collections.singletonMap(jobSubmissionGenericInfoKey, jobSubmissionGenericInfoValue);
// Submit a job with the generic informations map
JobId jobId = client.submit(jobDescriptor, anyMap(), genericInfosMap, anyMap());
client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
// The job generic info must be returned by the task
TaskResult taskResult = client.getJobResult(jobId).getResult("task1");
Assert.assertEquals(jobSubmissionGenericInfoValue, taskResult.value());
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class SchedulerClientTest method testDataSpaceNodeClientPushPull.
@Test(timeout = MAX_WAIT_TIME)
public void testDataSpaceNodeClientPushPull() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = nodeClientJob("/functionaltests/descriptors/dataspace_client_node_push_pull.groovy", "/functionaltests/descriptors/dataspace_client_node_fork.groovy", null);
JobId jobId = submitJob(job, client);
TaskResult tres = client.waitForTask(jobId.toString(), "NodeClientTask", TimeUnit.MINUTES.toMillis(5));
System.out.println(tres.getOutput().getAllLogs(false));
Assert.assertNotNull(tres);
Assert.assertEquals("HelloWorld", tres.value());
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataSpaceClient method init.
public void init(String restServerUrl, ISchedulerClient client) {
this.httpEngine = new ApacheHttpClient4Engine(new HttpClientBuilder().disableContentCompression().insecure(client.getConnectionInfo().isInsecure()).useSystemProperties().build());
this.providerFactory = ResteasyProviderFactory.getInstance();
SchedulerRestClient.registerGzipEncoding(providerFactory);
this.restDataspaceUrl = restDataspaceUrl(restServerUrl);
this.sessionId = client.getSession();
if (log.isDebugEnabled()) {
log.debug("Error : trying to retrieve session from disconnected client.");
}
this.schedulerClient = client;
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataSpaceClient method list.
@Override
public ListFile list(IRemoteSource source) throws NotConnectedException, PermissionException {
StringBuffer uriTmpl = (new StringBuffer()).append(restDataspaceUrl).append(source.getDataspace().value());
ResteasyClient client = new ResteasyClientBuilder().providerFactory(providerFactory).httpEngine(httpEngine).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(source.getPath()).queryParam("comp", "list");
List<String> includes = source.getIncludes();
if (includes != null && !includes.isEmpty()) {
target = target.queryParam("includes", includes.toArray(new Object[includes.size()]));
}
List<String> excludes = source.getExcludes();
if (excludes != null && !excludes.isEmpty()) {
target = target.queryParam("excludes", excludes.toArray(new Object[excludes.size()]));
}
Response response = null;
try {
response = target.request().header("sessionid", sessionId).get();
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedException("User not authenticated or session timeout.");
} else {
throw new RuntimeException(String.format("Cannot list the specified location: %s", source.getPath()));
}
}
return response.readEntity(ListFile.class);
} finally {
if (response != null) {
response.close();
}
}
}
Aggregations