Skip to content

Commit

Permalink
several bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
guowl3 committed Jul 11, 2024
1 parent 8037bb9 commit 954f759
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import java.util.List;
import java.util.Set;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.oceanbase.odc.service.connection.database.model.Database;
import com.oceanbase.odc.service.schedule.model.ScheduleTaskParameters;
import com.oceanbase.tools.dbbrowser.model.DBObjectType;
Expand All @@ -37,14 +41,16 @@ public class DataArchiveParameters implements ScheduleTaskParameters {

private String name;

@NotNull
private Long sourceDatabaseId;

@NotNull
private Long targetDataBaseId;

// inner init
@JsonProperty(access = Access.READ_ONLY)
private Database sourceDatabase;

// inner init
@JsonProperty(access = Access.READ_ONLY)
private Database targetDatabase;

private List<OffsetConfig> variables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.List;

import javax.validation.constraints.NotNull;

import com.oceanbase.odc.service.connection.database.model.Database;
import com.oceanbase.odc.service.schedule.model.ScheduleTaskParameters;

Expand All @@ -30,6 +32,7 @@
@Data
public class DataDeleteParameters implements ScheduleTaskParameters {

@NotNull
private Long databaseId;

private Long targetDatabaseId;
Expand All @@ -44,6 +47,7 @@ public class DataDeleteParameters implements ScheduleTaskParameters {

private List<DataArchiveTableConfig> tables;

@NotNull
private RateLimitConfiguration rateLimit;

private Boolean deleteByUniqueKey = true;
Expand All @@ -62,6 +66,6 @@ public class DataDeleteParameters implements ScheduleTaskParameters {

private Long timeoutMillis;

private boolean fullDatabase;
private boolean fullDatabase = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ public void jobToBeExecuted(JobExecutionContext context) {
entity.setFireTime(context.getFireTime());
entity = taskRepository.save(entity);
Optional<LatestTaskMappingEntity> optional = latestTaskMappingRepository.findByScheduleId(scheduleId);
if (optional.isPresent()) {
Optional<ScheduleTaskEntity> taskEntityOptional =
taskRepository.findById(optional.get().getLatestScheduleTaskId());
if (taskEntityOptional.isPresent() && !taskEntityOptional.get().getStatus().isTerminated()) {
log.warn("Concurrent scheduling is not allowed, ignoring this trigger, scheduleId={}", scheduleId);
return;
}
}
LatestTaskMappingEntity latestTaskMapping =
optional.isPresent() ? optional.get() : new LatestTaskMappingEntity();
latestTaskMapping.setLatestScheduleTaskId(entity.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.oceanbase.odc.service.schedule.model;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.fasterxml.jackson.annotation.JsonSubTypes;
Expand Down Expand Up @@ -43,11 +45,14 @@ public class CreateScheduleReq {
@JsonSubTypes.Type(value = DataArchiveParameters.class, name = "DATA_ARCHIVE"),
@JsonSubTypes.Type(value = DataDeleteParameters.class, name = "DATA_DELETE")
})
@NotNull
private ScheduleTaskParameters parameters;

// DATA_ARCHIVE、DATA_DELETE、PARTITION_PLAN
@NotNull
private ScheduleType type;

@NotNull
private TriggerConfig triggerConfig;

private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonRawValue;
import com.oceanbase.odc.core.shared.constant.TaskStatus;

import lombok.Data;
Expand All @@ -36,8 +37,10 @@ public class ScheduleTaskDetailResp {

private TaskStatus status;

@JsonRawValue
private String parameters;

@JsonRawValue
private String executionDetails;

private Date fireTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
}
} catch (Throwable e) {
log.warn("Start job failed, jobId={}.", a.getId(), e);
configuration.getTaskFrameworkDisabledHandler().handleJobToFailed();
// TODO 暂时调度失败直接放弃,不然会阻塞后续任务调度
configuration.getTaskFrameworkService().updateJobToCanceling(a.getId(), a.getStatus());
}
}

Expand Down

0 comments on commit 954f759

Please sign in to comment.