Search in sources :

Example 1 with GetJobReportRequest

use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportRequest 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)

Aggregations

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 GetJobReportResponse (com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportResponse)1 IOException (java.io.IOException)1 Test (org.junit.Test)1