Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-11401][Manager] Support Dolphinscheduler schedule engine #11468

Merged
merged 10 commits into from
Nov 20, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.manager.pojo.schedule.dolphinschedule;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class DSTaskDefinition {

@ApiModelProperty("DolphinScheduler task definition code")
@JsonProperty("code")
private long code;

@ApiModelProperty("DolphinScheduler task definition code")
@JsonProperty("delayTime")
private String delayTime;

@ApiModelProperty("DolphinScheduler task definition description")
@JsonProperty("description")
private String description;

@ApiModelProperty("DolphinScheduler task definition environment code")
@JsonProperty("environmentCode")
private int environmentCode;

@ApiModelProperty("DolphinScheduler task fail retry interval")
@JsonProperty("failRetryInterval")
private String failRetryInterval;

@ApiModelProperty("DolphinScheduler task definition fail retry times")
@JsonProperty("failRetryTimes")
private String failRetryTimes;

@ApiModelProperty("DolphinScheduler task definition flag")
@JsonProperty("flag")
private String flag;

@ApiModelProperty("DolphinScheduler task definition isCache")
@JsonProperty("isCache")
private String isCache;

@ApiModelProperty("DolphinScheduler task definition name")
@JsonProperty("name")
private String name;

@ApiModelProperty("DolphinScheduler task definition params")
@JsonProperty("taskParams")
private DSTaskParams taskParams;

@ApiModelProperty("DolphinScheduler task definition priority")
@JsonProperty("taskPriority")
private String taskPriority;

@ApiModelProperty("DolphinScheduler task definition type")
@JsonProperty("taskType")
private String taskType;

@ApiModelProperty("DolphinScheduler task definition timeout")
@JsonProperty("timeout")
private int timeout;

@ApiModelProperty("DolphinScheduler task definition timeout flag")
@JsonProperty("timeoutFlag")
private String timeoutFlag;

@ApiModelProperty("DolphinScheduler task definition timeout notify strategy")
@JsonProperty("timeoutNotifyStrategy")
private String timeoutNotifyStrategy;

@ApiModelProperty("DolphinScheduler task definition worker group")
@JsonProperty("workerGroup")
private String workerGroup;

@ApiModelProperty("DolphinScheduler task definition apu quota")
@JsonProperty("cpuQuota")
private int cpuQuota;

@ApiModelProperty("DolphinScheduler task definition memory max")
@JsonProperty("memoryMax")
private int memoryMax;

@ApiModelProperty("DolphinScheduler task definition execute type")
@JsonProperty("taskExecuteType")
private String taskExecuteType;

public DSTaskDefinition() {
this.delayTime = "0";
this.description = "";
this.environmentCode = -1;
this.failRetryInterval = "1";
this.failRetryTimes = "0";
this.flag = "YES";
this.isCache = "NO";
this.taskPriority = "MEDIUM";
this.taskType = "SHELL";
this.timeoutFlag = "CLOSE";
this.timeoutNotifyStrategy = "";
this.workerGroup = "default";
this.cpuQuota = -1;
this.memoryMax = -1;
this.taskExecuteType = "BATCH";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.manager.pojo.schedule.dolphinschedule;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
@Data
public class DSTaskParams {

@ApiModelProperty("DolphinScheduler task params local params")
@JsonProperty("localParams")
private List<Object> localParams;

@ApiModelProperty("DolphinScheduler task params raw script")
@JsonProperty("rawScript")
private String rawScript;

@ApiModelProperty("DolphinScheduler task params resource list")
@JsonProperty("resourceList")
private List<Object> resourceList;

public DSTaskParams() {
this.localParams = new ArrayList<>();
this.resourceList = new ArrayList<>();
this.rawScript = "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.manager.pojo.schedule.dolphinschedule;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class DSTaskRelation {

@ApiModelProperty("DolphinScheduler task relation name")
@JsonProperty("name")
private String name;

@ApiModelProperty("DolphinScheduler task relation pre-task code")
@JsonProperty("preTaskCode")
private int preTaskCode;

@ApiModelProperty("DolphinScheduler task relation pre-task version")
@JsonProperty("preTaskVersion")
private int preTaskVersion;

@ApiModelProperty("DolphinScheduler task relation post-task code")
@JsonProperty("postTaskCode")
private long postTaskCode;

@ApiModelProperty("DolphinScheduler task relation post-task version")
@JsonProperty("postTaskVersion")
private int postTaskVersion;

@ApiModelProperty("DolphinScheduler task relation condition type")
@JsonProperty("conditionType")
private String conditionType;

@ApiModelProperty("DolphinScheduler task relation condition params")
@JsonProperty("conditionParams")
private Object conditionParams;

public DSTaskRelation() {
this.name = "";
this.conditionType = "NONE";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.manager.pojo.schedule.dolphinschedule;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class DScheduleInfo {

@ApiModelProperty("DolphinScheduler schedule start time")
@JsonProperty("startTime")
private String startTime;

@ApiModelProperty("DolphinScheduler schedule end time")
@JsonProperty("endTime")
private String endTime;

@ApiModelProperty("DolphinScheduler schedule crontab expression")
@JsonProperty("crontab")
private String crontab;

@ApiModelProperty("DolphinScheduler schedule timezone id")
@JsonProperty("timezoneId")
private String timezoneId;

}
30 changes: 30 additions & 0 deletions inlong-manager/manager-schedule/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,35 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
<exclusion>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
public enum ScheduleEngineType {

NONE("None"),
QUARTZ("Quartz");
QUARTZ("Quartz"),
DOLPHINSCHEDULER("DolphinScheduler");

private final String type;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.manager.schedule.dolphinscheduler;

import org.apache.inlong.manager.pojo.schedule.ScheduleInfo;
import org.apache.inlong.manager.schedule.ScheduleEngineClient;
import org.apache.inlong.manager.schedule.ScheduleEngineType;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* Built-in implementation of third-party schedule engine client corresponding with {@link DolphinScheduleEngine}.
* DolphinScheduleClient simply invokes the {@link DolphinScheduleEngine} to register/unregister/update
* schedule info, all the logic for invoking the remote scheduling service is implemented in {@link DolphinScheduleEngine}
*/
@Service
public class DolphinScheduleClient implements ScheduleEngineClient {

@Resource
public DolphinScheduleEngine scheduleEngine;

@Override
public boolean accept(String engineType) {
return ScheduleEngineType.DOLPHINSCHEDULER.getType().equalsIgnoreCase(engineType);
}

@Override
public boolean register(ScheduleInfo scheduleInfo) {
return scheduleEngine.handleRegister(scheduleInfo);
}

@Override
public boolean unregister(String groupId) {
return scheduleEngine.handleUnregister(groupId);
}

@Override
public boolean update(ScheduleInfo scheduleInfo) {
return scheduleEngine.handleUpdate(scheduleInfo);
}
}
Loading
Loading