public static int getPortFromHostPortString(String addr)
      throws IllegalArgumentException {
    String[] hostport = addr.split(":");
    if (hostport.length != 2) {
      String errorMsg = "Address should be <host>:<port>, but it is " + addr;
      throw new IllegalArgumentException(errorMsg);
    }
    return Integer.parseInt(hostport[1]);
  }
@Test
  public void testGetPortFromHostPortString() throws Exception {

    assertEquals(1002, NetUtils.getPortFromHostPortString("testHost:1002"));

    LambdaTestUtils.intercept(IllegalArgumentException.class,
        () ->  NetUtils.getPortFromHostPortString("testHost"));

    LambdaTestUtils.intercept(IllegalArgumentException.class,
        () ->  NetUtils.getPortFromHostPortString("testHost:randomString"));
  }