Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Jun 3, 2016
1 parent 2840a02 commit c6a782a
Show file tree
Hide file tree
Showing 81 changed files with 2,000 additions and 707 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
/**
* 作业基本配置信息.
*
* @author zhangliang
* @author caohao
*/
public interface JobConfiguration<T extends ElasticJob> {
Expand All @@ -48,7 +47,7 @@ public interface JobConfiguration<T extends ElasticJob> {
*
* @return 作业实现类名称
*/
Class<T> getJobClass();
Class<? extends T> getJobClass();

/**
* 获取作业分片总数.
Expand All @@ -64,13 +63,6 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
String getCron();

/**
* 设置分片序列号和个性化参数对照表.
*
* @param shardingItemParameters 分片序列号和个性化参数对照表
*/
void setShardingItemParameters(String shardingItemParameters);

/**
* 获取分片序列号和个性化参数对照表.
*
Expand All @@ -85,13 +77,6 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
String getShardingItemParameters();

/**
* 设置作业自定义参数.
*
* @param jobParameter 作业自定义参数
*/
void setJobParameter(String jobParameter);

/**
* 获取作业自定义参数.
*
Expand All @@ -103,13 +88,6 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
String getJobParameter();

/**
* 设置监控作业执行时状态.
*
* @param monitorExecution 监控作业执行时状态
*/
void setMonitorExecution(boolean monitorExecution);

/**
* 获取监控作业执行时状态.
*
Expand All @@ -122,13 +100,6 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
boolean isMonitorExecution();

/**
* 设置最大容忍的本机与注册中心的时间误差秒数.
*
* @param maxTimeDiffSeconds 最大容忍的本机与注册中心的时间误差秒数
*/
void setMaxTimeDiffSeconds(int maxTimeDiffSeconds);

/**
* 获取最大容忍的本机与注册中心的时间误差秒数.
*
Expand All @@ -141,13 +112,6 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
int getMaxTimeDiffSeconds();

/**
* 设置是否开启失效转移.
*
* @param failover 是否开启失效转移
*/
void setFailover(boolean failover);

/**
* 获取是否开启失效转移.
*
Expand All @@ -159,41 +123,20 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
boolean isFailover();

/**
* 设置是否开启misfire.
*
* @param misfire 是否开启misfire
*/
void setMisfire(boolean misfire);

/**
* 获取是否开启misfire.
*
* @return misfire
*/
boolean isMisfire();

/**
* 设置作业辅助监控端口.
*
* @param monitorPort 作业辅助监控端口
*/
void setMonitorPort(int monitorPort);

/**
* 获取作业辅助监控端口.
*
* @return 作业辅助监控端口
*/
int getMonitorPort();

/**
* 设置作业分片策略实现类全路径.
*
* @param jobShardingStrategyClass 作业分片策略实现类全路径
*/
void setJobShardingStrategyClass(String jobShardingStrategyClass);

/**
* 获取作业分片策略实现类全路径.
*
Expand All @@ -205,45 +148,30 @@ public interface JobConfiguration<T extends ElasticJob> {
*/
String getJobShardingStrategyClass();

/**
* 设置作业描述信息.
*
* @param description 作业描述信息
*/
void setDescription(String description);

/**
* 获取作业描述信息.
*
* @return 作业描述信息
*/
String getDescription();

/**
* 设置作业是否禁止启动.
*
* @param disabled 作业是否禁止启动
*/
void setDisabled(boolean disabled);

/**
* 获取作业是否禁止启动.
*
* <p>
* 可用于部署作业时, 先禁止启动, 部署结束后统一启动.
* </p>
*
* @return 作业是否禁止启动
*/
boolean isDisabled();

/**
* 设置本地配置是否可覆盖注册中心配置.
*
* @param overwrite 本地配置是否可覆盖注册中心配置
*/
void setOverwrite(boolean overwrite);

/**
* 获取本地配置是否可覆盖注册中心配置.
*
* <p>
* 如果可覆盖, 每次启动作业都以本地配置为准.
* </p>
*
* @return 本地配置是否可覆盖注册中心配置
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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.config;

import com.dangdang.ddframe.job.api.DataFlowElasticJob;
import com.dangdang.ddframe.job.api.config.impl.DataFlowJobConfiguration.DataFlowJobConfigurationBuilder;
import com.dangdang.ddframe.job.api.config.impl.ScriptJobConfiguration.ScriptJobConfigurationBuilder;
import com.dangdang.ddframe.job.api.config.impl.SimpleJobConfiguration.SimpleJobConfigurationBuilder;
import com.dangdang.ddframe.job.plugin.job.type.simple.AbstractSimpleElasticJob;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
* 作业配置工厂.
*
* @author caohao
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JobConfigurationFactory {

/**
* 创建简单作业配置.
*
* @param jobName 作业名称
* @param jobClass 作业实现类名称
* @param shardingTotalCount 分片总数
* @param cron 作业启动时间的cron表达式
* @return 简单作业配置
*/
public static SimpleJobConfigurationBuilder createSimpleJobConfigurationBuilder(final String jobName,
final Class<? extends AbstractSimpleElasticJob> jobClass, final int shardingTotalCount, final String cron) {
return new SimpleJobConfigurationBuilder(jobName, jobClass, shardingTotalCount, cron);
}

/**
* 创建数据流作业配置.
*
* @param jobName 作业名称
* @param jobClass 作业实现类名称
* @param shardingTotalCount 分片总数
* @param cron 作业启动时间的cron表达式
* @return 数据流作业配置
*/
public static DataFlowJobConfigurationBuilder createDataFlowJobConfigurationBuilder(final String jobName,
final Class<? extends DataFlowElasticJob> jobClass, final int shardingTotalCount, final String cron) {
return new DataFlowJobConfigurationBuilder(jobName, jobClass, shardingTotalCount, cron);
}

/**
* 创建脚本作业配置.
*
* @param jobName 作业名称
* @param shardingTotalCount 分片总数
* @param cron 作业启动时间的cron表达式
* @param scriptCommandLine 作业脚本命令行
* @return 脚本作业配置
*/
public static ScriptJobConfigurationBuilder createScriptJobConfigurationBuilder(final String jobName, final int shardingTotalCount,
final String cron, final String scriptCommandLine) {
return new ScriptJobConfigurationBuilder(jobName, shardingTotalCount, cron, scriptCommandLine);
}
}
Loading

0 comments on commit c6a782a

Please sign in to comment.