-
监控hdfs的一个目录,若有新文件,spark就开始处理这个文件,可以使用spark streaming textfilestream来监控该目录
这个是文件实时传输过程的监控还是文件上传完成之后的监控,需要自己试一下看看。 -
hdfs api调用监控
package com.zx.dao;
import com.zx.utils.PropertiesUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.DFSInotifyEventInputStream;
import org.apache.hadoop.hdfs.client.HdfsAdmin;
import org.apache.hadoop.hdfs.inotify.Event;
import org.apache.hadoop.hdfs.inotify.EventBatch;
import org.apache.hadoop.hdfs.inotify.MissingEventsException;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Properties;
//监控hdfs系统的文件状态
public class MonitorHdfs extends Thread {
private ArrayList<String> fileList = new ArrayList<String>();
public void getFileStatus() throws IOException, InterruptedException, MissingEventsException {
Properties properties = Prope