use of org.elasticsearch.node.NodeValidationException in project elasticsearch by elastic.
the class BootstrapChecksTests method testFileDescriptorLimits.
public void testFileDescriptorLimits() throws NodeValidationException {
// simulates OS X versus non-OS X
final boolean osX = randomBoolean();
final int limit = osX ? 10240 : 1 << 16;
final AtomicLong maxFileDescriptorCount = new AtomicLong(randomIntBetween(1, limit - 1));
final BootstrapChecks.FileDescriptorCheck check;
if (osX) {
check = new BootstrapChecks.OsXFileDescriptorCheck() {
@Override
long getMaxFileDescriptorCount() {
return maxFileDescriptorCount.get();
}
};
} else {
check = new BootstrapChecks.FileDescriptorCheck() {
@Override
long getMaxFileDescriptorCount() {
return maxFileDescriptorCount.get();
}
};
}
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(true, Collections.singletonList(check), "testFileDescriptorLimits"));
assertThat(e.getMessage(), containsString("max file descriptors"));
maxFileDescriptorCount.set(randomIntBetween(limit + 1, Integer.MAX_VALUE));
BootstrapChecks.check(true, Collections.singletonList(check), "testFileDescriptorLimits");
// nothing should happen if current file descriptor count is
// not available
maxFileDescriptorCount.set(-1);
BootstrapChecks.check(true, Collections.singletonList(check), "testFileDescriptorLimits");
}
use of org.elasticsearch.node.NodeValidationException in project elasticsearch by elastic.
the class BootstrapChecksTests method testClientJvmCheck.
public void testClientJvmCheck() throws NodeValidationException {
final AtomicReference<String> vmName = new AtomicReference<>("Java HotSpot(TM) 32-Bit Client VM");
final BootstrapCheck check = new BootstrapChecks.ClientJvmCheck() {
@Override
String getVmName() {
return vmName.get();
}
};
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(true, Collections.singletonList(check), "testClientJvmCheck"));
assertThat(e.getMessage(), containsString("JVM is using the client VM [Java HotSpot(TM) 32-Bit Client VM] " + "but should be using a server VM for the best performance"));
vmName.set("Java HotSpot(TM) 32-Bit Server VM");
BootstrapChecks.check(true, Collections.singletonList(check), "testClientJvmCheck");
}
use of org.elasticsearch.node.NodeValidationException in project elasticsearch by elastic.
the class BootstrapChecksTests method testSystemCallFilterCheck.
public void testSystemCallFilterCheck() throws NodeValidationException {
final AtomicBoolean isSystemCallFilterInstalled = new AtomicBoolean();
final BootstrapChecks.SystemCallFilterCheck systemCallFilterEnabledCheck = new BootstrapChecks.SystemCallFilterCheck(true) {
@Override
boolean isSystemCallFilterInstalled() {
return isSystemCallFilterInstalled.get();
}
};
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(true, Collections.singletonList(systemCallFilterEnabledCheck), "testSystemCallFilterCheck"));
assertThat(e.getMessage(), containsString("system call filters failed to install; " + "check the logs and fix your configuration or disable system call filters at your own risk"));
isSystemCallFilterInstalled.set(true);
BootstrapChecks.check(true, Collections.singletonList(systemCallFilterEnabledCheck), "testSystemCallFilterCheck");
final BootstrapChecks.SystemCallFilterCheck systemCallFilterNotEnabledCheck = new BootstrapChecks.SystemCallFilterCheck(false) {
@Override
boolean isSystemCallFilterInstalled() {
return isSystemCallFilterInstalled.get();
}
};
isSystemCallFilterInstalled.set(false);
BootstrapChecks.check(true, Collections.singletonList(systemCallFilterNotEnabledCheck), "testSystemCallFilterCheck");
isSystemCallFilterInstalled.set(true);
BootstrapChecks.check(true, Collections.singletonList(systemCallFilterNotEnabledCheck), "testSystemCallFilterCheck");
}
use of org.elasticsearch.node.NodeValidationException in project elasticsearch by elastic.
the class BootstrapChecksTests method testMaxSizeVirtualMemory.
public void testMaxSizeVirtualMemory() throws NodeValidationException {
final long rlimInfinity = Constants.MAC_OS_X ? 9223372036854775807L : -1L;
final AtomicLong maxSizeVirtualMemory = new AtomicLong(randomIntBetween(0, Integer.MAX_VALUE));
final BootstrapChecks.MaxSizeVirtualMemoryCheck check = new BootstrapChecks.MaxSizeVirtualMemoryCheck() {
@Override
long getMaxSizeVirtualMemory() {
return maxSizeVirtualMemory.get();
}
@Override
long getRlimInfinity() {
return rlimInfinity;
}
};
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(true, Collections.singletonList(check), "testMaxSizeVirtualMemory"));
assertThat(e.getMessage(), containsString("max size virtual memory"));
maxSizeVirtualMemory.set(rlimInfinity);
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxSizeVirtualMemory");
// nothing should happen if max size virtual memory is not
// available
maxSizeVirtualMemory.set(Long.MIN_VALUE);
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxSizeVirtualMemory");
}
Aggregations