public long getOpenFileDescriptorCount() {
    Long ofdc;

    if (!ibmvendor) {
      ofdc = runUnixMXBeanMethod("getOpenFileDescriptorCount");
      return (ofdc != null ? ofdc : -1);
    }
    InputStream inputStream = null;
    InputStreamReader inputStreamReader = null;
    BufferedReader bufferedReader = null;
    try {
      // need to get the PID number of the process first
      RuntimeMXBean rtmbean = ManagementFactory.getRuntimeMXBean();
      String rtname = rtmbean.getName();
      Iterator<String> pidhost = Splitter.on('@').split(rtname).iterator();
      // using linux bash commands to retrieve info
      Process p = Runtime.getRuntime()
        .exec(new String[] { "bash", "-c", "ls /proc/" + pidhost.next() + "/fdinfo | wc -l" });
      inputStream = p.getInputStream();
      inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
      bufferedReader = new BufferedReader(inputStreamReader);
      String openFileDesCount;
      if ((openFileDesCount = bufferedReader.readLine()) != null) {
        return Long.parseLong(openFileDesCount);
      }
    } catch (IOException ie) {
      LOG.warn("Not able to get the number of open file descriptors", ie);
    } finally {
      if (bufferedReader != null) {
        try {
          bufferedReader.close();
        } catch (IOException e) {
          LOG.warn("Not able to close the BufferedReader", e);
        }
      }
      if (inputStreamReader != null) {
        try {
          inputStreamReader.close();
        } catch (IOException e) {
          LOG.warn("Not able to close the InputStreamReader", e);
        }
      }
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
          LOG.warn("Not able to close the InputStream", e);
        }
      }
    }
    return -1;
  }
Get the number of opened filed descriptor for the runtime jvm. If Oracle java, it will use the
com.sun.management interfaces. Otherwise, this methods implements it (linux only).
@return number of open file descriptors for the jvm
hbase-common/src/main/java/org/apache/hadoop/hbase/util/JVM.java