Example usage for org.apache.lucene.util Constants JRE_IS_MINIMUM_JAVA8

List of usage examples for org.apache.lucene.util Constants JRE_IS_MINIMUM_JAVA8

Introduction

In this page you can find the example usage for org.apache.lucene.util Constants JRE_IS_MINIMUM_JAVA8.

Prototype

boolean JRE_IS_MINIMUM_JAVA8

To view the source code for org.apache.lucene.util Constants JRE_IS_MINIMUM_JAVA8.

Click Source Link

Usage

From source file:com.floragunn.searchguard.ssl.SSLTest.java

License:Apache License

@Test
public void testCipherAndProtocols() throws Exception {

    Security.setProperty("jdk.tls.disabledAlgorithms", "");
    System.out.println("Disabled algos: " + Security.getProperty("jdk.tls.disabledAlgorithms"));
    System.out.println("allowOpenSSL: " + allowOpenSSL);

    Settings settings = Settings.settingsBuilder().put("searchguard.ssl.transport.enabled", false)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_KEYSTORE_ALIAS, "node-0")
            .put("searchguard.ssl.http.enabled", true)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
            .put("searchguard.ssl.http.clientauth_mode", "REQUIRE")
            .put("searchguard.ssl.http.keystore_filepath",
                    getAbsoluteFilePathFromClassPath("node-0-keystore.jks"))
            .put("searchguard.ssl.http.truststore_filepath", getAbsoluteFilePathFromClassPath("truststore.jks"))
            //WEAK and insecure cipher, do NOT use this, its here for unittesting only!!!
            .put("searchguard.ssl.http.enabled_ciphers", "SSL_RSA_EXPORT_WITH_RC4_40_MD5")
            //WEAK and insecure protocol, do NOT use this, its here for unittesting only!!!
            .put("searchguard.ssl.http.enabled_protocols", "SSLv3").put("client.type", "node")
            .put("path.home", ".").build();

    try {//from  w ww  . j  a va 2 s  .  c o m
        String[] enabledCiphers = new DefaultSearchGuardKeyStore(settings).createHTTPSSLEngine()
                .getEnabledCipherSuites();
        String[] enabledProtocols = new DefaultSearchGuardKeyStore(settings).createHTTPSSLEngine()
                .getEnabledProtocols();

        if (allowOpenSSL) {
            Assert.assertEquals(2, enabledProtocols.length); //SSLv2Hello is always enabled when using openssl
            Assert.assertTrue("Check SSLv3",
                    "SSLv3".equals(enabledProtocols[0]) || "SSLv3".equals(enabledProtocols[1]));
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("TLS_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        } else {
            Assert.assertEquals(1, enabledProtocols.length);
            Assert.assertEquals("SSLv3", enabledProtocols[0]);
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("SSL_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        }

        settings = Settings.settingsBuilder().put("searchguard.ssl.transport.enabled", true)
                .put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
                .put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
                .put("searchguard.ssl.transport.keystore_filepath",
                        getAbsoluteFilePathFromClassPath("node-0-keystore.jks"))
                .put("searchguard.ssl.transport.truststore_filepath",
                        getAbsoluteFilePathFromClassPath("truststore.jks"))
                //WEAK and insecure cipher, do NOT use this, its here for unittesting only!!!
                .put("searchguard.ssl.transport.enabled_ciphers", "SSL_RSA_EXPORT_WITH_RC4_40_MD5")
                //WEAK and insecure protocol, do NOT use this, its here for unittesting only!!!
                .put("searchguard.ssl.transport.enabled_protocols", "SSLv3").put("client.type", "node")
                .put("path.home", ".").build();

        enabledCiphers = new DefaultSearchGuardKeyStore(settings).createServerTransportSSLEngine()
                .getEnabledCipherSuites();
        enabledProtocols = new DefaultSearchGuardKeyStore(settings).createServerTransportSSLEngine()
                .getEnabledProtocols();

        if (allowOpenSSL) {
            Assert.assertEquals(2, enabledProtocols.length); //SSLv2Hello is always enabled when using openssl
            Assert.assertTrue("Check SSLv3",
                    "SSLv3".equals(enabledProtocols[0]) || "SSLv3".equals(enabledProtocols[1]));
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("TLS_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        } else {
            Assert.assertEquals(1, enabledProtocols.length);
            Assert.assertEquals("SSLv3", enabledProtocols[0]);
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("SSL_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        }
        enabledCiphers = new DefaultSearchGuardKeyStore(settings).createClientTransportSSLEngine(null, -1)
                .getEnabledCipherSuites();
        enabledProtocols = new DefaultSearchGuardKeyStore(settings).createClientTransportSSLEngine(null, -1)
                .getEnabledProtocols();

        if (allowOpenSSL) {
            Assert.assertEquals(2, enabledProtocols.length); //SSLv2Hello is always enabled when using openssl
            Assert.assertTrue("Check SSLv3",
                    "SSLv3".equals(enabledProtocols[0]) || "SSLv3".equals(enabledProtocols[1]));
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("TLS_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        } else {
            Assert.assertEquals(1, enabledProtocols.length);
            Assert.assertEquals("SSLv3", enabledProtocols[0]);
            Assert.assertEquals(1, enabledCiphers.length);
            Assert.assertEquals("SSL_RSA_EXPORT_WITH_RC4_40_MD5", enabledCiphers[0]);
        }
    } catch (ElasticsearchSecurityException e) {
        System.out.println("EXPECTED " + e.getClass().getSimpleName() + " for "
                + System.getProperty("java.specification.version") + ": " + e.toString());
        e.printStackTrace();
        Assert.assertTrue("Check if error contains 'no valid cipher suites' -> " + e.toString(),
                e.toString().contains("no valid cipher suites")
                        || e.toString().contains("failed to set cipher suite")
                        || e.toString().contains("Unable to configure permitted SSL ciphers")
                        || e.toString().contains("OPENSSL_internal:NO_CIPHER_MATCH"));
        Assert.assertTrue("Check if >= Java 8 and no openssl",
                allowOpenSSL ? true : Constants.JRE_IS_MINIMUM_JAVA8);
    }
}

From source file:org.apache.solr.cloud.BasicDistributedZk2Test.java

License:Apache License

@BeforeClass
public static void beforeThisClass2() throws Exception {
    assumeFalse("FIXME: This test fails under Java 8 all the time, see SOLR-4711",
            Constants.JRE_IS_MINIMUM_JAVA8);
}

From source file:org.apache.solr.cloud.hdfs.HdfsUnloadDistributedZkTest.java

License:Apache License

@BeforeClass
public static void setupClass() throws Exception {
    assumeFalse("FIXME: This test fails under Java 8 all the time, see SOLR-4711",
            Constants.JRE_IS_MINIMUM_JAVA8);

    dfsCluster = HdfsTestUtil.setupClass(
            new File(TEMP_DIR, HdfsUnloadDistributedZkTest.class.getName() + "_" + System.currentTimeMillis())
                    .getAbsolutePath());
}

From source file:org.apache.solr.cloud.UnloadDistributedZkTest.java

License:Apache License

@BeforeClass
public static void beforeThisClass3() throws Exception {
    assumeFalse("FIXME: This test fails under Java 8 all the time, see SOLR-4711",
            Constants.JRE_IS_MINIMUM_JAVA8);
}

From source file:org.apache.solr.hadoop.MorphlineBasicMiniMRTest.java

License:Apache License

@BeforeClass
public static void setupClass() throws Exception {
    solrHomeDirectory = createTempDir();
    assumeTrue("Currently this test can only be run without the lucene test security policy in place",
            System.getProperty("java.security.manager", "").equals(""));

    assumeFalse("HDFS tests were disabled by -Dtests.disableHdfs",
            Boolean.parseBoolean(System.getProperty("tests.disableHdfs", "false")));

    assumeFalse("FIXME: This test does not work with Windows because of native library requirements",
            Constants.WINDOWS);//from www.j av a  2 s. c  o  m
    assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301",
            Constants.JRE_IS_MINIMUM_JAVA8);
    assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301",
            System.getProperty("java.vm.info", "<?>").contains("IBM J9"));

    AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
    FileUtils.copyDirectory(MINIMR_CONF_DIR, solrHomeDirectory);
    File dataDir = createTempDir();
    tempDir = dataDir.getAbsolutePath();
    new File(tempDir).mkdirs();
    FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"),
            new File(tempDir + "/custom-mimetypes.xml"));

    AbstractSolrMorphlineTestBase.setupMorphline(tempDir, "test-morphlines/solrCellDocumentTypes", true);

    System.setProperty("hadoop.log.dir", new File(solrHomeDirectory, "logs").getAbsolutePath());

    int taskTrackers = 1;
    int dataNodes = 2;
    //    String proxyUser = System.getProperty("user.name");
    //    String proxyGroup = "g";
    //    StringBuilder sb = new StringBuilder();
    //    sb.append("127.0.0.1,localhost");
    //    for (InetAddress i : InetAddress.getAllByName(InetAddress.getLocalHost().getHostName())) {
    //      sb.append(",").append(i.getCanonicalHostName());
    //    }

    new File(dataDir, "nm-local-dirs").mkdirs();

    System.setProperty("solr.hdfs.blockcache.enabled", "false");

    System.setProperty("test.build.dir", dataDir + File.separator + "hdfs" + File.separator + "test-build-dir");
    System.setProperty("test.build.data", dataDir + File.separator + "hdfs" + File.separator + "build");
    System.setProperty("test.cache.data", dataDir + File.separator + "hdfs" + File.separator + "cache");

    JobConf conf = new JobConf();
    conf.set("dfs.block.access.token.enable", "false");
    conf.set("dfs.permissions", "true");
    conf.set("hadoop.security.authentication", "simple");
    conf.set(YarnConfiguration.NM_LOCAL_DIRS, dataDir.getPath() + File.separator + "nm-local-dirs");
    conf.set(YarnConfiguration.DEFAULT_NM_LOG_DIRS, dataDir + File.separator + "nm-logs");
    conf.set("testWorkDir", dataDir.getPath() + File.separator + "testWorkDir");

    dfsCluster = new MiniDFSCluster(conf, dataNodes, true, null);
    FileSystem fileSystem = dfsCluster.getFileSystem();
    fileSystem.mkdirs(new Path("/tmp"));
    fileSystem.mkdirs(new Path("/user"));
    fileSystem.mkdirs(new Path("/hadoop/mapred/system"));
    fileSystem.setPermission(new Path("/tmp"), FsPermission.valueOf("-rwxrwxrwx"));
    fileSystem.setPermission(new Path("/user"), FsPermission.valueOf("-rwxrwxrwx"));
    fileSystem.setPermission(new Path("/hadoop/mapred/system"), FsPermission.valueOf("-rwx------"));
    String nnURI = fileSystem.getUri().toString();
    int numDirs = 1;
    String[] racks = null;
    String[] hosts = null;

    mrCluster = new MiniMRCluster(0, 0, taskTrackers, nnURI, numDirs, racks, hosts, null, conf);
    ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
}

From source file:org.apache.solr.hadoop.MorphlineMapperTest.java

License:Apache License

@BeforeClass
public static void beforeClass() {
    assumeFalse("Does not work on Windows, because it uses UNIX shell commands or POSIX paths",
            Constants.WINDOWS);//from  ww  w. j a  va2 s.c o m
    assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301",
            Constants.JRE_IS_MINIMUM_JAVA8);
    assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301",
            System.getProperty("java.vm.info", "<?>").contains("IBM J9"));
}

From source file:org.apache.solr.hadoop.MorphlineReducerTest.java

License:Apache License

@BeforeClass
public static void beforeClass2() {
    assumeFalse("Does not work on Windows, because it uses UNIX shell commands or POSIX paths",
            Constants.WINDOWS);//from  w ww.ja v a2  s .c o m
    assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301",
            Constants.JRE_IS_MINIMUM_JAVA8);
    assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301",
            System.getProperty("java.vm.info", "<?>").contains("IBM J9"));

    System.setProperty("verifyPartitionAssignment", "false");
}

