Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lts-jobtracker/src/main/java/com/github/ltsopensource/jobtracker/sender/JobSender.java
#	pom.xml
  • Loading branch information
yuan.cheng committed May 16, 2017
2 parents 2df365b + 2b18df0 commit 64bc6e1
Show file tree
Hide file tree
Showing 29 changed files with 288 additions and 51 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ oschina地址:

这两个地址都会同步更新。感兴趣,请加QQ群:109500214 一起探讨、完善。越多人支持,就越有动力去更新,喜欢记得右上角star哈。

##1.7.0-SNAPSHOT(master)变更主要点
1. 增加手动触发任务按钮
2. 优化PreLoader
##1.7.1-SNAPSHOT(master)变更主要点
1. 增加 jdbc.create.db.table(boolean)来决定是否需要创建数据库表

## 框架概况
LTS 有主要有以下四种节点:
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ start mvn clean install -DskipTests
echo "LTS: mvn clean install -DskipTests"
echo "LTS: After sub window finished, close it , and press any key to continue" & pause>nul

set VERSION=1.7.0-SNAPSHOT
set VERSION=1.7.1-SNAPSHOT
set BASE_HOME=%~dp0%
set DIST_BIN_DIR=lts-%VERSION%-bin

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="1.7.0-SNAPSHOT"
VERSION="1.7.1-SNAPSHOT"

