Search in sources :

Example 1 with GetJobReportResponse

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;
}
Also used : FileSystem(org.apache.hadoop.fs.FileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) GetJobReportResponse(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse)

Example 2 with GetJobReportResponse

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;
    }
}
Also used : TConnection(com.tencent.angel.ipc.TConnection) InternalErrorEvent(com.tencent.angel.master.app.InternalErrorEvent) GetJobReportRequest(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportRequest) IOException(java.io.IOException) Location(com.tencent.angel.common.location.Location) GetJobReportResponse(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse) Test(org.junit.Test)

Example 3 with GetJobReportResponse

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);
}
Also used : GetJobReportResponse(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse)

Aggregations

GetJobReportResponse (com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse)3 Location (com.tencent.angel.common.location.Location)1 TConnection (com.tencent.angel.ipc.TConnection)1 InternalErrorEvent (com.tencent.angel.master.app.InternalErrorEvent)1 GetJobReportRequest (com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportRequest)1 IOException (java.io.IOException)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 LocalFileSystem (org.apache.hadoop.fs.LocalFileSystem)1 Test (org.junit.Test)1