当前位置: 首页>>代码示例>>Java>>正文


Java DistributedCache.addFileToClassPath方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.filecache.DistributedCache.addFileToClassPath方法的典型用法代码示例。如果您正苦于以下问题:Java DistributedCache.addFileToClassPath方法的具体用法?Java DistributedCache.addFileToClassPath怎么用?Java DistributedCache.addFileToClassPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.filecache.DistributedCache的用法示例。


在下文中一共展示了DistributedCache.addFileToClassPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runJob

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
static boolean runJob(JobConf conf, Path inDir, Path outDir, int numMaps, 
                         int numReds) throws IOException, InterruptedException {

  FileSystem fs = FileSystem.get(conf);
  if (fs.exists(outDir)) {
    fs.delete(outDir, true);
  }
  if (!fs.exists(inDir)) {
    fs.mkdirs(inDir);
  }
  String input = "The quick brown fox\n" + "has many silly\n"
      + "red fox sox\n";
  for (int i = 0; i < numMaps; ++i) {
    DataOutputStream file = fs.create(new Path(inDir, "part-" + i));
    file.writeBytes(input);
    file.close();
  }

  DistributedCache.addFileToClassPath(TestMRJobs.APP_JAR, conf, fs);
  conf.setOutputCommitter(CustomOutputCommitter.class);
  conf.setInputFormat(TextInputFormat.class);
  conf.setOutputKeyClass(LongWritable.class);
  conf.setOutputValueClass(Text.class);

  FileInputFormat.setInputPaths(conf, inDir);
  FileOutputFormat.setOutputPath(conf, outDir);
  conf.setNumMapTasks(numMaps);
  conf.setNumReduceTasks(numReds);

  JobClient jobClient = new JobClient(conf);
  
  RunningJob job = jobClient.submitJob(conf);
  return jobClient.monitorAndPrintJob(conf, job);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestMROldApiJobs.java

示例2: testCombinerShouldUpdateTheReporter

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
@Test
public void testCombinerShouldUpdateTheReporter() throws Exception {
  JobConf conf = new JobConf(mrCluster.getConfig());
  int numMaps = 5;
  int numReds = 2;
  Path in = new Path(mrCluster.getTestWorkDir().getAbsolutePath(),
      "testCombinerShouldUpdateTheReporter-in");
  Path out = new Path(mrCluster.getTestWorkDir().getAbsolutePath(),
      "testCombinerShouldUpdateTheReporter-out");
  createInputOutPutFolder(in, out, numMaps);
  conf.setJobName("test-job-with-combiner");
  conf.setMapperClass(IdentityMapper.class);
  conf.setCombinerClass(MyCombinerToCheckReporter.class);
  //conf.setJarByClass(MyCombinerToCheckReporter.class);
  conf.setReducerClass(IdentityReducer.class);
  DistributedCache.addFileToClassPath(TestMRJobs.APP_JAR, conf);
  conf.setOutputCommitter(CustomOutputCommitter.class);
  conf.setInputFormat(TextInputFormat.class);
  conf.setOutputKeyClass(LongWritable.class);
  conf.setOutputValueClass(Text.class);

  FileInputFormat.setInputPaths(conf, in);
  FileOutputFormat.setOutputPath(conf, out);
  conf.setNumMapTasks(numMaps);
  conf.setNumReduceTasks(numReds);
  
  runJob(conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestMRAppWithCombiner.java

示例3: copyLog4jPropertyFile

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void copyLog4jPropertyFile(Job job, Path submitJobDir,
    short replication) throws IOException {
  Configuration conf = job.getConfiguration();

  String file =
      validateFilePath(
          conf.get(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE), conf);
  LOG.debug("default FileSystem: " + jtFs.getUri());
  FsPermission mapredSysPerms =
      new FsPermission(JobSubmissionFiles.JOB_DIR_PERMISSION);
  if (!jtFs.exists(submitJobDir)) {
    throw new IOException("Cannot find job submission directory! "
        + "It should just be created, so something wrong here.");
  }

  Path fileDir = JobSubmissionFiles.getJobLog4jFile(submitJobDir);

  // first copy local log4j.properties file to HDFS under submitJobDir
  if (file != null) {
    FileSystem.mkdirs(jtFs, fileDir, mapredSysPerms);
    URI tmpURI = null;
    try {
      tmpURI = new URI(file);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException(e);
    }
    Path tmp = new Path(tmpURI);
    Path newPath = copyRemoteFiles(fileDir, tmp, conf, replication);
    DistributedCache.addFileToClassPath(new Path(newPath.toUri().getPath()),
        conf);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:34,代码来源:JobResourceUploader.java

示例4: copyLog4jPropertyFile

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void copyLog4jPropertyFile(Job job, Path submitJobDir,
    short replication) throws IOException {
  Configuration conf = job.getConfiguration();

  String file = validateFilePath(
      conf.get(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE), conf);
  LOG.debug("default FileSystem: " + jtFs.getUri());
  FsPermission mapredSysPerms = 
    new FsPermission(JobSubmissionFiles.JOB_DIR_PERMISSION);
  if (!jtFs.exists(submitJobDir)) {
    throw new IOException("Cannot find job submission directory! " 
        + "It should just be created, so something wrong here.");
  }
  
  Path fileDir = JobSubmissionFiles.getJobLog4jFile(submitJobDir);

  // first copy local log4j.properties file to HDFS under submitJobDir
  if (file != null) {
    FileSystem.mkdirs(jtFs, fileDir, mapredSysPerms);
    URI tmpURI = null;
    try {
      tmpURI = new URI(file);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException(e);
    }
    Path tmp = new Path(tmpURI);
    Path newPath = copyRemoteFiles(fileDir, tmp, conf, replication);
    DistributedCache.addFileToClassPath(new Path(newPath.toUri().getPath()), conf);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:32,代码来源:JobSubmitter.java

示例5: addCacheFiles

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
public void addCacheFiles( final String filesString , final Configuration conf ) throws IOException{
  for( String file : filesString.split( "," ) ){
    DistributedCache.addFileToClassPath( new Path( file ) , conf );
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:6,代码来源:HCatalogSampleMapReduce.java

示例6: addFileToClassPath

import org.apache.hadoop.mapreduce.filecache.DistributedCache; //导入方法依赖的package包/类
/**
 * Add an file path to the current set of classpath entries It adds the file
 * to cache as well.
 * 
 * Files added with this method will not be unpacked while being added to the
 * classpath.
 * To add archives to classpath, use the {@link #addArchiveToClassPath(Path)}
 * method instead.
 *
 * @param file Path of the file to be added
 */
public void addFileToClassPath(Path file)
  throws IOException {
  ensureState(JobState.DEFINE);
  DistributedCache.addFileToClassPath(file, conf, file.getFileSystem(conf));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:Job.java


注:本文中的org.apache.hadoop.mapreduce.filecache.DistributedCache.addFileToClassPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。