LogCollManager.java 1.07 KB
package com.sitech.ismp.coll.busi.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.sitech.ismp.coll.busi.LogCollThread;

/**
 * ClassName:LogCollManager
 * Description: 对日志采集线程进行管理
 *
 * @author   Linxc
 * @version  
 * @since    Ver 1.1
 * @Date	 2012	Feb 23, 2012		10:33:39 AM
 */
public class LogCollManager {
	private static Logger logger = Logger.getLogger("BUSI_COLL");
	
	private static Map<String,LogCollThread> threadPool = new HashMap<String, LogCollThread>();
	
	public static void add(String id,LogCollThread thread){
		threadPool.put(id, thread);
		thread.start();
		logger.info("Add new LogCollThread: " + id);
	}
	
	public static void remove(String id) {
		LogCollThread thread = threadPool.get(id);
		if (thread == null) {
			return;
		}
		if (thread.isRunFlag()) {
			thread.setRunFlag(false);
			logger.info("Stop LogCollThread: " + id);
		}
		threadPool.remove(id);
		logger.info("Remove LogCollThread: " + id);
	}
	
	public static boolean contains(String id) {
		return threadPool.containsKey(id);
	}
	
}