-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd34556
commit e5a93f3
Showing
15 changed files
with
225 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
...latform-common/src/main/java/com/flink/platform/common/exception/DefinitionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
package com.flink.platform.common.exception; | ||
|
||
import com.flink.platform.common.enums.ResponseStatus; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** exception. */ | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DefinitionException extends RuntimeException { | ||
|
||
protected int code; | ||
protected String msg; | ||
private ResponseStatus status; | ||
|
||
public DefinitionException(ResponseStatus responseStatus) { | ||
this.code = responseStatus.getCode(); | ||
this.msg = responseStatus.getDesc(); | ||
this.status = responseStatus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...orm-web/src/main/java/com/flink/platform/web/controller/extension/FlinkJobController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.flink.platform.web.controller.extension; | ||
|
||
import com.flink.platform.dao.entity.JobRunInfo; | ||
import com.flink.platform.dao.entity.result.JobCallback; | ||
import com.flink.platform.dao.service.JobRunInfoService; | ||
import com.flink.platform.grpc.JobGrpcServiceGrpc.JobGrpcServiceBlockingStub; | ||
import com.flink.platform.grpc.SavepointReply; | ||
import com.flink.platform.grpc.SavepointRequest; | ||
import com.flink.platform.web.entity.response.ResultInfo; | ||
import com.flink.platform.web.grpc.JobGrpcClient; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static com.flink.platform.common.constants.Constant.FLINK; | ||
import static com.flink.platform.common.enums.ExecutionStatus.RUNNING; | ||
import static com.flink.platform.common.enums.ExecutionStatus.SUCCESS; | ||
import static com.flink.platform.common.enums.ResponseStatus.OPERATION_NOT_ALLOWED; | ||
import static com.flink.platform.web.entity.response.ResultInfo.failure; | ||
import static com.flink.platform.web.entity.response.ResultInfo.success; | ||
|
||
/** | ||
* flink job controller. | ||
*/ | ||
@RestController | ||
@RequestMapping("/flink") | ||
public class FlinkJobController { | ||
|
||
@Autowired | ||
private JobRunInfoService jobRunService; | ||
|
||
@Autowired | ||
private JobGrpcClient jobGrpcClient; | ||
|
||
@GetMapping(value = "/savepoint/{jobRunId}") | ||
public ResultInfo<Long> savepoint(@PathVariable Long jobRunId) { | ||
JobRunInfo jobRun = jobRunService.getById(jobRunId); | ||
if (!FLINK.equals(jobRun.getType().getClassification())) { | ||
return failure(OPERATION_NOT_ALLOWED, "Only flink job can be savepoint"); | ||
} | ||
|
||
if (!RUNNING.equals(jobRun.getStatus()) && !SUCCESS.equals(jobRun.getStatus())) { | ||
return failure(OPERATION_NOT_ALLOWED, "Job is not running"); | ||
} | ||
|
||
JobCallback callback = jobRun.getBackInfo(); | ||
if (callback == null || StringUtils.isEmpty(callback.getJobId()) || StringUtils.isEmpty(callback.getAppId())) { | ||
return failure(OPERATION_NOT_ALLOWED, "AppId or JobId not found"); | ||
} | ||
|
||
JobGrpcServiceBlockingStub jobGrpcService = jobGrpcClient.grpcClient(jobRun.getHost()); | ||
SavepointRequest request = | ||
SavepointRequest.newBuilder().setJobRunId(jobRunId).build(); | ||
SavepointReply savepoint = jobGrpcService.savepointJob(request); | ||
return success(savepoint.getJobRunId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.