package com.eactive.eai.rms.onl.common.service;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationContext;

import com.eactive.eai.rms.onl.dashboard.service.Dashboard2RepositoryService;

public class PeakTpsUpdateHourJob implements Job {
    /**
     * Logger for this class
     */
    private static final Logger logger = Logger.getLogger(PeakTpsUpdateHourJob.class);
	
	private Dashboard2RepositoryService dashboard2Repository;

    // 매시간 정각에 PEAK TPS 정보를 Reload 한다. ( db 부하를 줄이기 위해, 정보수집 호스트를 제한하기 때문 )
    //@ScheduleMethod(type = ScheduleType.CRON, cronExpression = "0 0 * * * ?")
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
        //JobKey jobKey = context.getJobDetail().getKey();

		ApplicationContext appContext = null;
		try {
			appContext = (ApplicationContext)context.getScheduler().getContext().get("applicationContext");
		} catch (SchedulerException e) {
			logger.error("applicationContext get module error",e);
			return ;
		}  
		dashboard2Repository = (Dashboard2RepositoryService)appContext.getBean("dashboard2RepositoryService");	
		dashboard2Repository.reloadPeakTpsTrade();
				
	}
    
}
