"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java" between
elasticsearch-6.8.14-src.tar.gz and elasticsearch-6.8.15-src.tar.gz

About: elasticsearch is a Distributed, RESTful, Search Engine built on top of Apache Lucene. Source package (GitHub).

OsProbe.java  (elasticsearch-6.8.14-src):OsProbe.java  (elasticsearch-6.8.15-src)
skipping to change at line 49 skipping to change at line 49
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* The {@link OsProbe} class retrieves information about the physical and swap s ize of the machine * The {@link OsProbe} class retrieves information about the physical and swap s ize of the machine
* memory, as well as the system load average and cpu load. * memory, as well as the system load average and cpu load.
* *
* In some exceptional cases, it's possible the underlying native method used by * In some exceptional cases, it's possible the underlying native methods used b
* {@link #getFreePhysicalMemorySize()} and {@link #getTotalPhysicalMemorySize() y
} can return a * {@link #getFreePhysicalMemorySize()}, {@link #getTotalPhysicalMemorySize()},
* {@link #getFreeSwapSpaceSize()}, and {@link #getTotalSwapSpaceSize()} can ret
urn a
* negative value. Because of this, we prevent those methods from returning nega tive values, * negative value. Because of this, we prevent those methods from returning nega tive values,
* returning 0 instead. * returning 0 instead.
* *
* The OS can report a negative number in a number of cases: * The OS can report a negative number in a number of cases:
* - Non-supported OSes (HP-UX, or AIX) * - Non-supported OSes (HP-UX, or AIX)
* - A failure of macOS to initialize host statistics * - A failure of macOS to initialize host statistics
* - An OS that does not support the {@code _SC_PHYS_PAGES} or {@code _SC_PAGE_S IZE} flags for the {@code sysconf()} linux kernel call * - An OS that does not support the {@code _SC_PHYS_PAGES} or {@code _SC_PAGE_S IZE} flags for the {@code sysconf()} linux kernel call
* - An overflow of the product of {@code _SC_PHYS_PAGES} and {@code _SC_PAGE_SI ZE} * - An overflow of the product of {@code _SC_PHYS_PAGES} and {@code _SC_PAGE_SI ZE}
* - An error case retrieving these values from a linux kernel * - An error case retrieving these values from a linux kernel
* - A non-standard libc implementation not implementing the required values * - A non-standard libc implementation not implementing the required values
skipping to change at line 130 skipping to change at line 131
logger.warn("exception retrieving total physical memory", e); logger.warn("exception retrieving total physical memory", e);
return 0; return 0;
} }
} }
/** /**
* Returns the amount of free swap space in bytes. * Returns the amount of free swap space in bytes.
*/ */
public long getFreeSwapSpaceSize() { public long getFreeSwapSpaceSize() {
if (getFreeSwapSpaceSize == null) { if (getFreeSwapSpaceSize == null) {
return -1; logger.warn("getFreeSwapSpaceSize is not available");
return 0;
} }
try { try {
return (long) getFreeSwapSpaceSize.invoke(osMxBean); final long mem = (long) getFreeSwapSpaceSize.invoke(osMxBean);
if (mem < 0) {
logger.warn("OS reported a negative free swap space size [{}]",
mem);
return 0;
}
return mem;
} catch (Exception e) { } catch (Exception e) {
return -1; logger.warn("exception retrieving free swap space size", e);
return 0;
} }
} }
/** /**
* Returns the total amount of swap space in bytes. * Returns the total amount of swap space in bytes.
*/ */
public long getTotalSwapSpaceSize() { public long getTotalSwapSpaceSize() {
if (getTotalSwapSpaceSize == null) { if (getTotalSwapSpaceSize == null) {
return -1; logger.warn("getTotalSwapSpaceSize is not available");
return 0;
} }
try { try {
return (long) getTotalSwapSpaceSize.invoke(osMxBean); final long mem = (long) getTotalSwapSpaceSize.invoke(osMxBean);
if (mem < 0) {
logger.warn("OS reported a negative total swap space size [{}]",
mem);
return 0;
}
return mem;
} catch (Exception e) { } catch (Exception e) {
return -1; logger.warn("exception retrieving total swap space size", e);
return 0;
} }
} }
/** /**
* The system load averages as an array. * The system load averages as an array.
* *
* On Windows, this method returns {@code null}. * On Windows, this method returns {@code null}.
* *
* On Linux, this method returns the 1, 5, and 15-minute load averages. * On Linux, this method returns the 1, 5, and 15-minute load averages.
* *
 End of changes. 7 change blocks. 
9 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)