use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse in project angel by Tencent.
the class AppTest method tryGetResponseFromFile.
private GetJobReportResponse tryGetResponseFromFile(boolean deleteOnExist) throws IOException {
org.apache.hadoop.fs.Path internalStateFile = angelClient.getInternalStateFile();
GetJobReportResponse response = null;
FileSystem fs = internalStateFile.getFileSystem(angelClient.getConf());
if (fs.exists(internalStateFile)) {
LOG.info(internalStateFile + " exist, parse app report from it");
FSDataInputStream in = fs.open(internalStateFile);
response = GetJobReportResponse.parseFrom(in);
if (deleteOnExist) {
fs.delete(internalStateFile.getParent(), true);
}
}
return response;
}
use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse in project angel by Tencent.
the class AppTest method testGetJobReport.
@SuppressWarnings("unchecked")
@Test
public void testGetJobReport() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
Location masterLoc = LocalClusterContext.get().getMaster().getAppMaster().getAppContext().getMasterService().getLocation();
TConnection connection = TConnectionManager.getConnection(angelAppMaster.getConfig());
MasterProtocol master = connection.getMasterService(masterLoc.getIp(), masterLoc.getPort());
int task0Iteration = 2;
int task1Iteration = 1;
int jobIteration = (task0Iteration < task1Iteration) ? task0Iteration : task1Iteration;
master.taskIteration(null, TaskIterationRequest.newBuilder().setIteration(task0Iteration).setTaskId(ProtobufUtil.convertToIdProto(task0Id)).build());
master.taskIteration(null, TaskIterationRequest.newBuilder().setIteration(task1Iteration).setTaskId(ProtobufUtil.convertToIdProto(task1Id)).build());
Thread.sleep(1000);
GetJobReportRequest request = GetJobReportRequest.newBuilder().setAppId(LocalClusterContext.get().getAppId().toString()).build();
GetJobReportResponse response = master.getJobReport(null, request);
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_RUNNING);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
angelAppMaster.getAppContext().getEventHandler().handle(new InternalErrorEvent(angelAppMaster.getAppContext().getApplicationId(), "failed"));
Thread.sleep(5000);
response = master.getJobReport(null, request);
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
assertEquals(response.getJobReport().getDiagnostics(), "failed");
// Thread.sleep(5000);
// response = master.getJobReport(null, request);
// assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
// assertEquals(response.getJobReport().getCurIteration(), jobIteration);
// assertEquals(response.getJobReport().getDiagnostics(), "failed");
Thread.sleep(10000);
try {
response = master.getJobReport(null, request);
} catch (Exception x) {
response = tryGetResponseFromFile(true);
}
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
assertEquals(response.getJobReport().getDiagnostics(), "failed");
} catch (Exception x) {
LOG.error("run testGetJobReport failed ", x);
throw x;
}
}
use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse in project angel by Tencent.
the class App method serilize.
/**
* write application state to output stream
*
* @param out output stream
*/
public void serilize(FSDataOutputStream out) throws IOException {
GetJobReportResponse jobState = getJobReportResponse();
jobState.writeTo(out);
LOG.info("write app report to file successfully " + jobState);
}
Aggregations