如何访问hadoop分布式缓存中的drl文件?

nhaq1z21  于 2021-05-30  发布在  Hadoop
关注(0)|答案(0)|浏览(261)

我在Eclipse3.8中做了一个drools程序
我有两个口水档案。
我想把我的drools文件分享给所有的Map器和还原器。那么如何使用hadoop分布式缓存呢?在此之前,文件应该存在于本地文件系统或hdfs中。
这是一个如何在没有分布式缓存的情况下访问drools文件的程序。看看它,让我清楚地了解如何将drools存储到分布式缓存中,以及如何在程序中访问这些文件。

public class JUnitTests {

@Test
public void testMapReduceJob1() throws Exception {
    String drlDir = "/Users/mbp_user/devel/java/drools-hadoop/drl/";
    String hdfsOut = "output";
    FileSystem fs = FileSystem.get(new Configuration());
    fs.delete(new Path(hdfsOut), true);

    MapReduceByStateless.main(new String[] {
            "-files",
            drlDir + "rule1.drl",
            "input",
            "output"
            }
    );
}

@Test
public void testMapReduceJob2() throws Exception {
    String drlDir = "/Users/mbp_user/devel/java/drools-hadoop/drl/";
    String hdfsOut = "output";
    FileSystem fs = FileSystem.get(new Configuration());
    fs.delete(new Path(hdfsOut), true);

    MapReduceByStateful.main(new String[] {
            "-files",
            drlDir + "rule2.drl",
            "input",
            "output"
            }
    );
}
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题