@Test @DisplayName("getHugepageSize()") void getHugepageSize() { assumeTrue(mmanager != null); val pageSize = mmanager.getHugepageSize(); assertThat(pageSize).isPositive().withFailMessage("should be a power of two").isEqualTo(pageSize & -pageSize); }
@Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; }
SmartJniMemoryManager extends JniMemoryManager { @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; } }
SmartJniMemoryManager extends JniMemoryManager { @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; } private  SmartJniMemoryManager(); }
SmartJniMemoryManager extends JniMemoryManager { @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; } private  SmartJniMemoryManager(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE") long virt2phys(final long address); }
SmartJniMemoryManager extends JniMemoryManager { @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; } private  SmartJniMemoryManager(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE") long virt2phys(final long address);  }