추론 완료 shp파일 생성 수정

This commit is contained in:
2026-01-20 17:12:46 +09:00
parent 3271315d38
commit 6d423534f1
4 changed files with 102 additions and 9 deletions

View File

@@ -0,0 +1,23 @@
package com.kamco.cd.kamcoback.scheduler.config;
import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration
@EnableAsync
public class AsyncConfig {
@Bean(name = "shpExecutor")
public Executor shpExecutor() {
ThreadPoolTaskExecutor ex = new ThreadPoolTaskExecutor();
ex.setCorePoolSize(2);
ex.setMaxPoolSize(4);
ex.setQueueCapacity(50);
ex.setThreadNamePrefix("shp-");
ex.initialize();
return ex;
}
}

View File

@@ -0,0 +1,27 @@
package com.kamco.cd.kamcoback.scheduler.config;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import org.springframework.stereotype.Component;
@Component
public class ShpKeyLock {
private final ConcurrentHashMap<String, ReentrantLock> locks = new ConcurrentHashMap<>();
public boolean tryLock(String key) {
ReentrantLock lock = locks.computeIfAbsent(key, k -> new ReentrantLock());
return lock.tryLock();
}
public void unlock(String key) {
ReentrantLock lock = locks.get(key);
if (lock != null && lock.isHeldByCurrentThread()) {
lock.unlock();
// 메모리 누수 방지(락이 비어있으면 제거)
if (!lock.hasQueuedThreads()) {
locks.remove(key, lock);
}
}
}
}