Skip to content

Commit

Permalink
[release] Merge branch 'v3.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
KFCFans committed Jun 21, 2020
2 parents 271eafc + 459b980 commit 774126b
Show file tree
Hide file tree
Showing 39 changed files with 371 additions and 138 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -38,7 +38,7 @@ PowerJob(原OhMyScheduler)是全新一代分布式调度与计算框架,
| 日志白屏化 | 不支持 | 支持 | 不支持 | **支持** |
| 调度方式及性能 | 基于数据库锁,有性能瓶颈 | 基于数据库锁,有性能瓶颈 | 不详 | **无锁化设计,性能强劲无上限** |
| 报警监控 || 邮件 | 短信 | **邮件,提供接口允许开发者扩展** |
| 系统依赖 | MySQL | MySQL | 人民币(公测期间免费,哎,帮打个广告吧) | **任意Spring Data Jpa支持的关系型数据库(MySQL、Oracle...)** |
| 系统依赖 | JDBC支持的关系型数据库(MySQL、Oracle...) | MySQL | 人民币(公测期间免费,哎,帮打个广告吧) | **任意Spring Data Jpa支持的关系型数据库(MySQL、Oracle...)** |
| DAG工作流 | 不支持 | 不支持 | 支持 | **支持** |


Expand Down
20 changes: 11 additions & 9 deletions README_enUS.md
@@ -1,13 +1,15 @@
<p align="center">
<img src="https://raw.githubusercontent.com/KFCFans/OhMyScheduler/master/others/images/oms-logo.png" alt="OhMyScheduler" title="OhMyScheduler" width="557"/>
<img src="https://raw.githubusercontent.com/KFCFans/PowerJob/master/others/images/logo.png" alt="PowerJob" title="PowerJob" width="557"/>
</p>

<p align="center">
<a href="https://github.com/KFCFans/OhMyScheduler/actions"><img src="https://github.com/KFCFans/OhMyScheduler/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master"></a>
<a href="https://github.com/KFCFans/OhMyScheduler/blob/master/LICENSE"><img src="https://img.shields.io/github/license/KFCFans/OhMyScheduler"></a>
<a href="https://github.com/KFCFans/PowerJob/actions"><img src="https://github.com/KFCFans/PowerJob/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master" alt="actions"></a>
<a href="https://search.maven.org/search?q=com.github.kfcfans"><img alt="Maven Central" src="https://img.shields.io/maven-central/v/com.github.kfcfans/powerjob-worker"></a>
<a href="https://github.com/KFCFans/PowerJob/releases"><img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/kfcfans/powerjob?color=%23E59866"></a>
<a href="https://github.com/KFCFans/PowerJob/blob/master/LICENSE"><img src="https://img.shields.io/github/license/KFCFans/PowerJob" alt="LICENSE"></a>
</p>

OhMyScheduler is a powerful distributed scheduling platform and distributed computing framework based on Akka architecture.It provides you a chance to schedule job and distributed computing easily.
PowerJob is a powerful distributed scheduling platform and distributed computing framework based on Akka architecture.It provides you a chance to schedule job and distributed computing easily.

# Introduction

Expand All @@ -30,7 +32,7 @@ OhMyScheduler is a powerful distributed scheduling platform and distributed comp

### Comparison of similar products

