Skip to content

Commit

Permalink
Update CheckPoints.java
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys authored Oct 1, 2024
1 parent ddf0d7b commit ccdc301
Showing 1 changed file with 71 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.apache.streampark.console.core.metrics.flink;

import org.apache.streampark.console.core.enums.CheckPointStatusEnum;
import org.apache.streampark.console.core.enums.CheckPointTypeEnum;
import org.apache.streampark.console.core.enums.CheckPointStatus;
import org.apache.streampark.console.core.enums.CheckPointType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -29,100 +29,97 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

@Getter
@Setter
public class CheckPoints implements Serializable {

private List<CheckPoint> history;
private List<CheckPoint> history;

private Latest latest;
private Latest latest;

@JsonIgnore
public List<CheckPoint> getLatestCheckpoint() {
if (Objects.isNull(latest)) {
return Collections.emptyList();
}
return latest.getLatestCheckpoint();
@JsonIgnore
public List<CheckPoint> getLatestCheckpoint() {
if (latest == null) {
return Collections.emptyList();
}
return latest.getLatestCheckpoint();
}

@Getter
@Setter
public static class CheckPoint implements Serializable {

private Long id;
private String status;
@Getter
@Setter
public static class CheckPoint implements Serializable {
private Long id;
private String status;

@JsonProperty("external_path")
private String externalPath;
@JsonProperty("external_path")
private String externalPath;

@JsonProperty("is_savepoint")
private Boolean isSavepoint;
@JsonProperty("is_savepoint")
private Boolean isSavepoint;

@JsonProperty("latest_ack_timestamp")
private Long latestAckTimestamp;
@JsonProperty("latest_ack_timestamp")
private Long latestAckTimestamp;

@JsonProperty("checkpoint_type")
private String checkpointType;
@JsonProperty("checkpoint_type")
private String checkpointType;

@JsonProperty("trigger_timestamp")
private Long triggerTimestamp;
@JsonProperty("trigger_timestamp")
private Long triggerTimestamp;

@JsonProperty("state_size")
private Long stateSize;
@JsonProperty("state_size")
private Long stateSize;

@JsonProperty("end_to_end_duration")
private Long endToEndDuration;
@JsonProperty("end_to_end_duration")
private Long endToEndDuration;

private Boolean discarded;
private Boolean discarded;

public CheckPointStatusEnum getCheckPointStatus() {
return CheckPointStatusEnum.valueOf(this.status);
}
public CheckPointStatus getCheckPointStatus() {
return CheckPointStatus.valueOf(this.status);
}

public CheckPointTypeEnum getCheckPointType() {
if ("CHECKPOINT".equals(this.checkpointType)) {
return CheckPointTypeEnum.CHECKPOINT;
}
if ("SAVEPOINT".equals(this.checkpointType)) {
return CheckPointTypeEnum.SAVEPOINT;
}
return CheckPointTypeEnum.SYNC_SAVEPOINT;
}
public CheckPointType getCheckPointType() {
if ("CHECKPOINT".equals(this.checkpointType)) {
return CheckPointType.CHECKPOINT;
} else if ("SAVEPOINT".equals(this.checkpointType)) {
return CheckPointType.SAVEPOINT;
}
return CheckPointType.SYNC_SAVEPOINT;
}

public String getPath() {
return this.getExternalPath().replaceFirst("^hdfs:/[^/]", "hdfs:///");
}
public String getPath() {
return this.getExternalPath().replaceFirst("^hdfs:/[^/]", "hdfs:///");
}
}

@Getter
@Setter
public static class Latest implements Serializable {

@Getter
@Setter
public static class Latest implements Serializable {

private CheckPoint completed;
private CheckPoint savepoint;
private CheckPoint failed;

@JsonIgnore
public List<CheckPoint> getLatestCheckpoint() {
List<CheckPoint> checkPoints = new ArrayList<>();
if (completed != null) {
checkPoints.add(completed);
}
if (savepoint != null) {
checkPoints.add(savepoint);
}
if (failed != null) {
if (completed == null) {
checkPoints.add(failed);
} else {
if (failed.getId() > completed.getId()) {
checkPoints.add(failed);
}
}
}
return checkPoints;
private CheckPoint completed;
private CheckPoint savepoint;
private CheckPoint failed;

@JsonIgnore
public List<CheckPoint> getLatestCheckpoint() {
List<CheckPoint> checkPoints = new ArrayList<>();
if (completed != null) {
checkPoints.add(completed);
}
if (savepoint != null) {
checkPoints.add(savepoint);
}
if (failed != null) {
if (completed == null) {
checkPoints.add(failed);
} else {
if (failed.getId() > completed.getId()) {
checkPoints.add(failed);
}
}
}
return checkPoints;
}
}
}

0 comments on commit ccdc301

Please sign in to comment.