From source file:org.apache.solr.morphlines.cell.SolrCellMorphlineTest.java

License:Apache License

@BeforeClass
public static void beforeClass2() {
    assumeFalse("FIXME: Morphlines currently has issues with Windows paths", Constants.WINDOWS);
    assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301",
            Constants.JRE_IS_MINIMUM_JAVA8);
    assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301",
            System.getProperty("java.vm.info", "<?>").contains("IBM J9"));
}

From source file:org.apache.solr.morphlines.solr.SolrMorphlineTest.java

License:Apache License

@BeforeClass
public static void beforeClass2() {
    assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301",
            Constants.JRE_IS_MINIMUM_JAVA8);
    assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301",
            System.getProperty("java.vm.info", "<?>").contains("IBM J9"));
}

From source file:org.elasticsearch.common.util.concurrent.ConcurrentCollections.java

License:Apache License

/**
 * Creates a new CHM with an aggressive concurrency level, aimed at high concurrent update rate long living maps.
 *///from   www.j  a  v  a 2s. c om
public static <K, V> ConcurrentMap<K, V> newConcurrentMapWithAggressiveConcurrency() {
    if (Constants.JRE_IS_MINIMUM_JAVA8) {
        // Just use JDK's impl when we are on Java8:
        return new ConcurrentHashMap<>(16, 0.75f, aggressiveConcurrencyLevel);
    } else {
        return new ConcurrentHashMapV8<>(16, 0.75f, aggressiveConcurrencyLevel);
    }
}