Browse Source

1.0.2文档发布

pull/2/head
lidongdai 6 years ago
parent
commit
06acbe5fd5
  1. 48
      escheduler-api/pom.xml
  2. 1
      escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java
  3. 10
      escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java
  4. 53
      escheduler-api/src/main/java/cn/escheduler/api/configuration/Swagger2.java
  5. 8
      escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java
  6. 4
      escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java
  7. 2
      escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java
  8. 2
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java
  9. 2
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapperProvider.java
  10. 6
      escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java
  11. 5
      escheduler-server/pom.xml
  12. 4
      escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java
  13. 6
      escheduler-server/src/main/java/cn/escheduler/server/quartz/ProcessScheduleJob.java
  14. 2
      escheduler-server/src/main/java/cn/escheduler/server/quartz/QuartzExecutors.java
  15. 5
      escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java

48
escheduler-api/pom.xml

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>cn.analysys</groupId> <groupId>cn.analysys</groupId>
@ -10,13 +11,10 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.analysys</groupId> <groupId>cn.analysys</groupId>
<artifactId>escheduler-dao</artifactId> <artifactId>escheduler-server</artifactId>
</dependency>
<dependency>
<groupId>cn.analysys</groupId>
<artifactId>escheduler-common</artifactId>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
@ -37,6 +35,33 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>cn.analysys</groupId>-->
<!--<artifactId>escheduler-dao</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>cn.analysys</groupId>-->
<!--<artifactId>escheduler-common</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>io.netty</groupId>-->
<!--<artifactId>netty</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>io.netty</groupId>-->
<!--<artifactId>netty-all</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>com.google</groupId>-->
<!--<artifactId>netty</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<artifactId>leveldbjni-all</artifactId>-->
<!--<groupId>org.fusesource.leveldbjni</groupId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<!--springboot--> <!--springboot-->
<dependency> <dependency>
@ -142,6 +167,17 @@
<artifactId>quartz-jobs</artifactId> <artifactId>quartz-jobs</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency> <dependency>
<groupId>cn.analysys</groupId> <groupId>cn.analysys</groupId>
<artifactId>escheduler-rpc</artifactId> <artifactId>escheduler-rpc</artifactId>

1
escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java

@ -20,6 +20,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication @SpringBootApplication
@ServletComponentScan @ServletComponentScan

10
escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java

@ -33,8 +33,16 @@ public class AppConfiguration implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor()).addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN).excludePathPatterns(LOGIN_PATH_PATTERN); registry.addInterceptor(loginInterceptor()).addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN).excludePathPatterns(LOGIN_PATH_PATTERN,"/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html");
} }
//
// @Override
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
// registry.addResourceHandler("swagger-ui.html")
// .addResourceLocations("classpath:/META-INF/resources/");
// registry.addResourceHandler("/webjars/**")
// .addResourceLocations("classpath:/META-INF/resources/webjars/");
// }
@Bean @Bean
public LoginHandlerInterceptor loginInterceptor() { public LoginHandlerInterceptor loginInterceptor() {

53
escheduler-api/src/main/java/cn/escheduler/api/configuration/Swagger2.java

@ -0,0 +1,53 @@
/*
* 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 cn.escheduler.api.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
*
* swager2 config class <br/>
*
*/
@Configuration
@EnableSwagger2
public class Swagger2 implements WebMvcConfigurer {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.basePackage("cn.escheduler.api.controller")).paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("api docs").description("easy scheduler api docs")
.termsOfServiceUrl("https://www.analysys.com").version("1.0.0").build();
}
}

8
escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java

