类org.apache.hadoop.mapred.InvalidInputException源码实例Demo

下面列出了怎么用org.apache.hadoop.mapred.InvalidInputException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pxf   文件: HdfsFileFragmenterTest.java
@Test
public void testFragmenterErrorsWhenPathDoesNotExist() throws Exception {
    expectedException.expect(InvalidInputException.class);
    expectedException.expectMessage("Input path does not exist:");

    String path = this.getClass().getClassLoader().getResource("csv/").getPath();

    RequestContext context = new RequestContext();
    context.setConfig("default");
    context.setUser("test-user");
    context.setProfileScheme("localfile");
    context.setDataSource(path + "non-existent");

    Fragmenter fragmenter = new HdfsFileFragmenter();
    fragmenter.initialize(context);
    fragmenter.getFragments();
}
 
源代码2 项目: hadoop   文件: DistTool.java
/** Sanity check for source */
protected static void checkSource(Configuration conf, List<Path> srcs
    ) throws InvalidInputException {
  List<IOException> ioes = new ArrayList<IOException>();
  for(Path p : srcs) {
    try {
      if (!p.getFileSystem(conf).exists(p)) {
        ioes.add(new FileNotFoundException("Source "+p+" does not exist."));
      }
    }
    catch(IOException e) {ioes.add(e);}
  }
  if (!ioes.isEmpty()) {
    throw new InvalidInputException(ioes);
  }
}
 
源代码3 项目: big-c   文件: DistTool.java
/** Sanity check for source */
protected static void checkSource(Configuration conf, List<Path> srcs
    ) throws InvalidInputException {
  List<IOException> ioes = new ArrayList<IOException>();
  for(Path p : srcs) {
    try {
      if (!p.getFileSystem(conf).exists(p)) {
        ioes.add(new FileNotFoundException("Source "+p+" does not exist."));
      }
    }
    catch(IOException e) {ioes.add(e);}
  }
  if (!ioes.isEmpty()) {
    throw new InvalidInputException(ioes);
  }
}
 
源代码4 项目: RDFS   文件: DistTool.java
/** Sanity check for source */
protected static void checkSource(Configuration conf, List<Path> srcs
    ) throws InvalidInputException {
  List<IOException> ioes = new ArrayList<IOException>();
  for(Path p : srcs) {
    try {
      if (!p.getFileSystem(conf).exists(p)) {
        ioes.add(new FileNotFoundException("Source "+p+" does not exist."));
      }
    }
    catch(IOException e) {ioes.add(e);}
  }
  if (!ioes.isEmpty()) {
    throw new InvalidInputException(ioes);
  }
}
 
源代码5 项目: RDFS   文件: DistCp.java
/** Sanity check for srcPath */
private static void checkSrcPath(Configuration conf, List<Path> srcPaths
    ) throws IOException {
  List<IOException> rslt = new ArrayList<IOException>();
  List<Path> unglobbed = new LinkedList<Path>();
  for (Path p : srcPaths) {
    FileSystem fs = p.getFileSystem(conf);
    FileStatus[] inputs = fs.globStatus(p);

    if(inputs.length > 0) {
      for (FileStatus onePath: inputs) {
        unglobbed.add(onePath.getPath());
      }
    } else {
      rslt.add(new IOException("Input source " + p + " does not exist."));
    }
  }
  if (!rslt.isEmpty()) {
    throw new InvalidInputException(rslt);
  }
  srcPaths.clear();
  srcPaths.addAll(unglobbed);
}
 
源代码6 项目: hadoop-gpu   文件: DistTool.java
/** Sanity check for source */
protected static void checkSource(Configuration conf, List<Path> srcs
    ) throws InvalidInputException {
  List<IOException> ioes = new ArrayList<IOException>();
  for(Path p : srcs) {
    try {
      if (!p.getFileSystem(conf).exists(p)) {
        ioes.add(new FileNotFoundException("Source "+p+" does not exist."));
      }
    }
    catch(IOException e) {ioes.add(e);}
  }
  if (!ioes.isEmpty()) {
    throw new InvalidInputException(ioes);
  }
}
 
