我是Hadoop的新手,所以我有些怀疑在下一个案例中该怎么做。 我有一个算法,包括多个不同的作业运行,有时多个运行一个作业(在一个循环中)。Java代码或Oozie
我应该如何实现这一点,使用Oozie或使用Java代码?我一直在寻找通过Mahout的代码和ClusterIterator功能功能发现这一点:
public static void iterateMR(Configuration conf, Path inPath, Path priorPath, Path outPath, int numIterations)
throws IOException, InterruptedException, ClassNotFoundException {
ClusteringPolicy policy = ClusterClassifier.readPolicy(priorPath);
Path clustersOut = null;
int iteration = 1;
while (iteration <= numIterations) {
conf.set(PRIOR_PATH_KEY, priorPath.toString());
String jobName = "Cluster Iterator running iteration " + iteration + " over priorPath: " + priorPath;
Job job = new Job(conf, jobName);
job.setMapOutputKeyClass(IntWritable.class);
job.setMapOutputValueClass(ClusterWritable.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(ClusterWritable.class);
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setMapperClass(CIMapper.class);
job.setReducerClass(CIReducer.class);
FileInputFormat.addInputPath(job, inPath);
clustersOut = new Path(outPath, Cluster.CLUSTERS_DIR + iteration);
priorPath = clustersOut;
FileOutputFormat.setOutputPath(job, clustersOut);
job.setJarByClass(ClusterIterator.class);
if (!job.waitForCompletion(true)) {
throw new InterruptedException("Cluster Iteration " + iteration + " failed processing " + priorPath);
}
ClusterClassifier.writePolicy(policy, clustersOut);
FileSystem fs = FileSystem.get(outPath.toUri(), conf);
iteration++;
if (isConverged(clustersOut, conf, fs)) {
break;
}
}
Path finalClustersIn = new Path(outPath, Cluster.CLUSTERS_DIR + (iteration - 1) + Cluster.FINAL_ITERATION_SUFFIX);
FileSystem.get(clustersOut.toUri(), conf).rename(clustersOut, finalClustersIn);
}
所以,他们有它们运行MR工作循环。这是一个好方法吗?我知道Oozie用于DAG,可以与其他组件一起使用,例如Pig,但是我应该考虑将它用于这样的事情吗?
如果我想多次运行聚类算法,比如说对于聚类(使用特定的驱动程序),我应该在循环中还是使用Oozie来做这件事。
感谢
好的,谢谢你的回答,我会接受的,你能告诉我你喜欢我的情况吗?在我看来,我应该使用前两种方法之一在循环中调用Mahout集群,并认为这是一项工作,并且如果我需要其他组件,比如我需要使用Oozie,则需要使用其他组件。我在使用Hadoop方面缺乏经验,因此我以这种方式形成了我的问题。 – Marko 2014-11-06 14:51:10
既然你需要运行Map reduce和Mahout,我建议使用Oozie。您还可以运行本机shell命令来获取数据。 – 2014-11-07 05:00:21
感谢您的回答,还有一件事,我怎么能实现在循环中调用Mahout,因为它通常用于DAG? – Marko 2014-11-07 09:32:46