-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/hellohao-dev'
# Conflicts: # src/main/java/cn/hellohao/service/impl/InitializationStorage.java
- Loading branch information
Showing
46 changed files
with
896 additions
and
940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM openjdk:8 | ||
|
||
MAINTAINER 923453645@qq.com | ||
|
||
ADD hellohaotbed/ /hellohaotbed | ||
|
||
COPY appstart.sh /appstart.sh | ||
|
||
COPY application.properties /application.properties | ||
|
||
COPY Tbed.jar /Tbed.jar | ||
|
||
EXPOSE 10088 | ||
|
||
EXPOSE 10089 | ||
|
||
CMD ["/bin/bash","/appstart.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cn.hellohao.config; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Configuration; | ||
import javax.annotation.PostConstruct; | ||
import java.io.PrintStream; | ||
import java.util.function.Consumer; | ||
|
||
@Configuration | ||
public class LogSystemProxy { | ||
|
||
private final static Logger log = LoggerFactory.getLogger("proxy.system.log"); | ||
|
||
@PostConstruct | ||
public void initProxy(){ | ||
log.debug("LogSystemProxy init ....."); | ||
System.setOut(getLoggerProxy(StdType.OUT)); | ||
System.setErr(getLoggerProxy(StdType.ERR)); | ||
} | ||
|
||
|
||
private enum StdType{ | ||
OUT(System.out, log::info), | ||
ERR(System.err, log::error), | ||
; | ||
PrintStream stream; | ||
Consumer<String> consumer; | ||
StdType(PrintStream stream,Consumer<String> consumer){ | ||
this.stream = stream; | ||
this.consumer = consumer; | ||
} | ||
} | ||
|
||
private PrintStream getLoggerProxy(StdType stdType){ | ||
return new PrintStream(stdType.stream){ | ||
@Override | ||
public void print(String s) { | ||
stdType.stream.print(s); | ||
stdType.consumer.accept(s); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cn.hellohao.config; | ||
|
||
import lombok.Data; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.util.concurrent.ThreadPoolExecutor; | ||
|
||
//线程池 | ||
@Configuration | ||
@EnableAsync | ||
public class PoolConfig { | ||
ThreadPoolProperties properties = new ThreadPoolProperties(); | ||
@Bean(name = "taskExecutor") | ||
public ThreadPoolTaskExecutor taskExecutor() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(properties.getCorePoolSize()); | ||
executor.setMaxPoolSize(properties.getMaxPoolSize()); | ||
executor.setQueueCapacity(properties.getQueueCapacity()); | ||
executor.setThreadNamePrefix(properties.getThreadNamePrefix()); | ||
executor.setKeepAliveSeconds(properties.getKeepAliveTime()); | ||
executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown()); | ||
executor.setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds()); | ||
// 设置任务拒绝策略 | ||
/** | ||
* 4种 | ||
* ThreadPoolExecutor类有几个内部实现类来处理这类情况: | ||
- AbortPolicy 丢弃任务,抛RejectedExecutionException | ||
- CallerRunsPolicy 由该线程调用线程运行。直接调用Runnable的run方法运行。 | ||
- DiscardPolicy 抛弃策略,直接丢弃这个新提交的任务 | ||
- DiscardOldestPolicy 抛弃旧任务策略,从队列中踢出最先进入队列(最后一个执行)的任务 | ||
* 实现RejectedExecutionHandler接口,可自定义处理器 | ||
*/ | ||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | ||
return executor; | ||
} | ||
|
||
@Data | ||
class ThreadPoolProperties { | ||
private int corePoolSize = 5; | ||
private int maxPoolSize = 50; | ||
private int keepAliveTime = 15; | ||
private int queueCapacity = 6; | ||
private String threadNamePrefix = "Tbed-Thread"; | ||
private boolean allowCoreThreadTimeout = false; | ||
private boolean waitForTasksToCompleteOnShutdown = false; | ||
private int awaitTerminationSeconds; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.