스케쥴러 처리 방식 변경(스케쥴러 스레드풀 증가 + 차량번호끝1자리문자별 자료처리 스레드)
parent
2954b624d1
commit
1afb8931fe
@ -1,333 +0,0 @@
|
||||
package cfs.schd.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cfs.WASInfo;
|
||||
import cfs.schd.ExemptCarInfo;
|
||||
import cfs.schd.LocalResidentsCarInfo;
|
||||
import cfs.schd.dao.SchdDao;
|
||||
|
||||
@Component("cfsDaemon")
|
||||
public class CfsDaemon {
|
||||
|
||||
private List<MovingOutDaemonThread> movingOutDaemons;
|
||||
private List<NtttnDaemonThread> ntttnDaemons;
|
||||
private List<DspsnDaemonThread> dspsnDaemons;
|
||||
|
||||
@Resource(name="schdDao")
|
||||
private SchdDao schdDao;
|
||||
|
||||
@Resource(name="localResidentsCarInfo")
|
||||
private LocalResidentsCarInfo localResidentsCarInfo;
|
||||
|
||||
@Resource(name="exemptCarInfo")
|
||||
private ExemptCarInfo exemptCarInfo;
|
||||
|
||||
List<String> digits = Arrays.asList("0","1","2","3","4","5","6","7","8","9");
|
||||
|
||||
@PostConstruct
|
||||
public void onCreated() {
|
||||
|
||||
createThread();
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void onDestroyed() {
|
||||
for(MovingOutDaemonThread daemon : movingOutDaemons){
|
||||
if(!daemon.isInterrupted()){
|
||||
daemon.interrupt();
|
||||
}
|
||||
}
|
||||
for(NtttnDaemonThread daemon : ntttnDaemons){
|
||||
if(!daemon.isInterrupted()){
|
||||
daemon.interrupt();
|
||||
}
|
||||
}
|
||||
for(DspsnDaemonThread daemon : dspsnDaemons){
|
||||
if(!daemon.isInterrupted()){
|
||||
daemon.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createThread() {
|
||||
|
||||
movingOutDaemons = new ArrayList<MovingOutDaemonThread>();
|
||||
for(String digit : digits){
|
||||
MovingOutDaemonThread daemon = new MovingOutDaemonThread(digit);
|
||||
daemon.setDaemon(true);
|
||||
movingOutDaemons.add(daemon);
|
||||
}
|
||||
|
||||
ntttnDaemons = new ArrayList<NtttnDaemonThread>();
|
||||
for(String digit : digits){
|
||||
NtttnDaemonThread daemon = new NtttnDaemonThread(digit);
|
||||
daemon.setDaemon(true);
|
||||
ntttnDaemons.add(daemon);
|
||||
}
|
||||
|
||||
dspsnDaemons = new ArrayList<DspsnDaemonThread>();
|
||||
for(String digit : digits){
|
||||
DspsnDaemonThread daemon = new DspsnDaemonThread(digit);
|
||||
daemon.setDaemon(true);
|
||||
dspsnDaemons.add(daemon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String startDaemon(String daemonName) {
|
||||
String result = "";
|
||||
|
||||
if(countDaemon(daemonName) != 0){
|
||||
killDaemon(daemonName);
|
||||
return "기존 실행 중인 데몬 종료 요청함";
|
||||
}
|
||||
|
||||
String runWAS = schdDao.selectRunWas(daemonName);
|
||||
|
||||
if(!WASInfo.getWAS().equals(runWAS)){
|
||||
return "미실행WAS";
|
||||
}
|
||||
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null || movingOutDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
} else {
|
||||
for(MovingOutDaemonThread demon : movingOutDaemons){
|
||||
if(Thread.State.NEW == demon.getState()){
|
||||
demon.start();
|
||||
} else {
|
||||
demon.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = "시작됨";
|
||||
} else if(daemonName.equals("ITF_FIS_O_012")){
|
||||
if(ntttnDaemons == null || ntttnDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
} else {
|
||||
for(NtttnDaemonThread demon : ntttnDaemons){
|
||||
if(Thread.State.NEW == demon.getState()){
|
||||
demon.start();
|
||||
} else {
|
||||
demon.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = "시작됨";
|
||||
} else if(daemonName.equals("ITF_CFS_O_013")){
|
||||
if(dspsnDaemons == null || dspsnDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
} else {
|
||||
for(DspsnDaemonThread demon : dspsnDaemons){
|
||||
if(Thread.State.NEW == demon.getState()){
|
||||
demon.start();
|
||||
} else {
|
||||
demon.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = "시작됨";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int countDaemon(String daemonName) {
|
||||
int i = 0;
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null){
|
||||
return 0;
|
||||
}
|
||||
for(MovingOutDaemonThread daemon : movingOutDaemons){
|
||||
if(daemon.isAlive()){
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
|
||||
} else if(daemonName.equals("ITF_FIS_O_012")){
|
||||
if(ntttnDaemons == null){
|
||||
return 0;
|
||||
}
|
||||
for(NtttnDaemonThread daemon : ntttnDaemons){
|
||||
if(daemon.isAlive()){
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
} else if(daemonName.equals("ITF_CFS_O_013")){
|
||||
if(dspsnDaemons == null){
|
||||
return 0;
|
||||
}
|
||||
for(DspsnDaemonThread daemon : dspsnDaemons){
|
||||
if(daemon.isAlive()){
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String killDaemon(String daemonName) {
|
||||
String result = "";
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null || movingOutDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
return result;
|
||||
}
|
||||
|
||||
if(countDaemon(daemonName) == 0){
|
||||
result = "이미 종료됨";
|
||||
return result;
|
||||
}
|
||||
|
||||
for(MovingOutDaemonThread daemon : movingOutDaemons){
|
||||
daemon.interrupt();
|
||||
}
|
||||
result = "종료 요청 완료";
|
||||
return result;
|
||||
|
||||
} else if(daemonName.equals("ITF_FIS_O_012")){
|
||||
if(ntttnDaemons == null || ntttnDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
return result;
|
||||
}
|
||||
|
||||
if(countDaemon(daemonName) == 0){
|
||||
result = "이미 종료됨";
|
||||
return result;
|
||||
}
|
||||
|
||||
for(NtttnDaemonThread daemon : ntttnDaemons){
|
||||
daemon.interrupt();
|
||||
}
|
||||
result = "종료 요청 완료";
|
||||
return result;
|
||||
} else if(daemonName.equals("ITF_CFS_O_013")){
|
||||
if(dspsnDaemons == null || dspsnDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
return result;
|
||||
}
|
||||
|
||||
if(countDaemon(daemonName) == 0){
|
||||
result = "이미 종료됨";
|
||||
return result;
|
||||
}
|
||||
|
||||
for(DspsnDaemonThread daemon : dspsnDaemons){
|
||||
daemon.interrupt();
|
||||
}
|
||||
result = "종료 요청 완료";
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 지역주민 차량 전출 확인 스레드
|
||||
*/
|
||||
class MovingOutDaemonThread extends Thread {
|
||||
|
||||
private String lastDigit = null;
|
||||
|
||||
public MovingOutDaemonThread(String lastDigit){
|
||||
super("MOVING_OUT"+lastDigit);
|
||||
this.lastDigit = lastDigit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
|
||||
while(true){
|
||||
|
||||
boolean end = localResidentsCarInfo.checkMovingOut_lastDigit(lastDigit);
|
||||
if(end){
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class NtttnDaemonThread extends Thread {
|
||||
|
||||
private String lastDigit = null;
|
||||
|
||||
public NtttnDaemonThread(String lastDigit){
|
||||
super("ITF_FIS_O_012"+lastDigit);
|
||||
this.lastDigit = lastDigit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
|
||||
while(true){
|
||||
|
||||
boolean end = exemptCarInfo.getRdcxptInfoNtttnVhcle(lastDigit);
|
||||
if(end){
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DspsnDaemonThread extends Thread {
|
||||
|
||||
private String lastDigit = null;
|
||||
|
||||
public DspsnDaemonThread(String lastDigit){
|
||||
super("ITF_CFS_O_013"+lastDigit);
|
||||
this.lastDigit = lastDigit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
|
||||
while(true){
|
||||
|
||||
boolean end = exemptCarInfo.getRdcxptInfoDspsnVhcle(lastDigit);
|
||||
if(end){
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue