當前位置: 首頁>>代碼示例>>Java>>正文


Java JobClient.close方法代碼示例

本文整理匯總了Java中org.apache.hadoop.mapred.JobClient.close方法的典型用法代碼示例。如果您正苦於以下問題:Java JobClient.close方法的具體用法?Java JobClient.close怎麽用?Java JobClient.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.mapred.JobClient的用法示例。


在下文中一共展示了JobClient.close方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runJob

import org.apache.hadoop.mapred.JobClient; //導入方法依賴的package包/類
/**
 * Submit/run a map/reduce job.
 * 
 * @param job
 * @return true for success
 * @throws IOException
 */
public static boolean runJob(JobConf job) throws IOException {
  JobClient jc = new JobClient(job);
  boolean sucess = true;
  RunningJob running = null;
  try {
    running = jc.submitJob(job);
    JobID jobId = running.getID();
    System.out.println("Job " + jobId + " is submitted");
    while (!running.isComplete()) {
      System.out.println("Job " + jobId + " is still running.");
      try {
        Thread.sleep(60000);
      } catch (InterruptedException e) {
      }
      running = jc.getJob(jobId);
    }
    sucess = running.isSuccessful();
  } finally {
    if (!sucess && (running != null)) {
      running.killJob();
    }
    jc.close();
  }
  return sucess;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:33,代碼來源:DataJoinJob.java

示例2: closeClient

import org.apache.hadoop.mapred.JobClient; //導入方法依賴的package包/類
private void closeClient(JobClient client) {
  try {
    if (client != null)
      client.close();
  } catch (Exception ignored) {
    // nothing we can do
    ignored.printStackTrace();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:TestMRCJCSocketFactory.java

示例3: submitAndMonitorJob

import org.apache.hadoop.mapred.JobClient; //導入方法依賴的package包/類
public int submitAndMonitorJob() throws IOException {

    if (jar_ != null && isLocalHadoop()) {
      // getAbs became required when shell and subvm have different working dirs...
      File wd = new File(".").getAbsoluteFile();
      RunJar.unJar(new File(jar_), wd);
    }

    // if jobConf_ changes must recreate a JobClient
    jc_ = new JobClient(jobConf_);
    running_ = null;
    try {
      running_ = jc_.submitJob(jobConf_);
      jobId_ = running_.getID();
      if (background_) {
        LOG.info("Job is running in background.");
      } else if (!jc_.monitorAndPrintJob(jobConf_, running_)) {
        LOG.error("Job not successful!");
        return 1;
      }
      LOG.info("Output directory: " + output_);
    } catch(FileNotFoundException fe) {
      LOG.error("Error launching job , bad input path : " + fe.getMessage());
      return 2;
    } catch(InvalidJobConfException je) {
      LOG.error("Error launching job , Invalid job conf : " + je.getMessage());
      return 3;
    } catch(FileAlreadyExistsException fae) {
      LOG.error("Error launching job , Output path already exists : "
                + fae.getMessage());
      return 4;
    } catch(IOException ioe) {
      LOG.error("Error Launching job : " + ioe.getMessage());
      return 5;
    } catch (InterruptedException ie) {
      LOG.error("Error monitoring job : " + ie.getMessage());
      return 6;
    } finally {
      jc_.close();
    }
    return 0;
  }
 
開發者ID:naver,項目名稱:hadoop,代碼行數:43,代碼來源:StreamJob.java


注:本文中的org.apache.hadoop.mapred.JobClient.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。