Search in sources :

Example 26 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 27 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 28 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 29 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)

Example 30 with NodeValidationException

use of org.elasticsearch.node.NodeValidationException in project vertexium by visallo.

the class Elasticsearch5SearchIndex method createInProcessNode.

private Client createInProcessNode(ElasticsearchSearchIndexConfiguration config) {
    Settings settings = tryReadSettingsFromFile(config);
    if (settings == null) {
        String homePath = config.getInProcessNodeHomePath();
        checkNotNull(homePath, ElasticsearchSearchIndexConfiguration.IN_PROCESS_NODE_HOME_PATH + " is required for in process Elasticsearch node");
        Map<String, String> mapSettings = new HashMap<>();
        mapSettings.put("transport.type", "local");
        mapSettings.put("path.home", homePath);
        mapSettings.put("http.enabled", "false");
        mapSettings.put("discovery.zen.ping.unicast.hosts", "localhost");
        if (config.getClusterName() != null) {
            mapSettings.put("cluster.name", config.getClusterName());
        }
        mapSettings.putAll(config.getInProcessNodeAdditionalSettings());
        settings = Settings.builder().put(mapSettings).build();
    }
    this.inProcessNode = new Node(settings);
    try {
        inProcessNode.start();
    } catch (NodeValidationException ex) {
        throw new VertexiumException("Could not start in process node", ex);
    }
    Client client = inProcessNode.client();
    long startTime = System.currentTimeMillis();
    while (true) {
        if (System.currentTimeMillis() > startTime + IN_PROCESS_NODE_WAIT_TIME_MS) {
            throw new VertexiumException("Status failed to exit red status after waiting " + IN_PROCESS_NODE_WAIT_TIME_MS + "ms. Giving up.");
        }
        ClusterHealthResponse health = client.admin().cluster().prepareHealth().get();
        if (health.getStatus() != ClusterHealthStatus.RED) {
            break;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new VertexiumException("Could not sleep", e);
        }
        LOGGER.info("Status is %s, waiting...", health.getStatus());
    }
    return client;
}
Also used : NodeValidationException(org.elasticsearch.node.NodeValidationException) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) Node(org.elasticsearch.node.Node) TransportClient(org.elasticsearch.client.transport.TransportClient) Client(org.elasticsearch.client.Client) PreBuiltTransportClient(org.elasticsearch.transport.client.PreBuiltTransportClient) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

NodeValidationException (org.elasticsearch.node.NodeValidationException)33 IOException (java.io.IOException)8 Settings (org.elasticsearch.common.settings.Settings)8 Node (org.elasticsearch.node.Node)8 Matchers.hasToString (org.hamcrest.Matchers.hasToString)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ArrayList (java.util.ArrayList)4 Logger (org.apache.logging.log4j.Logger)4 BeforeClass (org.junit.BeforeClass)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 Path (java.nio.file.Path)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Plugin (org.elasticsearch.plugins.Plugin)3 Netty4Plugin (org.elasticsearch.transport.Netty4Plugin)3 BootstrapException (io.crate.bootstrap.BootstrapException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2 URISyntaxException (java.net.URISyntaxException)2