FileFtpColl.java 1.79 KB
package com.sitech.ismp.coll.busi;

import java.util.HashMap;
import java.util.Vector;

import org.apache.log4j.Logger;

import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.util.DES3;
import com.sitech.util.ThreadPoolUtil;

/**
 * FTP采集配置文件(GX)
 * 本地目录命名规则: ${coll.local.path} + "/" + ip.replace(".","_")/
 * 		例:/bnmsapp2/172_21_1_100/
 * 
 * 1. FTP配置文件到本地目录,文件命名规则为:CFG_$GUID.txt
 * 2. 创建对应的描述文件到本地目录,文件命名规则为:CFG_$GUID.info
 * 
 *******Begin CFG_986C5F24.info***************************************
 * TYPE=FTP
 * IP_ADDR=172.21.1.100
 * DIRECTORY=/bnmsapp2
 * FILE_NAME=AppCenterProxy_error_check.sh
 * PERSSIONS=-rw-r--r--
 * SIZE=1279
 * UPDATE_TIME=2012-10-17 10:02:38
 * USER=bnmsapp2
 * COLL_TIME=2012-11-21 13:18:55
 *******End CFG_986C5F24.info*****************************************
 *
 * @author linxc
 */
public class FileFtpColl implements FileFtpCollMBean {
	private Logger logger = Logger.getLogger(FileFtpColl.class);

	/**
	 * @param params HashMap  KEY:[IP_ADDR, USERNAME, PASSWORD, FILE_$GUID]
	 * @return 
	 */
	public Vector<TblATO_KPIDETAIL> collFile(HashMap<String, String> params) {
		try {
			ThreadPoolUtil.executorService.execute(new FileFtpCollThread(params));
		} catch (Exception e) {
			logger.error("Exception while do FileFtpColl.collFile() ", e);
			return new Vector<TblATO_KPIDETAIL>();
		}
		return new Vector<TblATO_KPIDETAIL>();
	}
	
	public static void main(String[] args) {
		HashMap<String,String> params = new HashMap<String, String>();
		params.put("IP_ADDR", "172.21.1.69");
		params.put("USERNAME", "yfbnms");
		params.put("PASSWORD", DES3.encrypt("yfbnms"));

		Thread thread = new Thread(new FileFtpCollThread(params));
		thread.start();
	}
}