-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Config 재설정하기 - SchedulerConfig 추가 - Scheduler 도메인 별 분리 - AsyncConfig 및 AsyncExceptionHandler 추가 * chore(package): 패키지 명 및 구조 변경 * chore: 설정 파일 명칭 변경 및 내용 이동 * feat: 메서드 실행시간 측정 로깅 추가 및 P6spy stack trace 추가
- Loading branch information
1 parent
48b3878
commit 75b474b
Showing
16 changed files
with
146 additions
and
39 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/com/prgrms/mukvengers/global/config/async/AsyncConfig.java
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,24 @@ | ||
package com.prgrms.mukvengers.global.config.async; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.AsyncConfigurer; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@EnableAsync | ||
@Configuration | ||
@RequiredArgsConstructor | ||
public class AsyncConfig implements AsyncConfigurer { | ||
|
||
private final ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
|
||
@Override | ||
public Executor getAsyncExecutor() { | ||
return threadPoolTaskExecutor; | ||
} | ||
|
||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/prgrms/mukvengers/global/config/scheduler/SchedulerConfig.java
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,27 @@ | ||
package com.prgrms.mukvengers.global.config.scheduler; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.SchedulingConfigurer; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||
import org.springframework.scheduling.config.ScheduledTaskRegistrar; | ||
|
||
@EnableScheduling | ||
@Configuration | ||
@ComponentScan(basePackages = "com.prgrms.mukvengers.global.scheduler") | ||
public class SchedulerConfig implements SchedulingConfigurer { | ||
|
||
private static final int POOL_SIZE = 10; | ||
|
||
@Override | ||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { | ||
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); | ||
threadPoolTaskScheduler.setPoolSize(POOL_SIZE); | ||
threadPoolTaskScheduler.setThreadNamePrefix("scheduled-task-pool-"); | ||
threadPoolTaskScheduler.initialize(); | ||
|
||
taskRegistrar.setTaskScheduler(threadPoolTaskScheduler); | ||
} | ||
} | ||
|
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
39 changes: 39 additions & 0 deletions
39
src/main/java/com/prgrms/mukvengers/global/log/LoggingAspect.java
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,39 @@ | ||
package com.prgrms.mukvengers.global.log; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.Signature; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Aspect | ||
@Component | ||
// @Profile("performance") | ||
public class LoggingAspect { | ||
|
||
@Pointcut("execution(* com.prgrms.mukvengers.domain..*(..))") | ||
public void methodInDomain() { | ||
} | ||
|
||
// 메서드 실행시간 분석 | ||
@Around("methodInDomain()") | ||
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { | ||
long startTime = System.currentTimeMillis(); | ||
Object result = joinPoint.proceed(); | ||
long endTime = System.currentTimeMillis(); | ||
|
||
long executionTimeMillis = endTime - startTime; | ||
|
||
Signature signature = joinPoint.getSignature(); | ||
|
||
String methodName = signature.getName(); | ||
String className = signature.getDeclaringType().getSimpleName(); | ||
log.info("[ExecutionTime] : {}.{} took {}ms", className, methodName, executionTimeMillis); | ||
|
||
return result; | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...l/slack/annotation/SlackNotification.java → .../report/annotation/SlackNotification.java
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
2 changes: 1 addition & 1 deletion
2
...vengers/global/slack/dto/RequestInfo.java → ...engers/global/report/dto/RequestInfo.java
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/prgrms/mukvengers/global/scheduler/CrewScheduler.java
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,26 @@ | ||
package com.prgrms.mukvengers.global.scheduler; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.prgrms.mukvengers.domain.crew.repository.CrewRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CrewScheduler { | ||
|
||
private final CrewRepository crewRepository; | ||
|
||
@Async | ||
@Scheduled(cron = "0 0 * * * *", zone = "Asia/Seoul") | ||
@Transactional | ||
public void changStatusOvertimeCrew() { | ||
crewRepository.updateAllStatusToFinish(LocalDateTime.now()); | ||
} | ||
} |
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
6 changes: 0 additions & 6 deletions
6
src/main/resources/application-aws.yml → src/main/resources/application-cloud.yml
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 |
---|---|---|
@@ -1,9 +1,3 @@ | ||
spring: | ||
servlet: | ||
multipart: | ||
max-request-size: 10MB | ||
max-file-size: 10MB | ||
|
||
cloud: | ||
aws: | ||
s3: | ||
|
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
2 changes: 1 addition & 1 deletion
2
...al/slack/SlackNotificationAspectTest.java → ...l/report/SlackNotificationAspectTest.java
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ spring: | |
include: | ||
- test | ||
- security | ||
- aws | ||
- cloud |