List of usage examples for org.apache.solr.client.solrj.embedded JettyConfig builder
public static Builder builder()
From source file:com.yahoo.ycsb.db.solr.SolrClientBaseTest.java
License:Open Source License
@BeforeClass public static void onlyOnce() throws Exception { Path miniSolrCloudClusterTempDirectory = Files.createTempDirectory("miniSolrCloudCluster"); miniSolrCloudClusterTempDirectory.toFile().deleteOnExit(); miniSolrCloudCluster = new MiniSolrCloudCluster(1, miniSolrCloudClusterTempDirectory, JettyConfig.builder().build()); // Upload Solr configuration URL configDir = SolrClientBaseTest.class.getClassLoader().getResource("solr_config"); assertNotNull(configDir);/*from www. j a va2 s .c o m*/ miniSolrCloudCluster.uploadConfigDir(new File(configDir.toURI()), MOCK_TABLE); }
From source file:ddf.catalog.source.solr.SolrProviderRealTimeQueryTest.java
License:Open Source License
@BeforeClass public static void beforeClass() throws Exception { ConfigurationStore store = ConfigurationStore.getInstance(); // Set to false for real time query by ID tests store.setForceAutoCommit(false);/*from w w w . ja v a2s.co m*/ String solrDataPath = Paths.get("target/surefire/solr/realtime").toString(); System.setProperty("solr.data.dir", solrDataPath); store.setDataDirectoryPath(solrDataPath); System.setProperty("jute.maxbuffer", "20000000"); // windows solution miniSolrCloud = new MiniSolrCloudCluster(1, baseDir.getRoot().toPath(), JettyConfig.builder().setContext("/solr").build()); System.setProperty("solr.cloud.shardCount", "1"); System.setProperty("solr.cloud.replicationFactor", "1"); System.setProperty("solr.cloud.maxShardPerNode", "1"); System.setProperty("solr.cloud.zookeeper.chroot", "/solr"); System.setProperty("solr.cloud.zookeeper", miniSolrCloud.getZkServer().getZkHost()); // Set soft commit and hard commit times high, so they will not impact the tests. System.setProperty("solr.autoSoftCommit.maxTime", String.valueOf(TimeUnit.MINUTES.toMillis(30))); System.setProperty("solr.autoCommit.maxTime", String.valueOf(TimeUnit.MINUTES.toMillis((45)))); System.setProperty("solr.commit.nrt.metacardTypes", COMMIT_NRT_TYPE); System.setProperty("solr.commit.nrt.commitWithinMs", "1"); SolrCloudClientFactory solrClientFactory = new SolrCloudClientFactory(); solrClient = solrClientFactory.newClient("catalog"); Assert.assertThat("Solr client is not available for testing", solrClient.isAvailable(30L, TimeUnit.SECONDS), Matchers.equalTo(true)); provider = new SolrCatalogProvider(solrClient, new GeotoolsFilterAdapterImpl(), new SolrFilterDelegateFactoryImpl()); // Mask the id, this is something that the CatalogFramework would usually do provider.setId(MASKED_ID); }
From source file:ddf.catalog.source.solr.SolrProviderTest.java
License:Open Source License
@BeforeClass public static void beforeClass() throws Exception { ConfigurationStore store = ConfigurationStore.getInstance(); store.setForceAutoCommit(true);/*ww w. ja v a 2 s .c om*/ String solrDataPath = Paths.get("target/surefire/solr").toString(); System.setProperty("solr.data.dir", solrDataPath); store.setDataDirectoryPath(solrDataPath); System.setProperty("jute.maxbuffer", "20000000"); // windows solution miniSolrCloud = new MiniSolrCloudCluster(1, baseDir.getRoot().toPath(), JettyConfig.builder().setContext("/solr").build()); System.setProperty("solr.cloud.shardCount", "1"); System.setProperty("solr.cloud.replicationFactor", "1"); System.setProperty("solr.cloud.maxShardPerNode", "1"); System.setProperty("solr.cloud.zookeeper.chroot", "/solr"); System.setProperty("solr.cloud.zookeeper", miniSolrCloud.getZkServer().getZkHost()); System.setProperty("metadata.size.limit", Integer.toString(FIVE_MEGABYTES)); SolrCloudClientFactory solrClientFactory = new SolrCloudClientFactory(); solrClient = solrClientFactory.newClient("catalog"); Assert.assertThat("Solr client is not available for testing", solrClient.isAvailable(30L, TimeUnit.SECONDS), Matchers.equalTo(true)); provider = new SolrCatalogProvider(solrClient, new GeotoolsFilterAdapterImpl(), new SolrFilterDelegateFactoryImpl()); // Mask the id, this is something that the CatalogFramework would usually do provider.setId(MASKED_ID); }
From source file:io.redlink.solrlib.standalone.test.StandaloneSolrServer.java
License:Apache License
public StandaloneSolrServer(int port, String context) { final JettyConfig.Builder builder = JettyConfig.builder() .setContext(StringUtils.defaultString(context, "/solr")); if (port > 0) builder.setPort(port);/*w w w . j ava2 s .c om*/ jettyConfig = builder.build(); }
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 ww . java 2 s .com 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()); }
From source file:org.apache.coheigea.bigdata.solr.SolrCloudTest.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()); 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()); }
From source file:org.apache.metron.solr.integration.components.SolrComponent.java
License:Apache License
@Override public void start() throws UnableToStartException { try {/*ww w .j a va 2 s .co m*/ File baseDir = Files.createTempDirectory("solrcomponent").toFile(); baseDir.deleteOnExit(); miniSolrCloudCluster = new MiniSolrCloudCluster(1, baseDir, new File(solrXmlPath), JettyConfig.builder().setPort(port).build()); for (String name : collections.keySet()) { String configPath = collections.get(name); miniSolrCloudCluster.uploadConfigDir(new File(configPath), name); } miniSolrCloudCluster.createCollection("metron", 1, 1, "metron", new HashMap<String, String>()); if (postStartCallback != null) postStartCallback.apply(this); } catch (Exception e) { throw new UnableToStartException(e.getMessage(), e); } }
From source file:org.codice.ddf.commands.solr.SolrCommandTest.java
License:Open Source License
protected static void createMiniSolrCloudCluster() throws Exception { miniSolrCloud = new MiniSolrCloudCluster(1, getBaseDirPath(), JettyConfig.builder().setContext("/solr").build()); miniSolrCloud.getSolrClient().connect(); System.setProperty("solr.cloud.shardCount", "1"); System.setProperty("solr.cloud.replicationFactor", "1"); System.setProperty("solr.cloud.maxShardPerNode", "1"); System.setProperty("solr.cloud.zookeeper.chroot", "/solr"); System.setProperty(SolrCommands.ZOOKEEPER_HOSTS_PROP, miniSolrCloud.getZkServer().getZkHost()); // Set soft commit and hard commit times high, so they will not impact the tests. System.setProperty("solr.autoSoftCommit.maxTime", String.valueOf(100)); System.setProperty("solr.autoCommit.maxTime", String.valueOf(100)); }
From source file:org.janusgraph.diskstorage.solr.SolrRunner.java
License:Apache License
public static void start(boolean isKerberosEnabled) throws Exception { kerberosEnabled = isKerberosEnabled; if (ZOOKEEPER_URLS_SYSTEM_PROPERTY != null) { return;// w w w . j a v a 2 s .c o m } String userDir = System.getProperty("user.dir"); String solrHome = userDir.contains("janusgraph-solr") ? Joiner.on(File.separator).join(userDir, "target", "test-classes", "solr") : Joiner.on(File.separator).join(userDir, "janusgraph-solr", "target", "test-classes", "solr"); File templateDirectory = new File(solrHome + File.separator + TEMPLATE_DIRECTORY); Preconditions.checkState(templateDirectory.exists()); File temp = new File(TMP_DIRECTORY + File.separator + "solr-" + System.nanoTime()); Preconditions.checkState(!temp.exists()); Preconditions.checkState(temp.mkdirs(), "Unable to create solr temporary directory {}", temp.getAbsolutePath()); temp.deleteOnExit(); final String solrXml = new String(Files.readAllBytes(new File(solrHome, "solr.xml").toPath())); if (!kerberosEnabled) { miniSolrCloudCluster = new MiniSolrCloudCluster(NUM_SERVERS, null, temp.toPath(), solrXml, null, null); } else { JettyConfig jettyConfig = JettyConfig.builder().setContext(null).withSSLConfig(null).withFilters(null) .withServlets(null).build(); miniSolrCloudCluster = new ConfigurableMiniSolrCloudCluster(NUM_SERVERS, temp.toPath(), solrXml, jettyConfig, null, Optional.of(SECURITY_JSON)); } for (String core : COLLECTIONS) { File coreDirectory = new File(temp.getAbsolutePath() + File.separator + core); Preconditions.checkState(coreDirectory.mkdirs()); FileUtils.copyDirectory(templateDirectory, coreDirectory); miniSolrCloudCluster.uploadConfigSet(Paths.get(coreDirectory.getAbsolutePath()), core); } }