| | QuartZ | xxl-job | SchedulerX 2.0 | OhMyScheduler |
| | QuartZ | xxl-job | SchedulerX 2.0 | PowerJob |
| ---------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Timing type | CRON | CRON | CRON, fixed frequency, fixed delay, OpenAPI | **CRON, fixed frequency, fixed delay, OpenAPI** |
| Task type | Built-in Java | Built-in Java, GLUE Java, Shell, Python and other scripts | Built-in Java, external Java (FatJar), Shell, Python and other scripts | **Built-in Java, external Java (container), Shell, Python and other scripts** |
Expand All @@ -39,13 +41,13 @@ OhMyScheduler is a powerful distributed scheduling platform and distributed comp
| Log blanking | not support | support | not support | **support** |
| Scheduling methods and performance | Based on database lock, there is a performance bottleneck | Based on database lock, there is a performance bottleneck | Unknown | **Lock-free design, powerful performance without upper limit** |
| Alarm monitoring | no | mail | SMS | **Email, providing an interface to allow developers to customize development** |
| System dependence | MySQL | MySQL | Renminbi (free during public beta, hey, help to advertise) | **Any relational database (MySQL, Oracle ...) supported by Spring Data Jpa** |
| DAG workflow | not support | not support | support | **support** |
| System dependence | Any relational database (MySQL, Oracle ...) supported by JDBC | MySQL | Renminbi (free during public beta, hey, help to advertise) | **Any relational database (MySQL, Oracle ...) supported by Spring Data Jpa** |
| workflow | not support | not support | support | **support** |

