コード例 #1
0
  private static int[] parseJobSetup(Path jobFile) {
    int[] result = new int[2];
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(jobFile.toString());
      Element configElement = doc.getDocumentElement();
      NodeList nodes = configElement.getElementsByTagName("property");
      if (nodes != null && nodes.getLength() > 0) {
        for (int i = 0; i < nodes.getLength(); i++) {
          Element property = (Element) nodes.item(i);
          String elName = xmlGetSingleValue(property, "name");
          if (elName == "example.count") {
            result[0] = Integer.parseInt(xmlGetSingleValue(property, "value"));
          } else if (elName == "batch.size") {
            result[1] = Integer.parseInt(xmlGetSingleValue(property, "value"));
          }
        }
      }

    } catch (ParserConfigurationException pce) {
      System.err.println(
          "Caught exception while parsing the cached file '"
              + jobFile
              + "' : "
              + StringUtils.stringifyException(pce));
      return null;
    } catch (SAXException se) {
      System.err.println(
          "Caught exception while parsing the cached file '"
              + jobFile
              + "' : "
              + StringUtils.stringifyException(se));
      return null;
    } catch (IOException ioe) {
      System.err.println(
          "Caught exception while parsing the cached file '"
              + jobFile
              + "' : "
              + StringUtils.stringifyException(ioe));
      return null;
    }
    return result;
  }
コード例 #2
0
ファイル: Injector.java プロジェクト: soolr/nutch-1.7
 public int run(String[] args) throws Exception {
   if (args.length < 2) {
     System.err.println("Usage: Injector <crawldb> <url_dir>");
     return -1;
   }
   try {
     inject(new Path(args[0]), new Path(args[1]));
     return 0;
   } catch (Exception e) {
     LOG.error("Injector: " + StringUtils.stringifyException(e));
     return -1;
   }
 }
コード例 #3
0
 public void configure(Configuration conf) {
   if (conf.getBoolean("minibatch.job.setup", false)) {
     Path[] jobSetupFiles = new Path[0];
     try {
       jobSetupFiles = DistributedCache.getLocalCacheFiles(conf);
     } catch (IOException ioe) {
       System.err.println(
           "Caught exception while getting cached files: "
               + StringUtils.stringifyException(ioe));
     }
     for (Path jobSetup : jobSetupFiles) {
       parseJobSetup(jobSetup);
     }
   }
 }