package com.nms.server.thread.deleteFiles;

import java.util.concurrent.Future;

import org.apache.log4j.Logger;

import com.nms.server.common.Common;
import com.nms.server.common.Constants;
import com.nms.server.util.ExceptionPrintUtils;

//监测数据主动收集管理线程
public class DeleteFilesManagerThread implements Runnable{
	private Logger logger = Logger.getLogger(DeleteFilesManagerThread.class);
	
	public void run() {
		try {
//			Thread.currentThread().setName("定时删除文件(log、error->detect、download)管理线程");			
			Thread.currentThread().setName("Regularly Delete Files (log, error->detect, download) Management Thread");			

			Future<?> future = Common.getFutureMap().get(Constants.DELETE_TMP_FILES);
			if(future != null && !future.isCancelled() && !future.isDone()){	//运行中
				logger.info("定时删除文件(log、error->detect、download)执行线程 运行中 不再启动新删除线程");
				return;
			}
			
			future = Common.service.submit(new DeleteFilesThread());
			//注册
			Common.getFutureMap().put(Constants.DELETE_TMP_FILES, future);

		} catch (Exception e) {
			logger.error(ExceptionPrintUtils.printExceptionStack(e));
		} 
	}
	
	public static void main(String[] args) {
		
	}
}
