use of org.objectweb.proactive.core.util.wrapper.StringWrapper in project scheduling by ow2-proactive.
the class RMCore method getNodeThreadDump.
@Override
@ImmediateService
public StringWrapper getNodeThreadDump(String nodeUrl) {
checkPermissionAndGetClientIsSuccessful();
RMNode node;
try {
node = getAliveNodeOrFail(nodeUrl);
} catch (RuntimeException e) {
logger.warn("Could not get node thread dump for node " + nodeUrl + ": " + e.getMessage());
throw new ThreadDumpNotAccessibleException(nodeUrl, e.getMessage());
}
String threadDump;
try {
threadDump = node.getNode().getThreadDump();
} catch (ProActiveException e) {
logger.error("Could not get node thread dump for node " + nodeUrl, e);
throw new ThreadDumpNotAccessibleException(nodeUrl, "Failed fetching thread dump", e);
}
logger.debug("Thread dump for node " + nodeUrl + ": " + threadDump);
return new StringWrapper(threadDump);
}
use of org.objectweb.proactive.core.util.wrapper.StringWrapper in project scheduling by ow2-proactive.
the class RMCore method getRMThreadDump.
@Override
@ImmediateService
public StringWrapper getRMThreadDump() {
checkPermissionAndGetClientIsSuccessful();
String threadDump;
try {
threadDump = this.nodeRM.getThreadDump();
} catch (ProActiveException e) {
logger.error("Could not get Resource Manager thread dump", e);
throw new ThreadDumpNotAccessibleException(this.getUrl(), "Failed fetching thread dump", e);
}
logger.debug("Resource Manager thread dump: " + threadDump);
return new StringWrapper(threadDump);
}
use of org.objectweb.proactive.core.util.wrapper.StringWrapper in project scheduling by ow2-proactive.
the class SchedulerClientTest method testJobResult.
@Test(timeout = MAX_WAIT_TIME)
public void testJobResult() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = createJobManyTasks("JobResult", SimpleJob.class, ErrorTask.class, LogTask.class, VariableTask.class, MetadataTask.class, RawTask.class);
JobId jobId = submitJob(job, client);
JobResult result = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
// job result
Assert.assertNotNull(result.getJobId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(JobStatus.FINISHED, result.getJobInfo().getStatus());
// the following check cannot work because of the way the job id is created on the client side.
// Assert.assertEquals(job.getName(), result.getName());
Assert.assertTrue(result.hadException());
Assert.assertEquals(1, result.getExceptionResults().size());
// job info
checkJobInfo(result.getJobInfo());
checkJobInfo(client.getJobInfo(jobId.value()));
JobState jobState = client.getJobState(jobId.value());
JobStatus status = jobState.getStatus();
assertFalse(status.isJobAlive());
Assert.assertEquals(JobStatus.FINISHED, status);
checkJobInfo(jobState.getJobInfo());
TaskState errorTaskState = findTask(getTaskNameForClass(ErrorTask.class), jobState.getHMTasks());
Assert.assertNotNull(errorTaskState);
TaskState simpleTaskState = findTask(getTaskNameForClass(SimpleJob.class), jobState.getHMTasks());
Assert.assertNotNull(simpleTaskState);
Assert.assertEquals(TaskStatus.FAULTY, errorTaskState.getStatus());
Assert.assertEquals(TaskStatus.FINISHED, simpleTaskState.getStatus());
// task result simple
TaskResult tResSimple = result.getResult(getTaskNameForClass(SimpleJob.class));
Assert.assertNotNull(tResSimple.value());
Assert.assertNotNull(tResSimple.getSerializedValue());
Assert.assertEquals(new StringWrapper(TEST_JOB), tResSimple.value());
Assert.assertEquals(new StringWrapper(TEST_JOB), ObjectByteConverter.byteArrayToObject(tResSimple.getSerializedValue()));
// task result with error
TaskResult tResError = result.getResult(getTaskNameForClass(ErrorTask.class));
Assert.assertNotNull(tResError);
Assert.assertTrue(tResError.hadException());
Assert.assertNotNull(tResError.getException());
Assert.assertTrue(tResError.getException() instanceof TaskException);
// task result with logs
TaskResult tResLog = result.getResult(getTaskNameForClass(LogTask.class));
Assert.assertNotNull(tResLog);
Assert.assertNotNull(tResLog.getOutput());
System.err.println(tResLog.getOutput().getStdoutLogs(false));
Assert.assertTrue(tResLog.getOutput().getStdoutLogs(false).contains(LogTask.HELLO_WORLD));
// task result with variables
TaskResult tResVar = result.getResult(getTaskNameForClass(VariableTask.class));
Assert.assertNotNull(tResVar.getPropagatedVariables());
Map<String, Serializable> vars = tResVar.getVariables();
System.out.println(vars);
Assert.assertTrue(tResVar.getPropagatedVariables().containsKey(VariableTask.MYVAR));
Assert.assertEquals("myvalue", vars.get(VariableTask.MYVAR));
// task result with metadata
TaskResult tMetaVar = result.getResult(getTaskNameForClass(MetadataTask.class));
Assert.assertNotNull(tMetaVar.getMetadata());
Assert.assertTrue(tMetaVar.getMetadata().containsKey(MetadataTask.MYVAR));
// task result with raw result
TaskResult tResRaw = result.getResult(getTaskNameForClass(RawTask.class));
Assert.assertNotNull(tResRaw.value());
Assert.assertNotNull(tResRaw.getSerializedValue());
Assert.assertArrayEquals(TEST_JOB.getBytes(), (byte[]) tResRaw.value());
Assert.assertArrayEquals(TEST_JOB.getBytes(), tResRaw.getSerializedValue());
}
use of org.objectweb.proactive.core.util.wrapper.StringWrapper in project scheduling by ow2-proactive.
the class RMRestTest method testGetNodeThreadDump.
@Test
public void testGetNodeThreadDump() throws Exception {
RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
when(rm.getNodeThreadDump("pnp://nodeurl")).thenReturn(new StringWrapper("threadDumpExample"));
String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
HttpResponse response = callHttpGetMethod("node/threaddump?nodeurl=pnp://nodeurl", sessionId);
assertEquals(HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
verify(rm).getNodeThreadDump("pnp://nodeurl");
String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
assertEquals("threadDumpExample", responseString);
}
Aggregations