# Document
**[GitHub Wiki](https://github.com/KFCFans/OhMyScheduler/wiki)**
**[GitHub Wiki](https://github.com/KFCFans/PowerJob/wiki)**

**[中文文档](https://www.yuque.com/ohmyscheduler/product)**
**[中文文档](https://www.yuque.com/powerjob/product)**

# Others

Expand Down
4 changes: 2 additions & 2 deletions powerjob-client/pom.xml
Expand Up @@ -10,11 +10,11 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-client</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<properties>
<powerjob.common.version>3.0.1</powerjob.common.version>
<powerjob.common.version>3.1.0</powerjob.common.version>
<junit.version>5.6.1</junit.version>
</properties>

Expand Down
Expand Up @@ -15,6 +15,7 @@
import okhttp3.RequestBody;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

Expand All @@ -39,8 +40,8 @@ public class OhMyClient {
* @param domain www.oms-server.com(内网域名,自行完成DNS & Proxy)
* @param appName 负责的应用名称
*/
public OhMyClient(String domain, String appName) {
this(Lists.newArrayList(domain), appName);
public OhMyClient(String domain, String appName, String password) {
this(Lists.newArrayList(domain), appName, password);
}


Expand All @@ -49,16 +50,16 @@ public OhMyClient(String domain, String appName) {
* @param addressList IP:Port 列表
* @param appName 负责的应用名称
*/
public OhMyClient(List<String> addressList, String appName) {
public OhMyClient(List<String> addressList, String appName, String password) {

Objects.requireNonNull(addressList, "domain can't be null!");
Objects.requireNonNull(appName, "appName can't be null");

allAddress = addressList;
for (String addr : addressList) {
String url = getUrl(OpenAPIConstant.ASSERT, addr) + "?appName=" + appName;
String url = getUrl(OpenAPIConstant.ASSERT, addr);
try {
String result = HttpUtils.get(url);
String result = assertApp(appName, password, url);
if (StringUtils.isNotEmpty(result)) {
ResultDTO resultDTO = JsonUtils.parseObject(result, ResultDTO.class);
if (resultDTO.isSuccess()) {
Expand All @@ -77,6 +78,15 @@ public OhMyClient(List<String> addressList, String appName) {
log.info("[OhMyClient] {}'s oms-client bootstrap successfully.", appName);
}

private static String assertApp(String appName, String password, String url) throws IOException {
FormBody.Builder builder = new FormBody.Builder()
.add("appName", appName);
if (password != null) {
builder.add("password", password);
}
return HttpUtils.post(url, builder.build());
}


private static String getUrl(String path, String address) {
return String.format(URL_PATTERN, address, OpenAPIConstant.WEB_PATH, path);
Expand Down
4 changes: 2 additions & 2 deletions powerjob-client/src/test/java/TestClient.java
Expand Up @@ -21,15 +21,15 @@ public class TestClient {

@BeforeAll
public static void initClient() throws Exception {
ohMyClient = new OhMyClient("127.0.0.1:7700", "oms-test2");
ohMyClient = new OhMyClient("127.0.0.1:7700", "oms-test2", null);
}

@Test
public void testSaveJob() throws Exception {

SaveJobInfoRequest newJobInfo = new SaveJobInfoRequest();
// newJobInfo.setId(8L);
newJobInfo.setJobName("omsOpenAPIJob");
newJobInfo.setJobName("omsOpenAPIJobccccc");
newJobInfo.setJobDescription("tes OpenAPI");
newJobInfo.setJobParams("{'aa':'bb'}");
newJobInfo.setTimeExpressionType(TimeExpressionType.CRON);
Expand Down
2 changes: 1 addition & 1 deletion powerjob-client/src/test/java/TestWorkflow.java
Expand Up @@ -20,7 +20,7 @@ public class TestWorkflow {

@BeforeAll
public static void initClient() throws Exception {
ohMyClient = new OhMyClient("127.0.0.1:7700", "oms-test");
ohMyClient = new OhMyClient("127.0.0.1:7700", "oms-test", null);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion powerjob-common/pom.xml
Expand Up @@ -10,7 +10,7 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-common</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
@@ -1,4 +1,4 @@
package com.github.kfcfans.powerjob.common.request.http;
package com.github.kfcfans.powerjob.common.request;

import com.github.kfcfans.powerjob.common.OmsSerializable;
import lombok.AllArgsConstructor;
Expand Down
4 changes: 2 additions & 2 deletions powerjob-server/pom.xml
Expand Up @@ -10,13 +10,13 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-server</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<properties>
<swagger.version>2.9.2</swagger.version>
<springboot.version>2.2.6.RELEASE</springboot.version>
<powerjob.common.version>3.0.1</powerjob.common.version>
<powerjob.common.version>3.1.0</powerjob.common.version>
<mysql.version>8.0.19</mysql.version>
<h2.db.version>1.4.200</h2.db.version>
<zip4j.version>2.5.2</zip4j.version>
Expand Down
Expand Up @@ -6,7 +6,7 @@
import com.github.kfcfans.powerjob.common.request.TaskTrackerReportInstanceStatusReq;
import com.github.kfcfans.powerjob.common.request.WorkerHeartbeat;
import com.github.kfcfans.powerjob.common.request.WorkerLogReportReq;
import com.github.kfcfans.powerjob.common.request.http.WorkerNeedDeployContainerRequest;
import com.github.kfcfans.powerjob.common.request.WorkerNeedDeployContainerRequest;
import com.github.kfcfans.powerjob.common.response.AskResponse;
import com.github.kfcfans.powerjob.common.utils.JsonUtils;
import com.github.kfcfans.powerjob.common.utils.NetUtils;
Expand Down
Expand Up @@ -21,7 +21,8 @@ public class AppInfoDO {
private Long id;

private String appName;
private String description;
// 应用分组密码
private String password;

// 当前负责该 appName 旗下任务调度的server地址,IP:Port(注意,该地址为ActorSystem地址,而不是HTTP地址,两者端口不同)
private String currentServer;
Expand Down
@@ -0,0 +1,38 @@
package com.github.kfcfans.powerjob.server.service;

import com.github.kfcfans.powerjob.common.OmsException;
import com.github.kfcfans.powerjob.server.persistence.core.model.AppInfoDO;
import com.github.kfcfans.powerjob.server.persistence.core.repository.AppInfoRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
* 应用信息服务
*
* @author tjq
* @since 2020/6/20
*/
@Service
public class AppInfoService {

@Resource
private AppInfoRepository appInfoRepository;

/**
* 验证应用访问权限
* @param appName 应用名称
* @param password 密码
* @return 应用ID
*/
public Long assertApp(String appName, String password) {

AppInfoDO appInfo = appInfoRepository.findByAppName(appName).orElseThrow(() -> new OmsException("can't find appInfo by appName: " + appName));
if (Objects.equals(appInfo.getPassword(), password)) {
return appInfo.getId();
}
throw new OmsException("password error!");
}

}
Expand Up @@ -3,6 +3,8 @@
import com.github.kfcfans.powerjob.common.response.ResultDTO;
import com.github.kfcfans.powerjob.server.persistence.core.model.AppInfoDO;
import com.github.kfcfans.powerjob.server.persistence.core.repository.AppInfoRepository;
import com.github.kfcfans.powerjob.server.service.AppInfoService;
import com.github.kfcfans.powerjob.server.web.request.AppAssertRequest;
import com.github.kfcfans.powerjob.server.web.request.ModifyAppInfoRequest;
import com.google.common.collect.Lists;
import lombok.Data;
Expand All @@ -29,6 +31,8 @@
@RequestMapping("/appInfo")
public class AppInfoController {

@Resource
private AppInfoService appInfoService;
@Resource
private AppInfoRepository appInfoRepository;

Expand All @@ -53,6 +57,11 @@ public ResultDTO<Void> saveAppInfo(@RequestBody ModifyAppInfoRequest req) {
return ResultDTO.success(null);
}

@PostMapping("/assert")
public ResultDTO<Long> assertApp(@RequestBody AppAssertRequest request) {
return ResultDTO.success(appInfoService.assertApp(request.getAppName(), request.getPassword()));
}

@GetMapping("/delete")
public ResultDTO<Void> deleteAppInfo(Long appId) {
appInfoRepository.deleteById(appId);
Expand Down
Expand Up @@ -3,8 +3,7 @@
import com.github.kfcfans.powerjob.common.InstanceStatus;
import com.github.kfcfans.powerjob.common.OpenAPIConstant;
import com.github.kfcfans.powerjob.common.request.http.SaveWorkflowRequest;
import com.github.kfcfans.powerjob.server.persistence.core.model.AppInfoDO;
import com.github.kfcfans.powerjob.server.persistence.core.repository.AppInfoRepository;
import com.github.kfcfans.powerjob.server.service.AppInfoService;
import com.github.kfcfans.powerjob.server.service.CacheService;
import com.github.kfcfans.powerjob.server.service.JobService;
import com.github.kfcfans.powerjob.server.service.instance.InstanceService;
Expand All @@ -15,7 +14,6 @@
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Optional;

/**
* 开放接口(OpenAPI)控制器,对接 oms-client
Expand All @@ -27,6 +25,8 @@
@RequestMapping(OpenAPIConstant.WEB_PATH)
public class OpenAPIController {

@Resource
private AppInfoService appInfoService;
@Resource
private JobService jobService;
@Resource
Expand All @@ -39,14 +39,10 @@ public class OpenAPIController {
@Resource
private CacheService cacheService;

@Resource
private AppInfoRepository appInfoRepository;

@GetMapping(OpenAPIConstant.ASSERT)
public ResultDTO<Long> assertAppName(String appName) {
Optional<AppInfoDO> appInfoOpt = appInfoRepository.findByAppName(appName);
return appInfoOpt.map(appInfoDO -> ResultDTO.success(appInfoDO.getId()))
.orElseGet(() -> ResultDTO.failed(appName + " is not registered!"));
@PostMapping(OpenAPIConstant.ASSERT)
public ResultDTO<Long> assertAppName(String appName, @RequestParam(required = false) String password) {
return ResultDTO.success(appInfoService.assertApp(appName, password));
}

/* ************* Job 区 ************* */
Expand Down
@@ -0,0 +1,15 @@
package com.github.kfcfans.powerjob.server.web.request;

import lombok.Data;

/**
* 验证应用(应用登陆)
*
* @author tjq
* @since 2020/6/20
*/
@Data
public class AppAssertRequest {
private String appName;
private String password;
}
Expand Up @@ -13,5 +13,5 @@ public class ModifyAppInfoRequest {

private Long id;
private String appName;
private String description;
private String password;
}

0 comments on commit 774126b

Please sign in to comment.