如何在win7下的eclipse中调试Hadoop2.2.0的程序

2024-12-26 09:10:47
推荐回答(2个)
回答1:

 如何eclipse中调试hadoop2.2.0,如果你使用的还是hadoop1.x的版本,那么,也没事,散仙在以前的博客里,也写过eclipse调试1.x的hadoop程序,两者最大的不同之处在于使用的eclipse插件不同,hadoop2.x与hadoop1.x的API,不太一致,所以插件也不一样,我们只需要使用分别对应的插件即可.
  方法如下:

  进入wordpress后台,Jetpack,点分享的配置,选择 Add a new service,
  server name 一定要写英文不能写中文,不然就崩溃了,如douban,
  private static String checkHadoopHome() {

  // first check the Dflag hadoop.home.dir with JVM scope
  //System.setProperty("hadoop.home.dir", "...");
  String home = System.getProperty("hadoop.home.dir");

  // fall back to the system/user-global env variable
  if (home == null) {
  home = System.getenv("HADOOP_HOME");
  }

  try {
  // couldn't find either setting for hadoop's home directory
  if (home == null) {
  throw new IOException("HADOOP_HOME or hadoop.home.dir are not set.");
  }

  if (home.startsWith("\"") && home.endsWith("\"")) {
  home = home.substring(1, home.length()-1);
  }

  // check that the home setting is actually a directory that exists
  File homedir = new File(home);
  if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) {
  throw new IOException("Hadoop home directory " + homedir
  + " does not exist, is not a directory, or is not an absolute path.");
  }

  home = homedir.getCanonicalPath();

  } catch (IOException ioe) {
  if (LOG.isDebugEnabled()) {
  LOG.debug("Failed to detect a valid hadoop home directory", ioe);
  }
  home = null;
  }
  //固定本机的hadoop地址
  home="D:\\hadoop-2.2.0";
  return home;
  }

回答2:

private static String checkHadoopHome() {

// first check the Dflag hadoop.home.dir with JVM scope
//System.setProperty("hadoop.home.dir", "...");
String home = System.getProperty("hadoop.home.dir");

// fall back to the system/user-global env variable
if (home == null) {
home = System.getenv("HADOOP_HOME");
}

try {
// couldn't find either setting for hadoop's home directory
if (home == null) {
throw new IOException("HADOOP_HOME or hadoop.home.dir are not set.");
}

if (home.startsWith("\"") && home.endsWith("\"")) {
home = home.substring(1, home.length()-1);
}

// check that the home setting is actually a directory that exists
File homedir = new File(home);
if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) {
throw new IOException("Hadoop home directory " + homedir
+ " does not exist, is not a directory, or is not an absolute path.");
}

home = homedir.getCanonicalPath();

} catch (IOException ioe) {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed to detect a valid hadoop home directory", ioe);
}
home = null;
}
//固定本机的hadoop地址
home="D:\\hadoop-2.2.0";
return home;
}。