SOLR-6773: Remove the multicore example as the DIH and cloud examples illustrate multicore behavior

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1644461 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy Potter 2014-12-10 15:46:35 +00:00
parent dd4cb4073f
commit f8da9b85ca
17 changed files with 5 additions and 570 deletions

View File

@ -466,6 +466,9 @@ Other Changes
* SOLR-6560: Purge termIndexInterval from example/test configs * SOLR-6560: Purge termIndexInterval from example/test configs
(Tom Burton-West, hossman) (Tom Burton-West, hossman)
* SOLR-6773: Remove the multicore example as the DIH and cloud examples
illustrate multicore behavior (hossman, Timothy Potter)
================== 4.10.3 ================== ================== 4.10.3 ==================
Bug Fixes Bug Fixes

View File

@ -1,98 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.cloud;
import java.io.File;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.ExternalPaths;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestMultiCoreConfBootstrap extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory.getLogger(TestMultiCoreConfBootstrap.class);
protected CoreContainer cores = null;
private String home;
protected File dataDir1;
protected File dataDir2;
protected ZkTestServer zkServer;
protected String zkDir;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
dataDir1 = createTempDir().toFile();
dataDir2 = createTempDir().toFile();
home = ExternalPaths.EXAMPLE_MULTICORE_HOME;
System.setProperty("solr.solr.home", home);
System.setProperty( "solr.core0.data.dir", dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", dataDir2.getCanonicalPath() );
zkDir = dataDir1.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
System.setProperty("zkHost", zkServer.getZkAddress());
}
@Override
@After
public void tearDown() throws Exception {
System.clearProperty("bootstrap_conf");
System.clearProperty("zkHost");
System.clearProperty("solr.solr.home");
if (cores != null)
cores.shutdown();
zkServer.shutdown();
zkServer = null;
zkDir = null;
super.tearDown();
}
@Test
public void testMultiCoreConfBootstrap() throws Exception {
System.setProperty("bootstrap_conf", "true");
cores = CoreContainer.createAndLoad(home, new File(home, "solr.xml"));
SolrZkClient zkclient = cores.getZkController().getZkClient();
// zkclient.printLayoutToStdOut();
assertTrue(zkclient.exists("/configs/core1/solrconfig.xml", true));
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
assertTrue(zkclient.exists("/configs/core0/solrconfig.xml", true));
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
zkclient.close();
}
}

View File

