Source:
<code>public static InetSocketAddress getMasterAddress(TajoConf conf, int type) { InetSocketAddress masterAddress = null; if (conf.getBoolVar(TajoConf.ConfVars.TAJO_MASTER_HA_ENABLE)) { try { FileSystem fs = getFileSystem(conf); Path[] paths = getSystemPath(conf); if (fs.exists(paths[1])) { FileStatus[] files = fs.listStatus(paths[1]); if (files.length == 1) { Path file = files[0].getPath(); String hostAddress = file.getName().replaceAll("_", ":"); FSDataInputStream stream = fs.open(file); String data = stream.readUTF(); stream.close(); String[] addresses = data.split("_"); switch (type) { <START> case 1: <END> masterAddress = NetUtils.createSocketAddr(hostAddress); break; case 2: masterAddress = NetUtils.createSocketAddr(addresses[0]); break; case 3: masterAddress = NetUtils.createSocketAddr(addresses[1]); break; case 4: masterAddress = NetUtils.createSocketAddr(addresses[2]); break; case 5: masterAddress = NetUtils.createSocketAddr(addresses[3]); break; default: break; } } } } catch (Exception e) { e.printStackTrace(); } } if (masterAddress == null) { switch (type) { case 1: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_UMBILICAL_RPC_ADDRESS)); break; case 2: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_CLIENT_RPC_ADDRESS)); break; case 3: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .RESOURCE_TRACKER_RPC_ADDRESS)); break; case 4: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .CATALOG_ADDRESS)); break; case 5: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_INFO_ADDRESS)); break; default: break; } } return masterAddress; }</code><technical_language>great if defined name instead of defined values</technical_language>

Target:
public static InetSocketAddress getMasterAddress(TajoConf conf, int type) { InetSocketAddress masterAddress = null; if (conf.getBoolVar(TajoConf.ConfVars.TAJO_MASTER_HA_ENABLE)) { try { FileSystem fs = getFileSystem(conf); Path activePath = new Path(TajoConf.getSystemHADir(conf), TajoConstants.SYSTEM_HA_ACTIVE_DIR_NAME); if (fs.exists(activePath)) { FileStatus[] files = fs.listStatus(activePath); if (files.length == 1) { Path file = files[0].getPath(); String hostAddress = file.getName().replaceAll("_", ":"); FSDataInputStream stream = fs.open(file); String data = stream.readUTF(); stream.close(); String[] addresses = data.split("_"); switch (type) { case 1: masterAddress = NetUtils.createSocketAddr(hostAddress); break; case 2: masterAddress = NetUtils.createSocketAddr(addresses[0]); break; case 3: masterAddress = NetUtils.createSocketAddr(addresses[1]); break; case 4: masterAddress = NetUtils.createSocketAddr(addresses[2]); break; case 5: masterAddress = NetUtils.createSocketAddr(addresses[3]); break; default: break; } } } } catch (Exception e) { e.printStackTrace(); } } if (masterAddress == null) { switch (type) { case 1: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_UMBILICAL_RPC_ADDRESS)); break; case 2: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_CLIENT_RPC_ADDRESS)); break; case 3: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .RESOURCE_TRACKER_RPC_ADDRESS)); break; case 4: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .CATALOG_ADDRESS)); break; case 5: masterAddress = NetUtils.createSocketAddr(conf.getVar(TajoConf.ConfVars .TAJO_MASTER_INFO_ADDRESS)); break; default: break; } } return masterAddress; }