Search in sources :

Example 16 with NodeValidationException

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");
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) NodeValidationException(org.elasticsearch.node.NodeValidationException)

Example 17 with NodeValidationException

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");
}
Also used : NodeValidationException(org.elasticsearch.node.NodeValidationException) AtomicReference(java.util.concurrent.atomic.AtomicReference) Matchers.hasToString(org.hamcrest.Matchers.hasToString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 18 with NodeValidationException

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");
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NodeValidationException(org.elasticsearch.node.NodeValidationException)

Example 19 with NodeValidationException

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");
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) NodeValidationException(org.elasticsearch.node.NodeValidationException)

Aggregations

NodeValidationException (org.elasticsearch.node.NodeValidationException)19 Matchers.hasToString (org.hamcrest.Matchers.hasToString)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Logger (org.apache.logging.log4j.Logger)2 SecureSettings (org.elasticsearch.common.settings.SecureSettings)2 Settings (org.elasticsearch.common.settings.Settings)2 Node (org.elasticsearch.node.Node)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Appender (org.apache.logging.log4j.core.Appender)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1