Skip to content

Commit

Permalink
move parseInetSocketAddress from CommonUtils to NetworkUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
cc committed Jul 17, 2015
1 parent dd2a5a9 commit fe7e38e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/tachyon/master/MasterClient.java
Expand Up @@ -289,7 +289,7 @@ private synchronized InetSocketAddress getMasterAddress() {
mTachyonConf.get(Constants.ZOOKEEPER_LEADER_PATH, null)); mTachyonConf.get(Constants.ZOOKEEPER_LEADER_PATH, null));
try { try {
String temp = leaderInquireClient.getMasterAddress(); String temp = leaderInquireClient.getMasterAddress();
return CommonUtils.parseInetSocketAddress(temp); return NetworkUtils.parseInetSocketAddress(temp);
} catch (IOException e) { } catch (IOException e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
throw Throwables.propagate(e); throw Throwables.propagate(e);
Expand Down
18 changes: 0 additions & 18 deletions common/src/main/java/tachyon/util/CommonUtils.java
Expand Up @@ -328,24 +328,6 @@ public static String parametersToString(Object... objs) {
return sb.toString(); return sb.toString();
} }


/**
* Parse InetSocketAddress from a String
*
* @param address
* @return InetSocketAddress of the String
* @throws IOException
*/
public static InetSocketAddress parseInetSocketAddress(String address) throws IOException {
if (address == null) {
return null;
}
String[] strArr = address.split(":");
if (strArr.length != 2) {
throw new IOException("Invalid InetSocketAddress " + address);
}
return new InetSocketAddress(strArr[0], Integer.parseInt(strArr[1]));
}

/** /**
* Parse a String size to Bytes. * Parse a String size to Bytes.
* *
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/java/tachyon/util/NetworkUtils.java
Expand Up @@ -260,4 +260,22 @@ public static InetSocketAddress getLocalWorkerAddress(TachyonConf conf) {
int workerPort = conf.getInt(Constants.WORKER_PORT, Constants.DEFAULT_WORKER_PORT); int workerPort = conf.getInt(Constants.WORKER_PORT, Constants.DEFAULT_WORKER_PORT);
return new InetSocketAddress(workerHostname, workerPort); return new InetSocketAddress(workerHostname, workerPort);
} }

/**
* Parse InetSocketAddress from a String
*
* @param address
* @return InetSocketAddress of the String
* @throws IOException
*/
public static InetSocketAddress parseInetSocketAddress(String address) throws IOException {
if (address == null) {
return null;
}
String[] strArr = address.split(":");
if (strArr.length != 2) {
throw new IOException("Invalid InetSocketAddress " + address);
}
return new InetSocketAddress(strArr[0], Integer.parseInt(strArr[1]));
}
} }

0 comments on commit fe7e38e

Please sign in to comment.