LTS_BIN="${BASH_SOURCE-$0}"
LTS_BIN="$(dirname "${LTS_BIN}")"
Expand Down
4 changes: 2 additions & 2 deletions lts-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
Expand Down Expand Up @@ -215,4 +215,4 @@
<artifactId>mongo-java-driver</artifactId>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<td>{{row.logType | format:'logTypeLabel'}}</td>
<td>{{row.success | format:'successLabel'}}</td>
<td>{{row.level}}</td>
<td>{{row.relyOnPrevCycle | format:'formatRelyOnPrevCycle',row}}</td>
<td>{{row.depPreCycle | format:'formatRelyOnPrevCycle',row}}</td>
<td>{{row.retryTimes | format:'formatRetryTimes', row}}</td>
<td>{{row.priority}}</td>
<td>{{row.triggerTime | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
Expand Down
9 changes: 7 additions & 2 deletions lts-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down Expand Up @@ -136,5 +136,10 @@
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface HttpCmdNames {

String HTTP_CMD_JOB_TERMINATE = "job_terminate_cmd";

String HTTP_CMD_NODE_ONLINE_OFFLINE = "node_online_offline_cmd";

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public interface ExtConfig {
String JDBC_URL = "jdbc.url";
String JDBC_USERNAME = "jdbc.username";
String JDBC_PASSWORD = "jdbc.password";

String NEED_CREATE_DB_TABLE = "jdbc.create.db.table";
/**
* Durid相关数据的配置
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.ltsopensource.core.logger.jcl.JclLoggerAdapter;
import com.github.ltsopensource.core.logger.jdk.JdkLoggerAdapter;
import com.github.ltsopensource.core.logger.log4j.Log4jLoggerAdapter;
import com.github.ltsopensource.core.logger.logback.LogbackLoggerAdapter;
import com.github.ltsopensource.core.logger.slf4j.Slf4jLoggerAdapter;
import com.github.ltsopensource.core.logger.support.FailsafeLogger;
import com.github.ltsopensource.core.spi.ServiceLoader;
Expand All @@ -28,7 +29,9 @@ private LoggerFactory() {
// 查找常用的日志框架
static {
String logger = System.getProperty("lts.logger");
if ("slf4j".equals(logger)) {
if ("logback".equals(logger)) {
setLoggerAdapter(new LogbackLoggerAdapter());
} else if ("slf4j".equals(logger)) {
setLoggerAdapter(new Slf4jLoggerAdapter());
} else if ("jcl".equals(logger)) {
setLoggerAdapter(new JclLoggerAdapter());
Expand All @@ -38,15 +41,19 @@ private LoggerFactory() {
setLoggerAdapter(new JdkLoggerAdapter());
} else {
try {
setLoggerAdapter(new Slf4jLoggerAdapter());
} catch (Throwable e1) {
setLoggerAdapter(new LogbackLoggerAdapter());
} catch (Throwable e0) {
try {
setLoggerAdapter(new Log4jLoggerAdapter());
} catch (Throwable e2) {
setLoggerAdapter(new Slf4jLoggerAdapter());
} catch (Throwable e1) {
try {
setLoggerAdapter(new JclLoggerAdapter());
} catch (Throwable e3) {
setLoggerAdapter(new JdkLoggerAdapter());
setLoggerAdapter(new Log4jLoggerAdapter());
} catch (Throwable e2) {
try {
setLoggerAdapter(new JclLoggerAdapter());
} catch (Throwable e3) {
setLoggerAdapter(new JdkLoggerAdapter());
}
}
}
}
Expand Down Expand Up @@ -132,4 +139,4 @@ public static File getFile() {
return LOGGER_ADAPTER.getFile();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.github.ltsopensource.core.logger.logback;

import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.support.AbstractLogger;

import java.io.Serializable;

public class LogbackLogger extends AbstractLogger implements Logger, Serializable {

private static final long serialVersionUID = 1L;
private final ch.qos.logback.classic.Logger logger;

public LogbackLogger(ch.qos.logback.classic.Logger logger) {
this.logger = logger;
}

public void trace(String msg) {
logger.trace(msg);
}

public void trace(Throwable e) {
logger.trace(e.getMessage(), e);
}

public void trace(String msg, Throwable e) {
logger.trace(msg, e);
}

public void debug(String msg) {
logger.debug(msg);
}

public void debug(Throwable e) {
logger.debug(e.getMessage(), e);
}

public void debug(String msg, Throwable e) {
logger.debug(msg, e);
}

public void info(String msg) {
logger.info(msg);
}

public void info(Throwable e) {
logger.info(e.getMessage(), e);
}

public void info(String msg, Throwable e) {
logger.info(msg, e);
}

public void warn(String msg) {
logger.warn(msg);
}

public void warn(Throwable e) {
logger.warn(e.getMessage(), e);
}

public void warn(String msg, Throwable e) {
logger.warn(msg, e);
}

public void error(String msg) {
logger.error(msg);
}

public void error(Throwable e) {
logger.error(e.getMessage(), e);
}

public void error(String msg, Throwable e) {
logger.error(msg, e);
}

public boolean isTraceEnabled() {
return logger.isTraceEnabled();
}

public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}

public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}

public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}

public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.github.ltsopensource.core.logger.logback;

import com.github.ltsopensource.core.logger.Level;
import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.LoggerAdapter;
import org.slf4j.LoggerFactory;

import java.io.File;

public class LogbackLoggerAdapter implements LoggerAdapter {

public LogbackLoggerAdapter() {
try {
Class.forName("ch.qos.logback.classic.Logger");
} catch (ClassNotFoundException e) {
throw new RuntimeException("ch.qos.logback.classic.Logger not found");
}
}

public Logger getLogger(String key) {
return new LogbackLogger((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(key));
}

public Logger getLogger(Class<?> key) {
return new LogbackLogger((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(key));
}

private Level level;

private File file;

public void setLevel(Level level) {
this.level = level;
}

public Level getLevel() {
return level;
}

public File getFile() {
return file;
}

public void setFile(File file) {
this.file = file;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.github.ltsopensource.core.AppContext;
import com.github.ltsopensource.core.cluster.Config;
import com.github.ltsopensource.core.cluster.NodeType;
import com.github.ltsopensource.core.commons.utils.Callable;
import com.github.ltsopensource.core.constant.ExtConfig;
import com.github.ltsopensource.core.domain.monitor.MData;
import com.github.ltsopensource.core.factory.NamedThreadFactory;
import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.LoggerFactory;
import com.github.ltsopensource.core.support.NodeShutdownHook;
import com.github.ltsopensource.jvmmonitor.JVMMonitor;

import java.util.concurrent.Executors;
Expand Down Expand Up @@ -41,17 +43,25 @@ public final void start() {
// 启动JVM监控
JVMMonitor.start();

final MStatReportWorker worker = new MStatReportWorker(appContext, this);

try {
if (!config.getParameter(ExtConfig.M_STAT_REPORTER_CLOSED, false)) {
if (start.compareAndSet(false, true)) {
scheduledFuture = executor.scheduleWithFixedDelay(
new MStatReportWorker(appContext, this), 1, 1, TimeUnit.SECONDS);
scheduledFuture = executor.scheduleWithFixedDelay(worker, 1, 1, TimeUnit.SECONDS);
LOGGER.info("MStatReporter start succeed.");
}
}
} catch (Exception e) {
LOGGER.error("MStatReporter start failed.", e);
}

NodeShutdownHook.registerHook(appContext, this.getClass().getName(), new Callable() {
@Override
public void call() throws Exception {
worker.run();
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private Version() {}

private static final Logger LOGGER = LoggerFactory.getLogger(Version.class);

private static final String VERSION = getVersion(Version.class, "1.7.0-SNAPSHOT");
private static final String VERSION = getVersion(Version.class, "1.7.1-SNAPSHOT");

static {
// 检查是否存在重复的jar包
Expand Down Expand Up @@ -113,4 +113,4 @@ public static void checkDuplicate(String path, boolean failOnError) {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static String getClassCode(Integer sequence, Class<?> sourceClass, Class

String beanCopierClassName = sourceClass.getSimpleName() + "2" + targetClass.getSimpleName() + BeanCopier.class.getSimpleName() + sequence;
String classDefinitionCode = "public class " + beanCopierClassName +
" extends " + BeanCopierAdapter.class.getSimpleName();
" extends " + BeanCopierAdapter.class.getName();

javaSourceBean.setClassDefinition(classDefinitionCode);

Expand All @@ -107,8 +107,8 @@ private static String getMethodImplCode(Integer sequence, Class<?> sourceClass,

StringBuilder methodCode = new StringBuilder();
methodCode.append("public void copyProps(").append(Object.class.getName()).append(" sourceObj, ").append(Object.class.getName()).append(" targetObj){\n");
methodCode.append(sourceClass.getSimpleName()).append(" source = ").append("(").append(sourceClass.getSimpleName()).append(")sourceObj;\n");
methodCode.append(targetClass.getSimpleName()).append(" target = ").append("(").append(targetClass.getSimpleName()).append(")targetObj;\n");
methodCode.append(sourceClass.getName()).append(" source = ").append("(").append(sourceClass.getName()).append(")sourceObj;\n");
methodCode.append(targetClass.getName()).append(" target = ").append("(").append(targetClass.getName()).append(")targetObj;\n");

// 这里查找了包括父类的属性
Field[] targetFields = ReflectionUtils.findFields(targetClass);
Expand All @@ -120,13 +120,19 @@ private static String getMethodImplCode(Integer sequence, Class<?> sourceClass,
Class<?> targetFieldClass = field.getType();

Method setMethod = ReflectionUtils.findMethod(targetClass, "set" + methodNameSuffix, targetFieldClass);
if (setMethod == null) {
setMethod = ReflectionUtils.findMethod(targetClass, "set" + field.getName(), targetFieldClass);
if (setMethod != null) {
methodNameSuffix = field.getName();
}
}
if (setMethod != null) {

// 查看这个属性是否有 PropConverter
if (propCvtMap != null && propCvtMap.containsKey(field.getName())) {

String converterName = field.getName() + "Converter";
String converterType = PropConverter.class.getSimpleName();
String converterType = PropConverter.class.getName();

methodCode.append(converterType).append(" ").append(converterName).append(" = (").append(converterType).append(")")
.append(BeanCopierFactory.class.getName()).append(".getConverter(").append(sequence).append(",").append("\"").append(field.getName()).append("\");\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<JobPo> getJobs(String taskTrackerIdentity) {
@Override
public List<JobPo> getDeadJobs(long deadline) {
Query<JobPo> query = template.createQuery(JobPo.class);
query.filter("gmtCreated < ", deadline);
query.filter("gmtModified < ", deadline);
return query.asList();
}

Expand Down
Loading

0 comments on commit 64bc6e1

Please sign in to comment.