源代码7 项目: pxf   文件: HdfsFileFragmenter.java
/**
 * Gets the fragments for a data source URI that can appear as a file name,
 * a directory name or a wildcard. Returns the data fragments in JSON
 * format.
 */
@Override
public List<Fragment> getFragments() throws Exception {
    String fileName = hcfsType.getDataUri(jobConf, context);
    Path path = new Path(fileName);

    PxfInputFormat pxfInputFormat = new PxfInputFormat();
    PxfInputFormat.setInputPaths(jobConf, path);

    FileStatus[] fileStatusArray;

    try {
        fileStatusArray = pxfInputFormat.listStatus(jobConf);
    } catch (InvalidInputException e) {
        if (StringUtils.equalsIgnoreCase("true", context.getOption(IGNORE_MISSING_PATH_OPTION))) {
            LOG.debug("Ignoring InvalidInputException", e);
            return fragments;
        }
        throw e;
    }

    fragments = Arrays.stream(fileStatusArray)
            .map(fileStatus -> new Fragment(fileStatus.getPath().toUri().toString()))
            .collect(Collectors.toList());
    LOG.debug("Total number of fragments = {}", fragments.size());

    return fragments;
}
 
源代码8 项目: pxf   文件: HdfsDataFragmenter.java
/**
 * Gets the fragments for a data source URI that can appear as a file name,
 * a directory name or a wildcard. Returns the data fragments in JSON
 * format.
 */
@Override
public List<Fragment> getFragments() throws Exception {
    Path path = new Path(hcfsType.getDataUri(jobConf, context));
    List<InputSplit> splits;
    try {
        splits = getSplits(path);
    } catch (InvalidInputException e) {
        if (StringUtils.equalsIgnoreCase("true", context.getOption(IGNORE_MISSING_PATH_OPTION))) {
            LOG.debug("Ignoring InvalidInputException", e);
            return fragments;
        }
        throw e;
    }

    LOG.debug("Total number of fragments = {}", splits.size());
    for (InputSplit split : splits) {
        FileSplit fsp = (FileSplit) split;
        String filepath = fsp.getPath().toString();
        String[] hosts = fsp.getLocations();

        /*
         * metadata information includes: file split's start, length and
         * hosts (locations).
         */
        byte[] fragmentMetadata = HdfsUtilities.prepareFragmentMetadata(fsp);
        Fragment fragment = new Fragment(filepath, hosts, fragmentMetadata);
        fragments.add(fragment);
    }

    return fragments;
}
 
源代码9 项目: pxf   文件: HdfsDataFragmenterTest.java
@Test
public void testInvalidInputPath() throws Exception {
    thrown.expect(InvalidInputException.class);
    thrown.expectMessage("Input Pattern file:/tmp/non-existent-path-on-disk/*.csv matches 0 files");

    RequestContext context = new RequestContext();
    context.setConfig("default");
    context.setUser("test-user");
    context.setProfileScheme("localfile");
    context.setDataSource("/tmp/non-existent-path-on-disk/*.csv");

    Fragmenter fragmenter = new HdfsDataFragmenter();
    fragmenter.initialize(context);
    fragmenter.getFragments();
}
 
源代码10 项目: pxf   文件: HdfsFileFragmenterTest.java
@Test
public void testInvalidInputPath() throws Exception {
    expectedException.expect(InvalidInputException.class);
    expectedException.expectMessage("Input Pattern file:/tmp/non-existent-path-on-disk/*.csv matches 0 files");

    RequestContext context = new RequestContext();
    context.setConfig("default");
    context.setUser("test-user");
    context.setProfileScheme("localfile");
    context.setDataSource("/tmp/non-existent-path-on-disk/*.csv");

    Fragmenter fragmenter = new HdfsFileFragmenter();
    fragmenter.initialize(context);
    fragmenter.getFragments();
}
 
源代码11 项目: hadoop   文件: DistCh.java
private static void check(Configuration conf, List<FileOperation> ops
    ) throws InvalidInputException {
  List<Path> srcs = new ArrayList<Path>();
  for(FileOperation op : ops) {
    srcs.add(op.src);
  }
  DistTool.checkSource(conf, srcs);
}
 
