@VisibleForTesting
  public static String getNsFromDataNodeNetworkLocation(String location) {
    // network location should be in the format of /ns/rack
    Pattern pattern = Pattern.compile("^/([^/]*)/");
    Matcher matcher = pattern.matcher(location);
    if (matcher.find()) {
      return matcher.group(1);
    }
    return "";
  }
@Test
  public void testGetNsFromDataNodeNetworkLocation() {
    assertEquals("ns0", RouterWebHdfsMethods
        .getNsFromDataNodeNetworkLocation("/ns0/rack-info1"));
    assertEquals("ns0", RouterWebHdfsMethods
        .getNsFromDataNodeNetworkLocation("/ns0/row1/rack-info1"));
    assertEquals("", RouterWebHdfsMethods
        .getNsFromDataNodeNetworkLocation("/row0"));
    assertEquals("", RouterWebHdfsMethods
        .getNsFromDataNodeNetworkLocation("whatever-rack-info1"));
  }