@ -23,6 +23,9 @@ import cn.escheduler.api.service.UsersService;
import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Constants;
import cn.escheduler.api.utils.Result; import cn.escheduler.api.utils.Result;
import cn.escheduler.dao.model.User; import cn.escheduler.dao.model.User;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -60,6 +63,11 @@ public class LoginController extends BaseController {
* @param response * @param response
* @return * @return
*/ */
@ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象,并根据传过来的user信息来更新用户详细信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String"),
@ApiImplicitParam(name = "userPassword", value = "密码", required = true, dataType = "String")
})
@RequestMapping(value = "/login") @RequestMapping(value = "/login")
public Result login(@RequestParam(value = "userName") String userName, public Result login(@RequestParam(value = "userName") String userName,
@RequestParam(value = "userPassword") String userPassword, @RequestParam(value = "userPassword") String userPassword,

4
escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java

@ -19,8 +19,8 @@ package cn.escheduler.api.service;
import cn.escheduler.api.dto.ScheduleParam; import cn.escheduler.api.dto.ScheduleParam;
import cn.escheduler.api.enums.Status; import cn.escheduler.api.enums.Status;
import cn.escheduler.api.quartz.ProcessScheduleJob; import cn.escheduler.server.quartz.ProcessScheduleJob;
import cn.escheduler.api.quartz.QuartzExecutors; import cn.escheduler.server.quartz.QuartzExecutors;
import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Constants;
import cn.escheduler.api.utils.PageInfo; import cn.escheduler.api.utils.PageInfo;
import cn.escheduler.common.enums.FailureStrategy; import cn.escheduler.common.enums.FailureStrategy;

2
escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java

@ -54,7 +54,7 @@ public interface ITaskQueue {
* an element pops out of the queue * an element pops out of the queue
* *
* @param key queue name * @param key queue name
* @param remove where remove the element * @param remove whether remove the element
* @return * @return
*/ */
String poll(String key, boolean remove); String poll(String key, boolean remove);

2
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java

@ -220,7 +220,7 @@ public class ProcessInstanceMapperProvider {
public String queryDetailById(Map<String, Object> parameter) { public String queryDetailById(Map<String, Object> parameter) {
return new SQL() { return new SQL() {
{ {
SELECT("inst.*,q.queue_name as queue,t.tenant_code as tenantCode,UNIX_TIMESTAMP(inst.end_time)-UNIX_TIMESTAMP(inst.start_time) as duration"); SELECT("inst.*,q.queue_name as queue,t.tenant_code,UNIX_TIMESTAMP(inst.end_time)-UNIX_TIMESTAMP(inst.start_time) as duration");
FROM(TABLE_NAME + " inst, t_escheduler_user u,t_escheduler_tenant t,t_escheduler_queue q"); FROM(TABLE_NAME + " inst, t_escheduler_user u,t_escheduler_tenant t,t_escheduler_queue q");

2
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapperProvider.java

@ -208,7 +208,7 @@ public class UserMapperProvider {
public String queryDetailsById(Map<String, Object> parameter) { public String queryDetailsById(Map<String, Object> parameter) {
return new SQL() { return new SQL() {
{ {
SELECT("u.*,q.queue_name as queueName,t.tenant_name as tenantName"); SELECT("u.*,q.queue_name,t.tenant_name");
FROM(TABLE_NAME + " u,t_escheduler_tenant t,t_escheduler_queue q"); FROM(TABLE_NAME + " u,t_escheduler_tenant t,t_escheduler_queue q");

6
escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java

@ -72,4 +72,10 @@ public class UserMapperTest {
Assert.assertEquals(user.getUserName(), "qiaozhanwei"); Assert.assertEquals(user.getUserName(), "qiaozhanwei");
} }
@Test
public void test(){
User user = userMapper.queryDetailsById(19);
System.out.println(user);
}
} }

5
escheduler-server/pom.xml

@ -46,10 +46,7 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>cn.analysys</groupId>
<artifactId>escheduler-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.analysys</groupId> <groupId>cn.analysys</groupId>
<artifactId>escheduler-rpc</artifactId> <artifactId>escheduler-rpc</artifactId>

4
escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java

@ -16,8 +16,8 @@
*/ */
package cn.escheduler.server.master; package cn.escheduler.server.master;
import cn.escheduler.api.quartz.ProcessScheduleJob; import cn.escheduler.server.quartz.ProcessScheduleJob;
import cn.escheduler.api.quartz.QuartzExecutors; import cn.escheduler.server.quartz.QuartzExecutors;
import cn.escheduler.common.Constants; import cn.escheduler.common.Constants;
import cn.escheduler.common.IStoppable; import cn.escheduler.common.IStoppable;
import cn.escheduler.common.thread.Stopper; import cn.escheduler.common.thread.Stopper;

6
escheduler-api/src/main/java/cn/escheduler/api/quartz/ProcessScheduleJob.java → escheduler-server/src/main/java/cn/escheduler/server/quartz/ProcessScheduleJob.java

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.escheduler.api.quartz; package cn.escheduler.server.quartz;
import cn.escheduler.common.Constants; import cn.escheduler.common.Constants;
@ -31,8 +31,8 @@ import org.springframework.util.Assert;
import java.util.Date; import java.util.Date;
import static cn.escheduler.api.quartz.QuartzExecutors.buildJobGroupName; import static cn.escheduler.server.quartz.QuartzExecutors.buildJobGroupName;
import static cn.escheduler.api.quartz.QuartzExecutors.buildJobName; import static cn.escheduler.server.quartz.QuartzExecutors.buildJobName;
/** /**
* process schedule job * process schedule job

2
escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java → escheduler-server/src/main/java/cn/escheduler/server/quartz/QuartzExecutors.java

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.escheduler.api.quartz; package cn.escheduler.server.quartz;
import cn.escheduler.common.Constants; import cn.escheduler.common.Constants;
import cn.escheduler.common.utils.JSONUtils; import cn.escheduler.common.utils.JSONUtils;

5
escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java

@ -134,7 +134,7 @@ public class FetchTaskThread implements Runnable{
public void run() { public void run() {
while (Stopper.isRunning()){ while (Stopper.isRunning()){
long start = System.currentTimeMillis();
InterProcessMutex mutex = null; InterProcessMutex mutex = null;
try { try {
if(OSUtils.checkResource(this.conf, false)) { if(OSUtils.checkResource(this.conf, false)) {
@ -221,7 +221,10 @@ public class FetchTaskThread implements Runnable{
logger.info("task : {} ready to submit to task scheduler thread",taskId); logger.info("task : {} ready to submit to task scheduler thread",taskId);
// submit task // submit task
workerExecService.submit(new TaskScheduleThread(taskInstance, processDao)); workerExecService.submit(new TaskScheduleThread(taskInstance, processDao));
logger.info("{} 耗时: {} ms",taskQueueStr,System.currentTimeMillis() - start );
} }
} }
} }

Loading…
Cancel
Save