hadoop日志分析系统二 第一部分 利用任务调度系统定期的把web系统所产生的日志文件导入到hdfs中

利用Quartz任务调度框架定期将网站产生的日志数据文件通过hadoophdfsapi加入到集群的hdfs

具体实现:

通过配置文件设置调度模式,通过调度框架的api调用hdfsapi实现定期往hdfs中添加文件

 

publicclass QuartzJob {

   publicvoid work() {

      readFile();

   }

}

 

public  void readFile() throws Exception{

      Configuration configuration = new Configuration();

      URI uri = new URI("hdfs://hadoop240:9000/");

FileSystem fs =FileSystem.get(uri, configuration);

      FSDataOutputStream out = fs.create(new Path("/hdfs文件地址"));

FileInputStream in = new FileInputStream("/目标文件地址");   IOUtils.copyBytes(in, out, 1024, true);

   }

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值