源代码12 项目: hadoop   文件: DistCpV1.java
/** Sanity check for srcPath */
private static void checkSrcPath(JobConf jobConf, List<Path> srcPaths) 
throws IOException {
  List<IOException> rslt = new ArrayList<IOException>();
  List<Path> unglobbed = new LinkedList<Path>();
  
  Path[] ps = new Path[srcPaths.size()];
  ps = srcPaths.toArray(ps);
  TokenCache.obtainTokensForNamenodes(jobConf.getCredentials(), ps, jobConf);
  
  
  for (Path p : srcPaths) {
    FileSystem fs = p.getFileSystem(jobConf);
    FileStatus[] inputs = fs.globStatus(p);
    
    if(inputs != null && inputs.length > 0) {
      for (FileStatus onePath: inputs) {
        unglobbed.add(onePath.getPath());
      }
    } else {
      rslt.add(new IOException("Input source " + p + " does not exist."));
    }
  }
  if (!rslt.isEmpty()) {
    throw new InvalidInputException(rslt);
  }
  srcPaths.clear();
  srcPaths.addAll(unglobbed);
}
 
源代码13 项目: big-c   文件: DistCh.java
private static void check(Configuration conf, List<FileOperation> ops
    ) throws InvalidInputException {
  List<Path> srcs = new ArrayList<Path>();
  for(FileOperation op : ops) {
    srcs.add(op.src);
  }
  DistTool.checkSource(conf, srcs);
}
 
源代码14 项目: big-c   文件: DistCpV1.java
/** Sanity check for srcPath */
private static void checkSrcPath(JobConf jobConf, List<Path> srcPaths) 
throws IOException {
  List<IOException> rslt = new ArrayList<IOException>();
  List<Path> unglobbed = new LinkedList<Path>();
  
  Path[] ps = new Path[srcPaths.size()];
  ps = srcPaths.toArray(ps);
  TokenCache.obtainTokensForNamenodes(jobConf.getCredentials(), ps, jobConf);
  
  
  for (Path p : srcPaths) {
    FileSystem fs = p.getFileSystem(jobConf);
    FileStatus[] inputs = fs.globStatus(p);
    
    if(inputs != null && inputs.length > 0) {
      for (FileStatus onePath: inputs) {
        unglobbed.add(onePath.getPath());
      }
    } else {
      rslt.add(new IOException("Input source " + p + " does not exist."));
    }
  }
  if (!rslt.isEmpty()) {
    throw new InvalidInputException(rslt);
  }
  srcPaths.clear();
  srcPaths.addAll(unglobbed);
}
 
源代码15 项目: RDFS   文件: DistCh.java
private static void check(Configuration conf, List<FileOperation> ops
    ) throws InvalidInputException {
  List<Path> srcs = new ArrayList<Path>();
  for(FileOperation op : ops) {
    srcs.add(op.src);
  }
  DistTool.checkSource(conf, srcs);
}
 
源代码16 项目: hadoop-gpu   文件: DistCh.java
private static void check(Configuration conf, List<FileOperation> ops
    ) throws InvalidInputException {
  List<Path> srcs = new ArrayList<Path>();
  for(FileOperation op : ops) {
    srcs.add(op.src);
  }
  DistTool.checkSource(conf, srcs);
}
 
源代码17 项目: hadoop-gpu   文件: DistCp.java
/** Sanity check for srcPath */
private static void checkSrcPath(Configuration conf, List<Path> srcPaths
    ) throws IOException {
  List<IOException> rslt = new ArrayList<IOException>();
  for (Path p : srcPaths) {
    FileSystem fs = p.getFileSystem(conf);
    if (!fs.exists(p)) {
      rslt.add(new IOException("Input source " + p + " does not exist."));
    }
  }
  if (!rslt.isEmpty()) {
    throw new InvalidInputException(rslt);
  }
}
 
 类所在包
 类方法
 同包方法