@ -108,23 +108,6 @@ public class ZkCLITest extends SolrTestCaseJ4 {
log.info("####SETUP_END " + getTestName()); log.info("####SETUP_END " + getTestName());
} }
@Test
public void testBootstrap() throws Exception {
// test bootstrap_conf
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"bootstrap", "-solrhome", this.solrHome};
ZkCLI.main(args);
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/collection1", true));
args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"bootstrap", "-solrhome", ExternalPaths.EXAMPLE_MULTICORE_HOME};
ZkCLI.main(args);
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/core0", true));
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/core1", true));
}
@Test @Test
public void testBootstrapWithChroot() throws Exception { public void testBootstrapWithChroot() throws Exception {
String chroot = "/foo/bar"; String chroot = "/foo/bar";

View File

@ -21,6 +21,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest; import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.QueryRequest;
@ -30,7 +31,6 @@ import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
import org.junit.BeforeClass; import org.junit.BeforeClass;
/** /**
@ -48,7 +48,7 @@ public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
@Override @Override
public String getSolrHome() { public String getSolrHome() {
return ExternalPaths.EXAMPLE_MULTICORE_HOME; return SolrTestCaseJ4.getFile("solrj/solr/multicore").getAbsolutePath();
} }
@BeforeClass @BeforeClass

View File

@ -1,260 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.solrj;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.ExternalPaths;
import org.junit.Test;
/**
*
* @since solr 1.3
*/
public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
{
protected CoreContainer cores;
private File dataDir2;
private File dataDir1;
private SolrServer solrCore0;
private SolrServer solrCore1;
private SolrServer solrAdmin;
private final Set<SolrServer> clients = new HashSet<>();
@Override public String getSolrHome() { return ExternalPaths.EXAMPLE_MULTICORE_HOME; }
@Override public void setUp() throws Exception {
super.setUp();
dataDir1 = createTempDir().toFile();
dataDir2 = createTempDir().toFile();
System.setProperty( "solr.core0.data.dir", this.dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
}
@Override
public void tearDown() throws Exception {
super.tearDown();
if(solrCore0 != null) solrCore0.shutdown();
if(solrCore1 != null) solrCore1.shutdown();
if(solrAdmin != null) solrAdmin.shutdown();
solrCore0 = solrCore1 = solrAdmin = null;
for (SolrServer client:clients) {
client.shutdown();
}
clients.clear();
}
@Override
protected final SolrServer getSolrServer()
{
throw new UnsupportedOperationException();
}
@Override
protected final SolrServer createNewSolrServer()
{
throw new UnsupportedOperationException();
}
protected SolrServer getSolrCore0()
{
if (solrCore0 == null) {
solrCore0 = createServer( "core0" );
}
return solrCore0;
}
protected SolrServer getSolrCore1()
{
if (solrCore1 == null) {
solrCore1 = createServer( "core1" );
}
return solrCore1;
}
protected SolrServer getSolrAdmin()
{
if (solrAdmin == null) {
solrAdmin = createServer( "" );
}
return solrAdmin;
}
protected SolrServer getSolrCore(String name)
{
SolrServer server = createServer(name);
clients.add(server);
return server;
}
protected abstract SolrServer createServer(String string);
@Test
public void testMultiCore() throws Exception
{
UpdateRequest up = new UpdateRequest();
up.setAction(ACTION.COMMIT, true, true);
up.deleteByQuery("*:*");
up.process(getSolrCore0());
up.process(getSolrCore1());
up.clear();
// Add something to each core
SolrInputDocument doc = new SolrInputDocument();
doc.setField( "id", "AAA" );
doc.setField( "name", "AAA1" );
doc.setField( "type", "BBB1" );
doc.setField( "core0", "yup" );
// Add to core0
up.add( doc );
up.process( getSolrCore0() );
// You can't add it to core1
try {
ignoreException("unknown field");
up.process( getSolrCore1() );
fail( "Can't add core0 field to core1!" );
}
catch( Exception ex ) {}
resetExceptionIgnores();
// Add to core1
doc.setField( "id", "BBB" );
doc.setField( "name", "BBB1" );
doc.setField( "type", "AAA1" );
doc.setField( "core1", "yup" );
doc.removeField( "core0" );
up.add( doc );
up.process( getSolrCore1() );
// You can't add it to core1
try {
ignoreException("unknown field");
up.process( getSolrCore0() );
fail( "Can't add core1 field to core0!" );
}
catch( Exception ex ) {}
resetExceptionIgnores();
// in core0
doc = new SolrInputDocument();
doc.setField( "id", "BBB1" );
doc.setField( "name", "AAA1" );
doc.setField( "type", "BBB" );
doc.setField( "core0", "AAA1" );
up.clear();
up.add( doc );
up.process( getSolrCore0() );
// now Make sure AAA is in 0 and BBB in 1
SolrQuery q = new SolrQuery();
QueryRequest r = new QueryRequest( q );
q.setQuery( "id:AAA" );
assertEquals( 1, r.process( getSolrCore0() ).getResults().size() );
assertEquals( 0, r.process( getSolrCore1() ).getResults().size() );
// Now test Changing the default core
assertEquals( 1, getSolrCore0().query( new SolrQuery( "id:AAA" ) ).getResults().size() );
assertEquals( 0, getSolrCore0().query( new SolrQuery( "id:BBB" ) ).getResults().size() );
assertEquals( 0, getSolrCore1().query( new SolrQuery( "id:AAA" ) ).getResults().size() );
assertEquals( 1, getSolrCore1().query( new SolrQuery( "id:BBB" ) ).getResults().size() );
// cross-core join
assertEquals( 0, getSolrCore0().query( new SolrQuery( "{!join from=type to=name}*:*" ) ).getResults().size() ); // normal join
assertEquals( 2, getSolrCore0().query( new SolrQuery( "{!join from=type to=name fromIndex=core1}id:BBB" ) ).getResults().size() );
assertEquals( 1, getSolrCore1().query( new SolrQuery( "{!join from=type to=name fromIndex=core0}id:AAA" ) ).getResults().size() );
// test that no rewrite happens in core0 (if it does, it will rewrite to BBB1 and nothing will be found in core1)
assertEquals( 2, getSolrCore0().query( new SolrQuery( "{!join from=type to=name fromIndex=core1}id:BB~" ) ).getResults().size() );
// test that query is parsed in the fromCore
assertEquals( 2, getSolrCore0().query( new SolrQuery( "{!join from=type to=name fromIndex=core1}core1:yup" ) ).getResults().size() );
// Now test reloading it should have a newer open time
String name = "core0";
SolrServer coreadmin = getSolrAdmin();
CoreAdminResponse mcr = CoreAdminRequest.getStatus( name, coreadmin );
long before = mcr.getStartTime( name ).getTime();
CoreAdminRequest.reloadCore( name, coreadmin );
// core should still have docs
assertEquals( 1, getSolrCore0().query( new SolrQuery( "id:AAA" ) ).getResults().size() );
mcr = CoreAdminRequest.getStatus( name, coreadmin );
long after = mcr.getStartTime( name ).getTime();
assertTrue( "should have more recent time: "+after+","+before, after > before );
// test move
CoreAdminRequest.renameCore("core1","corea",coreadmin);
CoreAdminRequest.renameCore("corea","coreb",coreadmin);
CoreAdminRequest.renameCore("coreb","corec",coreadmin);
CoreAdminRequest.renameCore("corec","cored",coreadmin);
CoreAdminRequest.renameCore("cored","corefoo",coreadmin);
try {
getSolrCore("core1").query( new SolrQuery( "id:BBB" ) );
fail( "core1 should be gone" );
}
catch( Exception ex ) {}
assertEquals( 1, getSolrCore("corefoo").query( new SolrQuery( "id:BBB" ) ).getResults().size() );
NamedList<Object> response = getSolrCore("corefoo").query(new SolrQuery().setRequestHandler("/admin/system")).getResponse();
NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
String indexDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("index");
response = getSolrCore("core0").query(new SolrQuery().setRequestHandler("/admin/system")).getResponse();
coreInfo = (NamedList<Object>) response.get("core");
String dataDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("data");
// test delete index on core
CoreAdminRequest.unloadCore("corefoo", true, coreadmin);
File dir = new File(indexDir);
assertFalse("Index directory exists after core unload with deleteIndex=true", dir.exists());
Unload req = new Unload(false);
req.setDeleteDataDir(true);
req.setCoreName("core0");
req.process(coreadmin);
dir = new File(dataDir);
assertFalse("Data directory exists after core unload with deleteDataDir=true : " + dir, dir.exists());
}
}

View File

@ -1,62 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.solrj.embedded;
import org.apache.solr.client.solrj.MultiCoreExampleTestBase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
/**
* This runs SolrServer test using
*
*
* @since solr 1.3
*/
public class MultiCoreEmbeddedTest extends MultiCoreExampleTestBase {
@Override public void setUp() throws Exception
{
// TODO: fix this test to use MockDirectoryFactory
System.clearProperty("solr.directoryFactory");
super.setUp();
setupCoreContainer();
SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
}
protected void setupCoreContainer() {
cores = new CoreContainer();
cores.load();
}
@Override
public void tearDown() throws Exception {
cores.shutdown();
super.tearDown();
}
@Override
protected SolrServer createServer(String string) {
return new EmbeddedSolrServer( cores, string );
}
protected SolrServer getSolrAdmin()
{
return getSolrCore0();
}
}

View File

@ -1,128 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.solrj.embedded;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.MultiCoreExampleTestBase;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ShardParams;
import org.junit.Test;
/**
* TODO? perhaps use:
* http://docs.codehaus.org/display/JETTY/ServletTester
* rather then open a real connection?
*
*
* @since solr 1.3
*/
public class MultiCoreExampleJettyTest extends MultiCoreExampleTestBase {
JettySolrRunner jetty;
int port = 0;
static final String context = "/example";
@Override public void setUp() throws Exception
{
// TODO: fix this test to use MockDirectoryFactory
System.clearProperty("solr.directoryFactory");
super.setUp();
jetty = new JettySolrRunner(getSolrHome(), context, 0, null, null, true, null, sslConfig);
jetty.start(false);
port = jetty.getLocalPort();
}
@Override public void tearDown() throws Exception
{
super.tearDown();
jetty.stop(); // stop the server
}
protected SolrServer createServer( String name )
{
try {
// setup the server...
String url = buildUrl(port, context) + "/" + name;
HttpSolrServer s = new HttpSolrServer( url );
s.setConnectionTimeout(SolrTestCaseJ4.DEFAULT_CONNECTION_TIMEOUT);
s.setDefaultMaxConnectionsPerHost(100);
s.setMaxTotalConnections(100);
return s;
}
catch( Exception ex ) {
throw new RuntimeException( ex );
}
}
@Test
public void testDistributed() throws Exception
{
UpdateRequest up = new UpdateRequest();
up.setAction(ACTION.COMMIT, true, true);
up.deleteByQuery("*:*");
up.process(getSolrCore0());
up.process(getSolrCore1());
up.clear();
// Add something to each core
SolrInputDocument doc = new SolrInputDocument();
// Add to core0
doc.setField( "id", "core0" );
up.add( doc );
up.process( getSolrCore0() );
up.clear();
// Add to core1
doc.setField( "id", "core1" );
up.add( doc );
up.process( getSolrCore1() );
up.clear();
SolrQuery q = new SolrQuery();
QueryRequest r = new QueryRequest( q );
q.setQuery( "*:*" );
assertEquals( 1, r.process( getSolrCore0() ).getResults().size() );
assertEquals( 1, r.process( getSolrCore1() ).getResults().size() );
// Distributed
String baseURL = buildUrl(port, context) + "/";
q = new SolrQuery( "*:*" );
q.set( ShardParams.SHARDS, baseURL+"core0,"+baseURL+"core1" );
q.set( "fl", "id,s:[shard]" );
r = new QueryRequest( q );
SolrDocumentList docs = r.process( getSolrCore0() ).getResults();
assertEquals( 2, docs.size() );
for( SolrDocument d : docs ) {
String id = (String)d.get("id");
String shard = (String)d.get("s");
assertEquals(baseURL+id, shard); // The shard ends with the core name
}
}
}

View File

@ -51,9 +51,6 @@ public class ExternalPaths {
public static String TECHPRODUCTS_CONFIGSET = public static String TECHPRODUCTS_CONFIGSET =
new File(SOURCE_HOME, "server/solr/configsets/sample_techproducts_configs/conf").getAbsolutePath(); new File(SOURCE_HOME, "server/solr/configsets/sample_techproducts_configs/conf").getAbsolutePath();
/* @see #SOURCE_HOME */
public static String EXAMPLE_MULTICORE_HOME = new File(SOURCE_HOME, "example/multicore").getAbsolutePath();
public static String SERVER_HOME = new File(SOURCE_HOME, "server/solr").getAbsolutePath(); public static String SERVER_HOME = new File(SOURCE_HOME, "server/solr").getAbsolutePath();
/** /**