Skip to content

Commit

Permalink
fix #91
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 18, 2016
1 parent 1e6ab95 commit a45d9a6
Show file tree
Hide file tree
Showing 97 changed files with 3,006 additions and 1,446 deletions.
43 changes: 43 additions & 0 deletions elastic-job-api/elastic-job-api-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>elastic-job-api</artifactId>
<groupId>com.dangdang</groupId>
<version>1.0.7-SNAPSHOT</version>
</parent>
<artifactId>elastic-job-api-core</artifactId>
<name>${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/

package com.dangdang.ddframe.job.api;

import com.dangdang.ddframe.job.internal.operate.JobOperateAPIImpl;
import com.dangdang.ddframe.job.internal.reg.RegistryCenterFactory;
import com.dangdang.ddframe.job.internal.settings.JobSettingsAPIImpl;
import com.dangdang.ddframe.job.internal.statistics.JobStatisticsAPIImpl;
import com.dangdang.ddframe.job.internal.statistics.ServerStatisticsAPIImpl;
import com.google.common.base.Optional;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
* 作业API工厂.
*
* @author zhangliang
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JobAPIFactory {

/**
* 创建作业配置API对象.
*
* @param connectString 注册中心连接字符串
* @param namespace 注册中心命名空间
* @param digest 注册中心凭证
* @return 操作作业API对象
*/
public static JobSettingsAPI createJobSettingsAPI(final String connectString, final String namespace, final Optional<String> digest) {
return new JobSettingsAPIImpl(RegistryCenterFactory.createCoordinatorRegistryCenter(connectString, namespace, digest));
}

/**
* 创建操作作业API对象.
*
* @param connectString 注册中心连接字符串
* @param namespace 注册中心命名空间
* @param digest 注册中心凭证
* @return 操作作业API对象
*/
public static JobOperateAPI createJobOperateAPI(final String connectString, final String namespace, final Optional<String> digest) {
return new JobOperateAPIImpl(RegistryCenterFactory.createCoordinatorRegistryCenter(connectString, namespace, digest));
}

/**
* 创建作业状态展示API对象.
*
* @param connectString 注册中心连接字符串
* @param namespace 注册中心命名空间
* @param digest 注册中心凭证
* @return 操作作业API对象
*/
public static JobStatisticsAPI createJobStatisticsAPI(final String connectString, final String namespace, final Optional<String> digest) {
return new JobStatisticsAPIImpl(RegistryCenterFactory.createCoordinatorRegistryCenter(connectString, namespace, digest));
}

/**
* 创建作业服务器状态展示API对象.
*
* @param connectString 注册中心连接字符串
* @param namespace 注册中心命名空间
* @param digest 注册中心凭证
* @return 操作作业API对象
*/
public static ServerStatisticsAPI createServerStatisticsAPI(final String connectString, final String namespace, final Optional<String> digest) {
return new ServerStatisticsAPIImpl(RegistryCenterFactory.createCoordinatorRegistryCenter(connectString, namespace, digest));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/

package com.dangdang.ddframe.job.api;

import com.google.common.base.Optional;

import java.util.Collection;

/**
* 操作作业的API.
*
* @author zhangliang
*/
public interface JobOperateAPI {

/**
* 作业暂停.
*
* <p>不会导致重新分片.</p>
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
*/
void pause(Optional<String> jobName, Optional<String> serverIp);

/**
* 作业恢复.
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
*/
void resume(Optional<String> jobName, Optional<String> serverIp);

/**
* 作业禁用.
*
* <p>会重新分片.</p>
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
*/
void disable(Optional<String> jobName, Optional<String> serverIp);

/**
* 作业启用.
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
*/
void enable(Optional<String> jobName, Optional<String> serverIp);

/**
* 作业关闭.
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
*/
void shutdown(Optional<String> jobName, Optional<String> serverIp);

/**
* 作业删除.
*
* <p>只有停止运行的作业才能删除.</p>
*
* @param jobName 作业名称
* @param serverIp 作业服务器IP地址
* @return 因为未停止而导致未能成功删除的作业服务器IP地址列表
*/
Collection<String> remove(Optional<String> jobName, Optional<String> serverIp);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Licensed 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.
Expand All @@ -15,24 +15,30 @@
* </p>
*/

package com.dangdang.ddframe.job.console.service;
package com.dangdang.ddframe.job.api;

import java.util.Collection;
import com.dangdang.ddframe.job.domain.JobSettings;

import com.dangdang.ddframe.job.console.domain.ExecutionInfo;
import com.dangdang.ddframe.job.console.domain.JobBriefInfo;
import com.dangdang.ddframe.job.console.domain.JobServer;
import com.dangdang.ddframe.job.console.domain.JobSettings;

public interface JobDimensionService {

Collection<JobBriefInfo> getAllJobsBriefInfo();
/**
* 作业配置的API.
*
* @author zhangliang
*/
public interface JobSettingsAPI {

/**
* 获取作业设置.
*
* @param jobName 作业名称
* @return 作业设置对象
*/
JobSettings getJobSettings(String jobName);

/**
* 更新作业设置.
*
* @param jobSettings 作业设置对象
*/
void updateJobSettings(JobSettings jobSettings);

Collection<JobServer> getServers(String jobName);

Collection<ExecutionInfo> getExecutionInfo(String jobName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/

package com.dangdang.ddframe.job.api;

import com.dangdang.ddframe.job.domain.ExecutionInfo;
import com.dangdang.ddframe.job.domain.JobBriefInfo;
import com.dangdang.ddframe.job.domain.ServerInfo;

import java.util.Collection;

/**
* 作业状态展示的API.
*
* @author zhangliang
*/
public interface JobStatisticsAPI {

/**
* 获取所有作业简明信息.
*
* @return 作业简明信息集合.
*/
Collection<JobBriefInfo> getAllJobsBriefInfo();

/**
* 获取执行作业的服务器.
*
* @param jobName 作业名称
* @return 作业的服务器集合
*/
Collection<ServerInfo> getServers(String jobName);

/**
* 获取作业运行时信息.
*
* @param jobName 作业名称
* @return 作业运行时信息集合
*/
Collection<ExecutionInfo> getExecutionInfo(String jobName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/

package com.dangdang.ddframe.job.api;

import com.dangdang.ddframe.job.domain.ServerInfo;
import com.dangdang.ddframe.job.domain.ServerBriefInfo;

import java.util.Collection;

/**
* 作业服务器状态展示的API.
*
* @author zhangliang
*/
public interface ServerStatisticsAPI {

/**
* 获取所有作业服务器简明信息.
*
* @return 作业服务器简明信息集合
*/
Collection<ServerBriefInfo> getAllServersBriefInfo();

/**
* 获取作业服务器部署的作业.
*
* @param serverIp 作业服务器IP
* @return 作业服务器部署的作业
*/
Collection<ServerInfo> getJobs(String serverIp);
}
Loading

0 comments on commit a45d9a6

Please sign in to comment.