List of usage examples for org.apache.solr.common.cloud ZkStateReader ZkStateReader
public ZkStateReader(String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout)
From source file:org.apache.coheigea.bigdata.solr.ranger.RangerSolrCloudTest.java
License:Apache License
@BeforeClass public static void setUp() throws Exception { JettyConfig.Builder jettyConfig = JettyConfig.builder(); jettyConfig.waitForLoadingCoresToFinish(null); String solrConfig = new String(Files.readAllBytes(Paths.get("target/test-classes/solrcloud/solr.xml")), Charset.defaultCharset()); tempDir = Files.createTempDirectory("solrcloud"); server = new MiniSolrCloudCluster(2, tempDir, solrConfig, jettyConfig.build()); // Insert the RangerSolrAuthorizer + BasicAuthPlugin try (ZkStateReader zkStateReader = new ZkStateReader(server.getZkServer().getZkAddress(), 10000, 10000)) { zkStateReader.getZkClient().delete(ZkStateReader.SOLR_SECURITY_CONF_PATH, 0, true); String securityJson = new String(Files.readAllBytes(Paths.get("src/test/resources/security.json")), Charset.defaultCharset()); zkStateReader.getZkClient().create(ZkStateReader.SOLR_SECURITY_CONF_PATH, securityJson.getBytes(Charset.defaultCharset()), CreateMode.PERSISTENT, true); }/*from w w w .j a va 2s .co m*/ String configName = "core1Config"; File configDir = Paths.get("target/test-classes/solrcloud").toFile(); server.uploadConfigDir(configDir, configName); Map<String, String> collectionProperties = new HashMap<>(); collectionProperties.put("config", "solrconfig.xml"); collectionProperties.put("schema", "schema.xml"); server.createCollection("docs", 1, 1, configName, collectionProperties); JettySolrRunner startedServer = server.startJettySolrRunner(); assertTrue(startedServer.isRunning()); }