mirror of https://github.com/apache/lucene.git
SOLR-8336: CoreDescriptor takes a Path for its instance dir, rather than a String
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1717254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
209481ad35
commit
e5be9136a6
|
@ -188,7 +188,8 @@ Other Changes
|
||||||
* LUCENE-6900: Added test for score ordered grouping, and refactored TopGroupsResultTransformer.
|
* LUCENE-6900: Added test for score ordered grouping, and refactored TopGroupsResultTransformer.
|
||||||
(David Smiley)
|
(David Smiley)
|
||||||
|
|
||||||
|
* SOLR-8336: CoreDescriptor now takes a Path for its instance directory, rather
|
||||||
|
than a String (Alan Woodward)
|
||||||
|
|
||||||
================== 5.4.0 ==================
|
================== 5.4.0 ==================
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.filecache.DistributedCache;
|
import org.apache.hadoop.filecache.DistributedCache;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
@ -158,13 +158,8 @@ class SolrRecordWriter<K, V> extends RecordWriter<K, V> {
|
||||||
|
|
||||||
CoreContainer container = new CoreContainer(loader);
|
CoreContainer container = new CoreContainer(loader);
|
||||||
container.load();
|
container.load();
|
||||||
|
|
||||||
Properties props = new Properties();
|
SolrCore core = container.create("core1", ImmutableMap.of(CoreDescriptor.CORE_DATADIR, dataDirStr));
|
||||||
props.setProperty(CoreDescriptor.CORE_DATADIR, dataDirStr);
|
|
||||||
|
|
||||||
CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHomeDir.toString(), props);
|
|
||||||
|
|
||||||
SolrCore core = container.create(descr);
|
|
||||||
|
|
||||||
if (!(core.getDirectoryFactory() instanceof HdfsDirectoryFactory)) {
|
if (!(core.getDirectoryFactory() instanceof HdfsDirectoryFactory)) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
package org.apache.solr.cloud;
|
package org.apache.solr.cloud;
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import org.apache.solr.core.ConfigSetService;
|
import org.apache.solr.core.ConfigSetService;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
import org.apache.solr.core.CoreDescriptor;
|
||||||
import org.apache.solr.core.SolrResourceLoader;
|
import org.apache.solr.core.SolrResourceLoader;
|
||||||
|
@ -37,7 +35,7 @@ public class CloudConfigSetService extends ConfigSetService {
|
||||||
// TODO: Shouldn't the collection node be created by the Collections API?
|
// TODO: Shouldn't the collection node be created by the Collections API?
|
||||||
zkController.createCollectionZkNode(cd.getCloudDescriptor());
|
zkController.createCollectionZkNode(cd.getCloudDescriptor());
|
||||||
String configName = zkController.getZkStateReader().readConfigName(cd.getCollectionName());
|
String configName = zkController.getZkStateReader().readConfigName(cd.getCollectionName());
|
||||||
return new ZkSolrResourceLoader(Paths.get(cd.getInstanceDir()), configName, parentLoader.getClassLoader(),
|
return new ZkSolrResourceLoader(cd.getInstanceDir(), configName, parentLoader.getClassLoader(),
|
||||||
cd.getSubstitutableProperties(), zkController);
|
cd.getSubstitutableProperties(), zkController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,31 +17,24 @@ package org.apache.solr.cloud;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import org.apache.solr.common.cloud.Replica;
|
import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.cloud.Slice;
|
|
||||||
import org.apache.solr.common.params.SolrParams;
|
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
import org.apache.solr.core.CoreDescriptor;
|
||||||
import org.apache.solr.util.PropertiesUtil;
|
import org.apache.solr.util.PropertiesUtil;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
|
|
||||||
public class CloudDescriptor {
|
public class CloudDescriptor {
|
||||||
|
|
||||||
private final CoreDescriptor cd;
|
private final CoreDescriptor cd;
|
||||||
private String shardId;
|
private String shardId;
|
||||||
private String collectionName;
|
private String collectionName;
|
||||||
private SolrParams params;
|
|
||||||
private String roles = null;
|
private String roles = null;
|
||||||
private Integer numShards;
|
private Integer numShards;
|
||||||
private String nodeName = null;
|
private String nodeName = null;
|
||||||
|
private Map<String, String> collectionParams = new HashMap<>();
|
||||||
/* shardRange and shardState are used once-only during sub shard creation for shard splits
|
|
||||||
* Use the values from {@link Slice} instead */
|
|
||||||
volatile String shardRange = null;
|
|
||||||
volatile Slice.State shardState = Slice.State.ACTIVE;
|
|
||||||
volatile String shardParent = null;
|
|
||||||
|
|
||||||
private volatile boolean isLeader = false;
|
private volatile boolean isLeader = false;
|
||||||
|
|
||||||
|
@ -64,6 +57,12 @@ public class CloudDescriptor {
|
||||||
if (Strings.isNullOrEmpty(nodeName))
|
if (Strings.isNullOrEmpty(nodeName))
|
||||||
this.nodeName = null;
|
this.nodeName = null;
|
||||||
this.numShards = PropertiesUtil.toInteger(props.getProperty(CloudDescriptor.NUM_SHARDS), null);
|
this.numShards = PropertiesUtil.toInteger(props.getProperty(CloudDescriptor.NUM_SHARDS), null);
|
||||||
|
|
||||||
|
for (String propName : props.stringPropertyNames()) {
|
||||||
|
if (propName.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) {
|
||||||
|
collectionParams.put(propName.substring(ZkController.COLLECTION_PARAM_PREFIX.length()), props.getProperty(propName));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Replica.State getLastPublished() {
|
public Replica.State getLastPublished() {
|
||||||
|
@ -115,12 +114,8 @@ public class CloudDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Optional parameters that can change how a core is created. */
|
/** Optional parameters that can change how a core is created. */
|
||||||
public SolrParams getParams() {
|
public Map<String, String> getParams() {
|
||||||
return params;
|
return collectionParams;
|
||||||
}
|
|
||||||
|
|
||||||
public void setParams(SolrParams params) {
|
|
||||||
this.params = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setting only matters on core creation
|
// setting only matters on core creation
|
||||||
|
|
|
@ -72,12 +72,11 @@ public class CloudUtil {
|
||||||
cc.unload(desc.getName());
|
cc.unload(desc.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
File instanceDir = new File(desc.getInstanceDir());
|
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(instanceDir);
|
FileUtils.deleteDirectory(desc.getInstanceDir().toFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SolrException.log(log, "Failed to delete instance dir for core:"
|
SolrException.log(log, "Failed to delete instance dir for core:"
|
||||||
+ desc.getName() + " dir:" + instanceDir.getAbsolutePath());
|
+ desc.getName() + " dir:" + desc.getInstanceDir());
|
||||||
}
|
}
|
||||||
log.error("", new SolrException(ErrorCode.SERVER_ERROR,
|
log.error("", new SolrException(ErrorCode.SERVER_ERROR,
|
||||||
"Will not load SolrCore " + desc.getName()
|
"Will not load SolrCore " + desc.getName()
|
||||||
|
|
|
@ -25,19 +25,7 @@ import java.net.URLEncoder;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
@ -52,25 +40,7 @@ import org.apache.solr.cloud.overseer.OverseerAction;
|
||||||
import org.apache.solr.cloud.overseer.SliceMutator;
|
import org.apache.solr.cloud.overseer.SliceMutator;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
import org.apache.solr.common.cloud.BeforeReconnect;
|
import org.apache.solr.common.cloud.*;
|
||||||
import org.apache.solr.common.cloud.ClusterState;
|
|
||||||
import org.apache.solr.common.cloud.ClusterStateUtil;
|
|
||||||
import org.apache.solr.common.cloud.DefaultConnectionStrategy;
|
|
||||||
import org.apache.solr.common.cloud.DefaultZkACLProvider;
|
|
||||||
import org.apache.solr.common.cloud.DefaultZkCredentialsProvider;
|
|
||||||
import org.apache.solr.common.cloud.DocCollection;
|
|
||||||
import org.apache.solr.common.cloud.OnReconnect;
|
|
||||||
import org.apache.solr.common.cloud.Replica;
|
|
||||||
import org.apache.solr.common.cloud.Slice;
|
|
||||||
import org.apache.solr.common.cloud.SolrZkClient;
|
|
||||||
import org.apache.solr.common.cloud.ZkACLProvider;
|
|
||||||
import org.apache.solr.common.cloud.ZkCmdExecutor;
|
|
||||||
import org.apache.solr.common.cloud.ZkConfigManager;
|
|
||||||
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
|
||||||
import org.apache.solr.common.cloud.ZkCredentialsProvider;
|
|
||||||
import org.apache.solr.common.cloud.ZkNodeProps;
|
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
|
||||||
import org.apache.solr.common.cloud.ZooKeeperException;
|
|
||||||
import org.apache.solr.common.params.CollectionParams;
|
import org.apache.solr.common.params.CollectionParams;
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
import org.apache.solr.common.params.SolrParams;
|
import org.apache.solr.common.params.SolrParams;
|
||||||
|
@ -102,11 +72,11 @@ import org.slf4j.MDC;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
|
||||||
|
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NODE_NAME_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.ELECTION_NODE_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.ELECTION_NODE_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.NODE_NAME_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.NODE_NAME_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.REJOIN_AT_HEAD_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.REJOIN_AT_HEAD_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
|
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
|
||||||
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NODE_NAME_PROP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ZooKeeper interactions.
|
* Handle ZooKeeper interactions.
|
||||||
|
@ -1337,7 +1307,6 @@ public final class ZkController {
|
||||||
try {
|
try {
|
||||||
if (!zkClient.exists(collectionPath, true)) {
|
if (!zkClient.exists(collectionPath, true)) {
|
||||||
log.info("Creating collection in ZooKeeper:" + collection);
|
log.info("Creating collection in ZooKeeper:" + collection);
|
||||||
SolrParams params = cd.getParams();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Object> collectionProps = new HashMap<>();
|
Map<String, Object> collectionProps = new HashMap<>();
|
||||||
|
@ -1346,15 +1315,8 @@ public final class ZkController {
|
||||||
String defaultConfigName = System.getProperty(COLLECTION_PARAM_PREFIX + CONFIGNAME_PROP, collection);
|
String defaultConfigName = System.getProperty(COLLECTION_PARAM_PREFIX + CONFIGNAME_PROP, collection);
|
||||||
|
|
||||||
// params passed in - currently only done via core admin (create core commmand).
|
// params passed in - currently only done via core admin (create core commmand).
|
||||||
if (params != null) {
|
if (cd.getParams().size() > 0) {
|
||||||
Iterator<String> iter = params.getParameterNamesIterator();
|
collectionProps.putAll(cd.getParams());
|
||||||
while (iter.hasNext()) {
|
|
||||||
String paramName = iter.next();
|
|
||||||
if (paramName.startsWith(COLLECTION_PARAM_PREFIX)) {
|
|
||||||
collectionProps.put(paramName.substring(COLLECTION_PARAM_PREFIX.length()), params.get(paramName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the config name wasn't passed in, use the default
|
// if the config name wasn't passed in, use the default
|
||||||
if (!collectionProps.containsKey(CONFIGNAME_PROP)) {
|
if (!collectionProps.containsKey(CONFIGNAME_PROP)) {
|
||||||
// TODO: getting the configName from the collectionPath should fail since we already know it doesn't exist?
|
// TODO: getting the configName from the collectionPath should fail since we already know it doesn't exist?
|
||||||
|
@ -1795,8 +1757,7 @@ public final class ZkController {
|
||||||
String confName = cd.getCollectionName();
|
String confName = cd.getCollectionName();
|
||||||
if (StringUtils.isEmpty(confName))
|
if (StringUtils.isEmpty(confName))
|
||||||
confName = coreName;
|
confName = coreName;
|
||||||
String instanceDir = cd.getInstanceDir();
|
Path udir = cd.getInstanceDir().resolve("conf");
|
||||||
Path udir = Paths.get(instanceDir).resolve("conf");
|
|
||||||
log.info("Uploading directory " + udir + " with name " + confName + " for SolrCore " + coreName);
|
log.info("Uploading directory " + udir + " with name " + confName + " for SolrCore " + coreName);
|
||||||
configManager.uploadConfigDir(udir, confName);
|
configManager.uploadConfigDir(udir, confName);
|
||||||
}
|
}
|
||||||
|
@ -2524,4 +2485,22 @@ public final class ZkController {
|
||||||
super(code, msg);
|
super(code, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) {
|
||||||
|
DocCollection collection = zkStateReader.getClusterState().getCollectionOrNull(dcore.getCollectionName());
|
||||||
|
if (collection != null) {
|
||||||
|
Collection<Slice> slices = collection.getSlices();
|
||||||
|
|
||||||
|
for (Slice slice : slices) {
|
||||||
|
Collection<Replica> replicas = slice.getReplicas();
|
||||||
|
for (Replica replica : replicas) {
|
||||||
|
if (replica.getName().equals(
|
||||||
|
dcore.getCloudDescriptor().getCoreNodeName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ public abstract class ConfigSetService {
|
||||||
protected Path locateInstanceDir(CoreDescriptor cd) {
|
protected Path locateInstanceDir(CoreDescriptor cd) {
|
||||||
String configSet = cd.getConfigSet();
|
String configSet = cd.getConfigSet();
|
||||||
if (configSet == null)
|
if (configSet == null)
|
||||||
return Paths.get(cd.getInstanceDir());
|
return cd.getInstanceDir();
|
||||||
Path configSetDirectory = configSetBase.resolve(configSet);
|
Path configSetDirectory = configSetBase.resolve(configSet);
|
||||||
if (!Files.isDirectory(configSetDirectory))
|
if (!Files.isDirectory(configSetDirectory))
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
|
import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
|
||||||
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
||||||
|
import org.apache.solr.cloud.Overseer;
|
||||||
import org.apache.solr.cloud.ZkController;
|
import org.apache.solr.cloud.ZkController;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
|
@ -518,7 +519,7 @@ public class CoreContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkForDuplicateCoreNames(List<CoreDescriptor> cds) {
|
private static void checkForDuplicateCoreNames(List<CoreDescriptor> cds) {
|
||||||
Map<String, String> addedCores = Maps.newHashMap();
|
Map<String, Path> addedCores = Maps.newHashMap();
|
||||||
for (CoreDescriptor cd : cds) {
|
for (CoreDescriptor cd : cds) {
|
||||||
final String name = cd.getName();
|
final String name = cd.getName();
|
||||||
if (addedCores.containsKey(name))
|
if (addedCores.containsKey(name))
|
||||||
|
@ -707,12 +708,82 @@ public class CoreContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new core based on a CoreDescriptor, publishing the core state to the cluster
|
* Creates a new core, publishing the core state to the cluster
|
||||||
* @param cd the CoreDescriptor
|
* @param coreName the core name
|
||||||
|
* @param parameters the core parameters
|
||||||
* @return the newly created core
|
* @return the newly created core
|
||||||
*/
|
*/
|
||||||
public SolrCore create(CoreDescriptor cd) {
|
public SolrCore create(String coreName, Map<String, String> parameters) {
|
||||||
return create(cd, true);
|
return create(coreName, cfg.getCoreRootDirectory().resolve(coreName), parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new core in a specified instance directory, publishing the core state to the cluster
|
||||||
|
* @param coreName the core name
|
||||||
|
* @param instancePath the instance directory
|
||||||
|
* @param parameters the core parameters
|
||||||
|
* @return the newly created core
|
||||||
|
*/
|
||||||
|
public SolrCore create(String coreName, Path instancePath, Map<String, String> parameters) {
|
||||||
|
|
||||||
|
CoreDescriptor cd = new CoreDescriptor(this, coreName, instancePath, parameters);
|
||||||
|
|
||||||
|
// TODO: There's a race here, isn't there?
|
||||||
|
if (getAllCoreNames().contains(coreName)) {
|
||||||
|
log.warn("Creating a core with existing name is not allowed");
|
||||||
|
// TODO: Shouldn't this be a BAD_REQUEST?
|
||||||
|
throw new SolrException(ErrorCode.SERVER_ERROR, "Core with name '" + coreName + "' already exists.");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean preExisitingZkEntry = false;
|
||||||
|
try {
|
||||||
|
if (getZkController() != null) {
|
||||||
|
if (!Overseer.isLegacy(getZkController().getZkStateReader().getClusterProps())) {
|
||||||
|
if (cd.getCloudDescriptor().getCoreNodeName() == null) {
|
||||||
|
throw new SolrException(ErrorCode.SERVER_ERROR, "non legacy mode coreNodeName missing " + parameters.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
preExisitingZkEntry = getZkController().checkIfCoreNodeNameAlreadyExists(cd);
|
||||||
|
}
|
||||||
|
|
||||||
|
SolrCore core = create(cd, true);
|
||||||
|
|
||||||
|
// only write out the descriptor if the core is successfully created
|
||||||
|
coresLocator.create(this, cd);
|
||||||
|
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
if (isZooKeeperAware() && !preExisitingZkEntry) {
|
||||||
|
try {
|
||||||
|
getZkController().unregister(coreName, cd);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
SolrException.log(log, null, e);
|
||||||
|
} catch (KeeperException e) {
|
||||||
|
SolrException.log(log, null, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Throwable tc = ex;
|
||||||
|
Throwable c = null;
|
||||||
|
do {
|
||||||
|
tc = tc.getCause();
|
||||||
|
if (tc != null) {
|
||||||
|
c = tc;
|
||||||
|
}
|
||||||
|
} while (tc != null);
|
||||||
|
|
||||||
|
String rootMsg = "";
|
||||||
|
if (c != null) {
|
||||||
|
rootMsg = " Caused by: " + c.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
||||||
|
"Error CREATEing SolrCore '" + coreName + "': " + ex.getMessage() + rootMsg, ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -723,7 +794,7 @@ public class CoreContainer {
|
||||||
*
|
*
|
||||||
* @return the newly created core
|
* @return the newly created core
|
||||||
*/
|
*/
|
||||||
public SolrCore create(CoreDescriptor dcore, boolean publishState) {
|
private SolrCore create(CoreDescriptor dcore, boolean publishState) {
|
||||||
|
|
||||||
if (isShutDown) {
|
if (isShutDown) {
|
||||||
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Solr has been shutdown.");
|
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Solr has been shutdown.");
|
||||||
|
@ -960,8 +1031,8 @@ public class CoreContainer {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCoreRootDirectory() {
|
public Path getCoreRootDirectory() {
|
||||||
return cfg.getCoreRootDirectory().toString();
|
return cfg.getCoreRootDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1007,7 +1078,7 @@ public class CoreContainer {
|
||||||
if (zkSys.getZkController() != null) {
|
if (zkSys.getZkController() != null) {
|
||||||
zkSys.getZkController().throwErrorIfReplicaReplaced(desc);
|
zkSys.getZkController().throwErrorIfReplicaReplaced(desc);
|
||||||
}
|
}
|
||||||
core = create(desc); // This should throw an error if it fails.
|
core = create(desc, true); // This should throw an error if it fails.
|
||||||
}
|
}
|
||||||
core.open();
|
core.open();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,26 +17,26 @@
|
||||||
|
|
||||||
package org.apache.solr.core;
|
package org.apache.solr.core;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.solr.cloud.CloudDescriptor;
|
import org.apache.solr.cloud.CloudDescriptor;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.params.SolrParams;
|
|
||||||
import org.apache.solr.common.util.IOUtils;
|
|
||||||
import org.apache.solr.util.PropertiesUtil;
|
import org.apache.solr.util.PropertiesUtil;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Solr core descriptor
|
* A Solr core descriptor
|
||||||
*
|
*
|
||||||
|
@ -47,8 +47,6 @@ public class CoreDescriptor {
|
||||||
// Properties file name constants
|
// Properties file name constants
|
||||||
public static final String CORE_NAME = "name";
|
public static final String CORE_NAME = "name";
|
||||||
public static final String CORE_CONFIG = "config";
|
public static final String CORE_CONFIG = "config";
|
||||||
public static final String CORE_INSTDIR = "instanceDir";
|
|
||||||
public static final String CORE_ABS_INSTDIR = "absoluteInstDir";
|
|
||||||
public static final String CORE_DATADIR = "dataDir";
|
public static final String CORE_DATADIR = "dataDir";
|
||||||
public static final String CORE_ULOGDIR = "ulogDir";
|
public static final String CORE_ULOGDIR = "ulogDir";
|
||||||
public static final String CORE_SCHEMA = "schema";
|
public static final String CORE_SCHEMA = "schema";
|
||||||
|
@ -91,13 +89,12 @@ public class CoreDescriptor {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static ImmutableList<String> requiredProperties = ImmutableList.of(
|
private static ImmutableList<String> requiredProperties = ImmutableList.of(
|
||||||
CORE_NAME, CORE_INSTDIR, CORE_ABS_INSTDIR
|
CORE_NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static ImmutableList<String> standardPropNames = ImmutableList.of(
|
public static ImmutableList<String> standardPropNames = ImmutableList.of(
|
||||||
CORE_NAME,
|
CORE_NAME,
|
||||||
CORE_CONFIG,
|
CORE_CONFIG,
|
||||||
CORE_INSTDIR,
|
|
||||||
CORE_DATADIR,
|
CORE_DATADIR,
|
||||||
CORE_ULOGDIR,
|
CORE_ULOGDIR,
|
||||||
CORE_SCHEMA,
|
CORE_SCHEMA,
|
||||||
|
@ -118,6 +115,8 @@ public class CoreDescriptor {
|
||||||
|
|
||||||
private final CloudDescriptor cloudDesc;
|
private final CloudDescriptor cloudDesc;
|
||||||
|
|
||||||
|
private final Path instanceDir;
|
||||||
|
|
||||||
/** The original standard core properties, before substitution */
|
/** The original standard core properties, before substitution */
|
||||||
protected final Properties originalCoreProperties = new Properties();
|
protected final Properties originalCoreProperties = new Properties();
|
||||||
|
|
||||||
|
@ -130,61 +129,72 @@ public class CoreDescriptor {
|
||||||
/** The properties for this core, substitutable by resource loaders */
|
/** The properties for this core, substitutable by resource loaders */
|
||||||
protected final Properties substitutableProperties = new Properties();
|
protected final Properties substitutableProperties = new Properties();
|
||||||
|
|
||||||
/**
|
public CoreDescriptor(CoreContainer container, String name, Path instanceDir, String... properties) {
|
||||||
* Create a new CoreDescriptor.
|
this(container, name, instanceDir, toMap(properties));
|
||||||
* @param container the CoreDescriptor's container
|
|
||||||
* @param name the CoreDescriptor's name
|
|
||||||
* @param instanceDir a String containing the instanceDir
|
|
||||||
* @param coreProps a Properties object of the properties for this core
|
|
||||||
*/
|
|
||||||
public CoreDescriptor(CoreContainer container, String name, String instanceDir,
|
|
||||||
Properties coreProps) {
|
|
||||||
this(container, name, instanceDir, coreProps, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreDescriptor(CoreContainer container, String name, String instanceDir, String... properties) {
|
private static Map<String, String> toMap(String... properties) {
|
||||||
this(container, name, instanceDir, toProperties(properties));
|
Map<String, String> props = new HashMap<>();
|
||||||
}
|
|
||||||
|
|
||||||
private static Properties toProperties(String... properties) {
|
|
||||||
Properties props = new Properties();
|
|
||||||
assert properties.length % 2 == 0;
|
assert properties.length % 2 == 0;
|
||||||
for (int i = 0; i < properties.length; i += 2) {
|
for (int i = 0; i < properties.length; i += 2) {
|
||||||
props.setProperty(properties[i], properties[i+1]);
|
props.put(properties[i], properties[i+1]);
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new CoreDescriptor with a given name and instancedir
|
||||||
|
* @param container the CoreDescriptor's container
|
||||||
|
* @param name the CoreDescriptor's name
|
||||||
|
* @param instanceDir the CoreDescriptor's instancedir
|
||||||
|
*/
|
||||||
|
public CoreDescriptor(CoreContainer container, String name, Path instanceDir) {
|
||||||
|
this(container, name, instanceDir, Collections.emptyMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new CoreDescriptor using the properties of an existing one
|
||||||
|
* @param coreName the new CoreDescriptor's name
|
||||||
|
* @param other the CoreDescriptor to copy
|
||||||
|
*/
|
||||||
|
public CoreDescriptor(String coreName, CoreDescriptor other) {
|
||||||
|
this.coreContainer = other.coreContainer;
|
||||||
|
this.cloudDesc = other.cloudDesc;
|
||||||
|
this.instanceDir = other.instanceDir;
|
||||||
|
this.originalExtraProperties.putAll(other.originalExtraProperties);
|
||||||
|
this.originalCoreProperties.putAll(other.originalCoreProperties);
|
||||||
|
this.coreProperties.putAll(other.coreProperties);
|
||||||
|
this.substitutableProperties.putAll(other.substitutableProperties);
|
||||||
|
this.coreProperties.setProperty(CORE_NAME, coreName);
|
||||||
|
this.originalCoreProperties.setProperty(CORE_NAME, coreName);
|
||||||
|
this.substitutableProperties.setProperty(SOLR_CORE_PROP_PREFIX + CORE_NAME, coreName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CoreDescriptor.
|
* Create a new CoreDescriptor.
|
||||||
* @param container the CoreDescriptor's container
|
* @param container the CoreDescriptor's container
|
||||||
* @param name the CoreDescriptor's name
|
* @param name the CoreDescriptor's name
|
||||||
* @param instanceDir a String containing the instanceDir
|
* @param instanceDir a Path resolving to the instanceDir
|
||||||
* @param coreProps a Properties object of the properties for this core
|
* @param coreProps a Map of the properties for this core
|
||||||
* @param params additional params
|
|
||||||
*/
|
*/
|
||||||
public CoreDescriptor(CoreContainer container, String name, String instanceDir,
|
public CoreDescriptor(CoreContainer container, String name, Path instanceDir,
|
||||||
Properties coreProps, SolrParams params) {
|
Map<String, String> coreProps) {
|
||||||
|
|
||||||
this.coreContainer = container;
|
this.coreContainer = container;
|
||||||
|
this.instanceDir = instanceDir;
|
||||||
|
|
||||||
originalCoreProperties.setProperty(CORE_NAME, name);
|
originalCoreProperties.setProperty(CORE_NAME, name);
|
||||||
originalCoreProperties.setProperty(CORE_INSTDIR, instanceDir);
|
|
||||||
|
|
||||||
Properties containerProperties = container.getContainerProperties();
|
Properties containerProperties = container.getContainerProperties();
|
||||||
name = PropertiesUtil.substituteProperty(checkPropertyIsNotEmpty(name, CORE_NAME),
|
name = PropertiesUtil.substituteProperty(checkPropertyIsNotEmpty(name, CORE_NAME),
|
||||||
containerProperties);
|
containerProperties);
|
||||||
instanceDir = PropertiesUtil.substituteProperty(checkPropertyIsNotEmpty(instanceDir, CORE_INSTDIR),
|
|
||||||
containerProperties);
|
|
||||||
|
|
||||||
coreProperties.putAll(defaultProperties);
|
coreProperties.putAll(defaultProperties);
|
||||||
coreProperties.put(CORE_NAME, name);
|
coreProperties.put(CORE_NAME, name);
|
||||||
coreProperties.put(CORE_INSTDIR, instanceDir);
|
|
||||||
coreProperties.put(CORE_ABS_INSTDIR, convertToAbsolute(instanceDir, container.getCoreRootDirectory()));
|
|
||||||
|
|
||||||
for (String propname : coreProps.stringPropertyNames()) {
|
for (String propname : coreProps.keySet()) {
|
||||||
|
|
||||||
String propvalue = coreProps.getProperty(propname);
|
String propvalue = coreProps.get(propname);
|
||||||
|
|
||||||
if (isUserDefinedProperty(propname))
|
if (isUserDefinedProperty(propname))
|
||||||
originalExtraProperties.put(propname, propvalue);
|
originalExtraProperties.put(propname, propvalue);
|
||||||
|
@ -202,9 +212,6 @@ public class CoreDescriptor {
|
||||||
// TODO maybe make this a CloudCoreDescriptor subclass?
|
// TODO maybe make this a CloudCoreDescriptor subclass?
|
||||||
if (container.isZooKeeperAware()) {
|
if (container.isZooKeeperAware()) {
|
||||||
cloudDesc = new CloudDescriptor(name, coreProperties, this);
|
cloudDesc = new CloudDescriptor(name, coreProperties, this);
|
||||||
if (params != null) {
|
|
||||||
cloudDesc.setParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cloudDesc = null;
|
cloudDesc = null;
|
||||||
|
@ -226,20 +233,16 @@ public class CoreDescriptor {
|
||||||
*/
|
*/
|
||||||
protected void loadExtraProperties() {
|
protected void loadExtraProperties() {
|
||||||
String filename = coreProperties.getProperty(CORE_PROPERTIES, DEFAULT_EXTERNAL_PROPERTIES_FILE);
|
String filename = coreProperties.getProperty(CORE_PROPERTIES, DEFAULT_EXTERNAL_PROPERTIES_FILE);
|
||||||
File propertiesFile = resolvePaths(filename);
|
Path propertiesFile = instanceDir.resolve(filename);
|
||||||
if (propertiesFile.exists()) {
|
if (Files.exists(propertiesFile)) {
|
||||||
FileInputStream in = null;
|
try (InputStream is = Files.newInputStream(propertiesFile)) {
|
||||||
try {
|
|
||||||
in = new FileInputStream(propertiesFile);
|
|
||||||
Properties externalProps = new Properties();
|
Properties externalProps = new Properties();
|
||||||
externalProps.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
externalProps.load(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||||
coreProperties.putAll(externalProps);
|
coreProperties.putAll(externalProps);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String message = String.format(Locale.ROOT, "Could not load properties from %s: %s:",
|
String message = String.format(Locale.ROOT, "Could not load properties from %s: %s:",
|
||||||
propertiesFile.getAbsoluteFile(), e.toString());
|
propertiesFile.toString(), e.toString());
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, message);
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, message);
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(in);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,13 +261,6 @@ public class CoreDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File resolvePaths(String filepath) {
|
|
||||||
File file = new File(filepath);
|
|
||||||
if (file.isAbsolute())
|
|
||||||
return file;
|
|
||||||
return new File(getInstanceDir(), filepath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this property a Solr-standard property, or is it an extra property
|
* Is this property a Solr-standard property, or is it an extra property
|
||||||
* defined per-core by the user?
|
* defined per-core by the user?
|
||||||
|
@ -283,33 +279,6 @@ public class CoreDescriptor {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new CoreDescriptor with a given name and instancedir
|
|
||||||
* @param container the CoreDescriptor's container
|
|
||||||
* @param name the CoreDescriptor's name
|
|
||||||
* @param instanceDir the CoreDescriptor's instancedir
|
|
||||||
*/
|
|
||||||
public CoreDescriptor(CoreContainer container, String name, String instanceDir) {
|
|
||||||
this(container, name, instanceDir, new Properties());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new CoreDescriptor using the properties of an existing one
|
|
||||||
* @param coreName the new CoreDescriptor's name
|
|
||||||
* @param other the CoreDescriptor to copy
|
|
||||||
*/
|
|
||||||
public CoreDescriptor(String coreName, CoreDescriptor other) {
|
|
||||||
this.coreContainer = other.coreContainer;
|
|
||||||
this.cloudDesc = other.cloudDesc;
|
|
||||||
this.originalExtraProperties.putAll(other.originalExtraProperties);
|
|
||||||
this.originalCoreProperties.putAll(other.originalCoreProperties);
|
|
||||||
this.coreProperties.putAll(other.coreProperties);
|
|
||||||
this.substitutableProperties.putAll(other.substitutableProperties);
|
|
||||||
this.coreProperties.setProperty(CORE_NAME, coreName);
|
|
||||||
this.originalCoreProperties.setProperty(CORE_NAME, coreName);
|
|
||||||
this.substitutableProperties.setProperty(SOLR_CORE_PROP_PREFIX + CORE_NAME, coreName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPropertiesName() {
|
public String getPropertiesName() {
|
||||||
return coreProperties.getProperty(CORE_PROPERTIES);
|
return coreProperties.getProperty(CORE_PROPERTIES);
|
||||||
}
|
}
|
||||||
|
@ -322,22 +291,11 @@ public class CoreDescriptor {
|
||||||
return defaultProperties.get(CORE_DATADIR).equals(coreProperties.getProperty(CORE_DATADIR));
|
return defaultProperties.get(CORE_DATADIR).equals(coreProperties.getProperty(CORE_DATADIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@return the core instance directory. */
|
|
||||||
public String getRawInstanceDir() {
|
|
||||||
return coreProperties.getProperty(CORE_INSTDIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String convertToAbsolute(String instDir, String solrHome) {
|
|
||||||
checkNotNull(instDir);
|
|
||||||
return SolrResourceLoader.normalizeDir(Paths.get(solrHome).resolve(instDir).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the core instance directory
|
||||||
* @return the core instance directory, prepended with solr_home if not an absolute path.
|
|
||||||
*/
|
*/
|
||||||
public String getInstanceDir() {
|
public Path getInstanceDir() {
|
||||||
return coreProperties.getProperty(CORE_ABS_INSTDIR);
|
return instanceDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@return the core configuration resource name. */
|
/**@return the core configuration resource name. */
|
||||||
|
@ -401,12 +359,7 @@ public class CoreDescriptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder("CoreDescriptor[name=")
|
return "CoreDescriptor[name=" + this.getName() + ";instanceDir=" + this.getInstanceDir() + "]";
|
||||||
.append(this.getName())
|
|
||||||
.append(";instanceDir=")
|
|
||||||
.append(this.getInstanceDir())
|
|
||||||
.append("]")
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigSet() {
|
public String getConfigSet() {
|
||||||
|
|
|
@ -28,7 +28,9 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.SimpleFileVisitor;
|
import java.nio.file.SimpleFileVisitor;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -158,7 +160,11 @@ public class CorePropertiesLocator implements CoresLocator {
|
||||||
try (InputStream fis = Files.newInputStream(propertiesFile)) {
|
try (InputStream fis = Files.newInputStream(propertiesFile)) {
|
||||||
coreProperties.load(new InputStreamReader(fis, StandardCharsets.UTF_8));
|
coreProperties.load(new InputStreamReader(fis, StandardCharsets.UTF_8));
|
||||||
String name = createName(coreProperties, instanceDir);
|
String name = createName(coreProperties, instanceDir);
|
||||||
return new CoreDescriptor(cc, name, instanceDir.toString(), coreProperties);
|
Map<String, String> propMap = new HashMap<>();
|
||||||
|
for (String key : coreProperties.stringPropertyNames()) {
|
||||||
|
propMap.put(key, coreProperties.getProperty(key));
|
||||||
|
}
|
||||||
|
return new CoreDescriptor(cc, name, instanceDir, propMap);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
logger.error("Couldn't load core descriptor from {}:{}", propertiesFile, e.toString());
|
logger.error("Couldn't load core descriptor from {}:{}", propertiesFile, e.toString());
|
||||||
|
@ -175,9 +181,6 @@ public class CorePropertiesLocator implements CoresLocator {
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
p.putAll(cd.getPersistableStandardProperties());
|
p.putAll(cd.getPersistableStandardProperties());
|
||||||
p.putAll(cd.getPersistableUserProperties());
|
p.putAll(cd.getPersistableUserProperties());
|
||||||
// We don't persist the instance directory, as that's defined by the location
|
|
||||||
// of the properties file.
|
|
||||||
p.remove(CoreDescriptor.CORE_INSTDIR);
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,7 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
|
||||||
|
|
||||||
public String getDataHome(CoreDescriptor cd) throws IOException {
|
public String getDataHome(CoreDescriptor cd) throws IOException {
|
||||||
// by default, we go off the instance directory
|
// by default, we go off the instance directory
|
||||||
String instanceDir = new File(cd.getInstanceDir()).getAbsolutePath();
|
return cd.getInstanceDir().resolve(cd.getDataDir()).toAbsolutePath().toString();
|
||||||
return normalize(SolrResourceLoader.normalizeDir(instanceDir) + cd.getDataDir());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1006,10 +1006,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
||||||
private String initUpdateLogDir(CoreDescriptor coreDescriptor) {
|
private String initUpdateLogDir(CoreDescriptor coreDescriptor) {
|
||||||
String updateLogDir = coreDescriptor.getUlogDir();
|
String updateLogDir = coreDescriptor.getUlogDir();
|
||||||
if (updateLogDir == null) {
|
if (updateLogDir == null) {
|
||||||
updateLogDir = dataDir;
|
updateLogDir = coreDescriptor.getInstanceDir().resolve(dataDir).normalize().toAbsolutePath().toString();
|
||||||
if (new File(updateLogDir).isAbsolute() == false) {
|
|
||||||
updateLogDir = SolrResourceLoader.normalizeDir(coreDescriptor.getInstanceDir()) + updateLogDir;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return updateLogDir;
|
return updateLogDir;
|
||||||
}
|
}
|
||||||
|
@ -2492,12 +2489,11 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
||||||
public void postClose(SolrCore core) {
|
public void postClose(SolrCore core) {
|
||||||
CoreDescriptor cd = core.getCoreDescriptor();
|
CoreDescriptor cd = core.getCoreDescriptor();
|
||||||
if (cd != null) {
|
if (cd != null) {
|
||||||
File instanceDir = new File(cd.getInstanceDir());
|
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(instanceDir);
|
FileUtils.deleteDirectory(cd.getInstanceDir().toFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SolrException.log(log, "Failed to delete instance dir for core:"
|
SolrException.log(log, "Failed to delete instance dir for core:"
|
||||||
+ core.getName() + " dir:" + instanceDir.getAbsolutePath());
|
+ core.getName() + " dir:" + cd.getInstanceDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2516,12 +2512,11 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleteInstanceDir) {
|
if (deleteInstanceDir) {
|
||||||
File instanceDir = new File(cd.getInstanceDir());
|
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(instanceDir);
|
FileUtils.deleteDirectory(cd.getInstanceDir().toFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SolrException.log(log, "Failed to delete instance dir for unloaded core:" + cd.getName()
|
SolrException.log(log, "Failed to delete instance dir for unloaded core:" + cd.getName()
|
||||||
+ " dir:" + instanceDir.getAbsolutePath());
|
+ " dir:" + cd.getInstanceDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.solr.handler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -26,8 +25,6 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexCommit;
|
import org.apache.lucene.index.IndexCommit;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
@ -63,8 +60,7 @@ public class SnapShooter {
|
||||||
snapDir = core.getDataDir();
|
snapDir = core.getDataDir();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
File base = new File(core.getCoreDescriptor().getInstanceDir());
|
snapDir = core.getCoreDescriptor().getInstanceDir().resolve(location).normalize().toString();
|
||||||
snapDir = org.apache.solr.util.FileUtils.resolvePath(base, location).getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
this.snapshotName = snapshotName;
|
this.snapshotName = snapshotName;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,16 @@ package org.apache.solr.handler.admin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
@ -31,7 +40,6 @@ import org.apache.lucene.search.MatchAllDocsQuery;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.solr.cloud.CloudDescriptor;
|
import org.apache.solr.cloud.CloudDescriptor;
|
||||||
import org.apache.solr.cloud.Overseer;
|
|
||||||
import org.apache.solr.cloud.SyncStrategy;
|
import org.apache.solr.cloud.SyncStrategy;
|
||||||
import org.apache.solr.cloud.ZkController;
|
import org.apache.solr.cloud.ZkController;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
@ -71,6 +79,7 @@ import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||||
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
||||||
import org.apache.solr.util.DefaultSolrThreadFactory;
|
import org.apache.solr.util.DefaultSolrThreadFactory;
|
||||||
import org.apache.solr.util.NumberUtils;
|
import org.apache.solr.util.NumberUtils;
|
||||||
|
import org.apache.solr.util.PropertiesUtil;
|
||||||
import org.apache.solr.util.RefCounted;
|
import org.apache.solr.util.RefCounted;
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -547,37 +556,33 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
||||||
|
|
||||||
public static ImmutableMap<String, String> cloudParamToProp;
|
public static ImmutableMap<String, String> cloudParamToProp;
|
||||||
|
|
||||||
protected static CoreDescriptor buildCoreDescriptor(SolrParams params, CoreContainer container) {
|
protected static Map<String, String> buildCoreParams(SolrParams params) {
|
||||||
|
|
||||||
String name = checkNotEmpty(params.get(CoreAdminParams.NAME),
|
Map<String, String> coreParams = new HashMap<>();
|
||||||
"Missing parameter [" + CoreAdminParams.NAME + "]");
|
|
||||||
|
|
||||||
Properties coreProps = new Properties();
|
// standard core create parameters
|
||||||
for (String param : paramToProp.keySet()) {
|
for (String param : paramToProp.keySet()) {
|
||||||
String value = params.get(param, null);
|
String value = params.get(param, null);
|
||||||
if (StringUtils.isNotEmpty(value)) {
|
if (StringUtils.isNotEmpty(value)) {
|
||||||
coreProps.setProperty(paramToProp.get(param), value);
|
coreParams.put(paramToProp.get(param), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extra properties
|
||||||
Iterator<String> paramsIt = params.getParameterNamesIterator();
|
Iterator<String> paramsIt = params.getParameterNamesIterator();
|
||||||
while (paramsIt.hasNext()) {
|
while (paramsIt.hasNext()) {
|
||||||
String param = paramsIt.next();
|
String param = paramsIt.next();
|
||||||
if (!param.startsWith(CoreAdminParams.PROPERTY_PREFIX))
|
if (param.startsWith(CoreAdminParams.PROPERTY_PREFIX)) {
|
||||||
continue;
|
String propName = param.substring(CoreAdminParams.PROPERTY_PREFIX.length());
|
||||||
String propName = param.substring(CoreAdminParams.PROPERTY_PREFIX.length());
|
String propValue = params.get(param);
|
||||||
String propValue = params.get(param);
|
coreParams.put(propName, propValue);
|
||||||
coreProps.setProperty(propName, propValue);
|
}
|
||||||
|
if (param.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) {
|
||||||
|
coreParams.put(param, params.get(param));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
|
return coreParams;
|
||||||
if (StringUtils.isEmpty(instancedir) && coreProps.getProperty(CoreAdminParams.INSTANCE_DIR) != null) {
|
|
||||||
instancedir = coreProps.getProperty(CoreAdminParams.INSTANCE_DIR);
|
|
||||||
} else if (StringUtils.isEmpty(instancedir)){
|
|
||||||
instancedir = name; // will be resolved later against solr.home
|
|
||||||
//instancedir = container.getSolrHome() + "/" + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CoreDescriptor(container, name, instancedir, coreProps, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String checkNotEmpty(String value, String message) {
|
private static String checkNotEmpty(String value, String message) {
|
||||||
|
@ -595,88 +600,23 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
||||||
|
|
||||||
SolrParams params = req.getParams();
|
SolrParams params = req.getParams();
|
||||||
log.info("core create command {}", params);
|
log.info("core create command {}", params);
|
||||||
CoreDescriptor dcore = buildCoreDescriptor(params, coreContainer);
|
String coreName = params.required().get(CoreAdminParams.NAME);
|
||||||
|
Map<String, String> coreParams = buildCoreParams(params);
|
||||||
|
|
||||||
if (coreContainer.getAllCoreNames().contains(dcore.getName())) {
|
Path instancePath = coreContainer.getCoreRootDirectory().resolve(coreName);
|
||||||
log.warn("Creating a core with existing name is not allowed");
|
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
// TODO: Should we nuke setting odd instance paths? They break core discovery, generally
|
||||||
"Core with name '" + dcore.getName() + "' already exists.");
|
String instanceDir = req.getParams().get(CoreAdminParams.INSTANCE_DIR);
|
||||||
|
if (instanceDir == null)
|
||||||
|
instanceDir = req.getParams().get("property.instanceDir");
|
||||||
|
if (instanceDir != null) {
|
||||||
|
instanceDir = PropertiesUtil.substituteProperty(instanceDir, coreContainer.getContainerProperties());
|
||||||
|
instancePath = coreContainer.getCoreRootDirectory().resolve(instanceDir).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO this should be moved into CoreContainer, really...
|
coreContainer.create(coreName, instancePath, coreParams);
|
||||||
boolean preExisitingZkEntry = false;
|
|
||||||
try {
|
|
||||||
if (coreContainer.getZkController() != null) {
|
|
||||||
if (!Overseer.isLegacy(coreContainer.getZkController().getZkStateReader().getClusterProps())) {
|
|
||||||
if (dcore.getCloudDescriptor().getCoreNodeName() == null) {
|
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
|
||||||
"non legacy mode coreNodeName missing " + params);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
preExisitingZkEntry = checkIfCoreNodeNameAlreadyExists(dcore);
|
|
||||||
|
|
||||||
}
|
rsp.add("core", coreName);
|
||||||
|
|
||||||
SolrCore core = coreContainer.create(dcore);
|
|
||||||
|
|
||||||
// only write out the descriptor if the core is successfully created
|
|
||||||
coreContainer.getCoresLocator().create(coreContainer, dcore);
|
|
||||||
|
|
||||||
rsp.add("core", core.getName());
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
if (coreContainer.isZooKeeperAware() && dcore != null && !preExisitingZkEntry) {
|
|
||||||
try {
|
|
||||||
coreContainer.getZkController().unregister(dcore.getName(), dcore);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
SolrException.log(log, null, e);
|
|
||||||
} catch (KeeperException e) {
|
|
||||||
SolrException.log(log, null, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Throwable tc = ex;
|
|
||||||
Throwable c = null;
|
|
||||||
do {
|
|
||||||
tc = tc.getCause();
|
|
||||||
if (tc != null) {
|
|
||||||
c = tc;
|
|
||||||
}
|
|
||||||
} while (tc != null);
|
|
||||||
|
|
||||||
String rootMsg = "";
|
|
||||||
if (c != null) {
|
|
||||||
rootMsg = " Caused by: " + c.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
|
||||||
"Error CREATEing SolrCore '" + dcore.getName() + "': " +
|
|
||||||
ex.getMessage() + rootMsg, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) {
|
|
||||||
ZkStateReader zkStateReader = coreContainer.getZkController()
|
|
||||||
.getZkStateReader();
|
|
||||||
DocCollection collection = zkStateReader.getClusterState().getCollectionOrNull(dcore.getCollectionName());
|
|
||||||
if (collection != null) {
|
|
||||||
Collection<Slice> slices = collection.getSlices();
|
|
||||||
|
|
||||||
for (Slice slice : slices) {
|
|
||||||
Collection<Replica> replicas = slice.getReplicas();
|
|
||||||
for (Replica replica : replicas) {
|
|
||||||
if (replica.getName().equals(
|
|
||||||
dcore.getCloudDescriptor().getCoreNodeName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,9 +20,9 @@ package org.apache.solr;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
|
@ -49,15 +49,8 @@ public class TestCrossCoreJoin extends SolrTestCaseJ4 {
|
||||||
// FileUtils.copyDirectory(getFile("solrj/solr"), testHome);
|
// FileUtils.copyDirectory(getFile("solrj/solr"), testHome);
|
||||||
initCore("solrconfig.xml", "schema12.xml", TEST_HOME(), "collection1");
|
initCore("solrconfig.xml", "schema12.xml", TEST_HOME(), "collection1");
|
||||||
final CoreContainer coreContainer = h.getCoreContainer();
|
final CoreContainer coreContainer = h.getCoreContainer();
|
||||||
final CoreDescriptor toCoreDescriptor = coreContainer.getCoreDescriptor("collection1");
|
|
||||||
final CoreDescriptor fromCoreDescriptor = new CoreDescriptor("fromCore", toCoreDescriptor) {
|
|
||||||
@Override
|
|
||||||
public String getSchemaName() {
|
|
||||||
return "schema.xml";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fromCore = coreContainer.create(fromCoreDescriptor);
|
fromCore = coreContainer.create("fromCore", ImmutableMap.of("configSet", "minimal"));
|
||||||
|
|
||||||
assertU(add(doc("id", "1", "name", "john", "title", "Director", "dept_s", "Engineering")));
|
assertU(add(doc("id", "1", "name", "john", "title", "Director", "dept_s", "Engineering")));
|
||||||
assertU(add(doc("id", "2", "name", "mark", "title", "VP", "dept_s", "Marketing")));
|
assertU(add(doc("id", "2", "name", "mark", "title", "VP", "dept_s", "Marketing")));
|
||||||
|
@ -108,15 +101,17 @@ public class TestCrossCoreJoin extends SolrTestCaseJ4 {
|
||||||
@Test
|
@Test
|
||||||
public void testCoresAreDifferent() throws Exception {
|
public void testCoresAreDifferent() throws Exception {
|
||||||
assertQEx("schema12.xml" + " has no \"cat\" field", req("cat:*"), ErrorCode.BAD_REQUEST);
|
assertQEx("schema12.xml" + " has no \"cat\" field", req("cat:*"), ErrorCode.BAD_REQUEST);
|
||||||
final LocalSolrQueryRequest req = new LocalSolrQueryRequest(fromCore, "cat:*", "lucene", 0, 100, Collections.emptyMap());
|
final LocalSolrQueryRequest req = new LocalSolrQueryRequest(fromCore, "cat:*", "/select", 0, 100, Collections.emptyMap());
|
||||||
final String resp = query(fromCore, req);
|
final String resp = query(fromCore, req);
|
||||||
assertTrue(resp, resp.contains("numFound=\"1\""));
|
assertTrue(resp, resp.contains("numFound=\"1\""));
|
||||||
assertTrue(resp, resp.contains("<int name=\"id\">10</int>"));
|
assertTrue(resp, resp.contains("<str name=\"id\">10</str>"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String query(SolrCore core, SolrQueryRequest req) throws Exception {
|
public String query(SolrCore core, SolrQueryRequest req) throws Exception {
|
||||||
String handler = "standard";
|
String handler = "standard";
|
||||||
|
if (req.getParams().get("qt") != null)
|
||||||
|
handler = req.getParams().get("qt");
|
||||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||||
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
|
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
|
||||||
core.execute(core.getRequestHandler(handler), req, rsp);
|
core.execute(core.getRequestHandler(handler), req, rsp);
|
||||||
|
|
|
@ -17,6 +17,13 @@ package org.apache.solr.cloud;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.apache.solr.common.cloud.ClusterState;
|
import org.apache.solr.common.cloud.ClusterState;
|
||||||
|
@ -27,8 +34,6 @@ import org.apache.solr.common.cloud.ZkNodeProps;
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
import org.apache.solr.common.cloud.ZkStateReader;
|
||||||
import org.apache.solr.common.util.Utils;
|
import org.apache.solr.common.util.Utils;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
|
||||||
import org.apache.solr.core.SolrCore;
|
|
||||||
import org.apache.zookeeper.CreateMode;
|
import org.apache.zookeeper.CreateMode;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -36,12 +41,6 @@ import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Slow
|
@Slow
|
||||||
public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
|
public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
|
||||||
protected static Logger log = LoggerFactory
|
protected static Logger log = LoggerFactory
|
||||||
|
@ -157,10 +156,7 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
|
||||||
CreateMode.PERSISTENT, true);
|
CreateMode.PERSISTENT, true);
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
|
|
||||||
CoreDescriptor dcore = buildCoreDescriptor(container1, "testcore", "testcore")
|
container1.create("testcore", ImmutableMap.of("dataDir", dataDir4.getAbsolutePath()));
|
||||||
.withDataDir(dataDir4.getAbsolutePath()).build();
|
|
||||||
|
|
||||||
SolrCore core = container1.create(dcore);
|
|
||||||
|
|
||||||
ZkController zkController2 = container2.getZkController();
|
ZkController zkController2 = container2.getZkController();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,17 @@ package org.apache.solr.cloud;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.StringUtils;
|
import org.apache.commons.codec.binary.StringUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
@ -37,17 +48,6 @@ import org.apache.solr.util.TimeOut;
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static org.apache.solr.cloud.ReplicaPropertiesBase.verifyUniqueAcrossCollection;
|
import static org.apache.solr.cloud.ReplicaPropertiesBase.verifyUniqueAcrossCollection;
|
||||||
|
|
||||||
@LuceneTestCase.Slow
|
@LuceneTestCase.Slow
|
||||||
|
@ -232,12 +232,10 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
|
||||||
String collectionName = "solrj_test_core_props";
|
String collectionName = "solrj_test_core_props";
|
||||||
|
|
||||||
File tmpDir = createTempDir("testPropertyParamsForCreate").toFile();
|
File tmpDir = createTempDir("testPropertyParamsForCreate").toFile();
|
||||||
File instanceDir = new File(tmpDir, "instanceDir-" + TestUtil.randomSimpleString(random(), 1, 5));
|
|
||||||
File dataDir = new File(tmpDir, "dataDir-" + TestUtil.randomSimpleString(random(), 1, 5));
|
File dataDir = new File(tmpDir, "dataDir-" + TestUtil.randomSimpleString(random(), 1, 5));
|
||||||
File ulogDir = new File(tmpDir, "ulogDir-" + TestUtil.randomSimpleString(random(), 1, 5));
|
File ulogDir = new File(tmpDir, "ulogDir-" + TestUtil.randomSimpleString(random(), 1, 5));
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.put(CoreAdminParams.INSTANCE_DIR, instanceDir.getAbsolutePath());
|
|
||||||
properties.put(CoreAdminParams.DATA_DIR, dataDir.getAbsolutePath());
|
properties.put(CoreAdminParams.DATA_DIR, dataDir.getAbsolutePath());
|
||||||
properties.put(CoreAdminParams.ULOG_DIR, ulogDir.getAbsolutePath());
|
properties.put(CoreAdminParams.ULOG_DIR, ulogDir.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -262,9 +260,6 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
|
||||||
CoreAdminResponse status = CoreAdminRequest.getStatus(replica1.getStr("core"), client);
|
CoreAdminResponse status = CoreAdminRequest.getStatus(replica1.getStr("core"), client);
|
||||||
NamedList<Object> coreStatus = status.getCoreStatus(replica1.getStr("core"));
|
NamedList<Object> coreStatus = status.getCoreStatus(replica1.getStr("core"));
|
||||||
String dataDirStr = (String) coreStatus.get("dataDir");
|
String dataDirStr = (String) coreStatus.get("dataDir");
|
||||||
String instanceDirStr = (String) coreStatus.get("instanceDir");
|
|
||||||
assertEquals("Instance dir does not match param passed in property.instanceDir syntax",
|
|
||||||
new File(instanceDirStr).getAbsolutePath(), instanceDir.getAbsolutePath());
|
|
||||||
assertEquals("Data dir does not match param given in property.dataDir syntax",
|
assertEquals("Data dir does not match param given in property.dataDir syntax",
|
||||||
new File(dataDirStr).getAbsolutePath(), dataDir.getAbsolutePath());
|
new File(dataDirStr).getAbsolutePath(), dataDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,23 +17,10 @@ package org.apache.solr.cloud;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
|
||||||
import org.apache.solr.common.cloud.SolrZkClient;
|
|
||||||
import org.apache.solr.common.cloud.ZkNodeProps;
|
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
|
||||||
import org.apache.solr.core.CoreContainer;
|
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,6 +29,21 @@ import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||||
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
|
import org.apache.solr.common.cloud.SolrZkClient;
|
||||||
|
import org.apache.solr.common.cloud.ZkNodeProps;
|
||||||
|
import org.apache.solr.common.cloud.ZkStateReader;
|
||||||
|
import org.apache.solr.core.CoreContainer;
|
||||||
|
import org.apache.solr.core.SolrResourceLoader;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
@Slow
|
@Slow
|
||||||
public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
||||||
protected static Logger log = LoggerFactory
|
protected static Logger log = LoggerFactory
|
||||||
|
@ -133,11 +135,11 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
private void setupContainer(int port, String shard) throws IOException,
|
private void setupContainer(int port, String shard) throws IOException,
|
||||||
ParserConfigurationException, SAXException {
|
ParserConfigurationException, SAXException {
|
||||||
File data = createTempDir().toFile();
|
Path data = createTempDir();
|
||||||
|
|
||||||
System.setProperty("hostPort", Integer.toString(port));
|
System.setProperty("hostPort", Integer.toString(port));
|
||||||
System.setProperty("shard", shard);
|
System.setProperty("shard", shard);
|
||||||
System.setProperty("solr.data.dir", data.getAbsolutePath());
|
System.setProperty("solr.data.dir", data.toString());
|
||||||
System.setProperty("solr.solr.home", TEST_HOME());
|
System.setProperty("solr.solr.home", TEST_HOME());
|
||||||
Set<Integer> ports = shardPorts.get(shard);
|
Set<Integer> ports = shardPorts.get(shard);
|
||||||
if (ports == null) {
|
if (ports == null) {
|
||||||
|
@ -145,9 +147,12 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
||||||
shardPorts.put(shard, ports);
|
shardPorts.put(shard, ports);
|
||||||
}
|
}
|
||||||
ports.add(port);
|
ports.add(port);
|
||||||
CoreContainer container = new CoreContainer();
|
|
||||||
|
SolrResourceLoader loader = new SolrResourceLoader(createTempDir());
|
||||||
|
Files.copy(TEST_PATH().resolve("solr.xml"), loader.getInstancePath().resolve("solr.xml"));
|
||||||
|
CoreContainer container = new CoreContainer(loader);
|
||||||
container.load();
|
container.load();
|
||||||
container.create(new CoreDescriptor(container, "collection1", "collection1", "collection", "collection1"));
|
container.create("collection1_" + shard, ImmutableMap.of("collection", "collection1"));
|
||||||
containerMap.put(port, container);
|
containerMap.put(port, container);
|
||||||
System.clearProperty("solr.solr.home");
|
System.clearProperty("solr.solr.home");
|
||||||
System.clearProperty("hostPort");
|
System.clearProperty("hostPort");
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -76,8 +77,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
|
||||||
container = setupContainer(TEST_PATH().resolve("configsets").toString());
|
container = setupContainer(TEST_PATH().resolve("configsets").toString());
|
||||||
Path testDirectory = container.getResourceLoader().getInstancePath();
|
Path testDirectory = container.getResourceLoader().getInstancePath();
|
||||||
|
|
||||||
SolrCore core1 = container.create(new CoreDescriptor(container, "core1", testDirectory.resolve("core1").toString(),
|
SolrCore core1 = container.create("core1", ImmutableMap.of("configSet", "configset-2"));
|
||||||
"configSet", "configset-2"));
|
|
||||||
assertThat(core1.getCoreDescriptor().getName(), is("core1"));
|
assertThat(core1.getCoreDescriptor().getName(), is("core1"));
|
||||||
assertThat(Paths.get(core1.getDataDir()).toString(), is(testDirectory.resolve("core1").resolve("data").toString()));
|
assertThat(Paths.get(core1.getDataDir()).toString(), is(testDirectory.resolve("core1").resolve("data").toString()));
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
|
||||||
container = setupContainer(getFile("solr/configsets").getAbsolutePath());
|
container = setupContainer(getFile("solr/configsets").getAbsolutePath());
|
||||||
Path testDirectory = container.getResourceLoader().getInstancePath();
|
Path testDirectory = container.getResourceLoader().getInstancePath();
|
||||||
|
|
||||||
container.create(new CoreDescriptor(container, "core1", testDirectory.resolve("core1").toString(), "configSet", "nonexistent"));
|
container.create("core1", ImmutableMap.of("configSet", "nonexistent"));
|
||||||
fail("Expected core creation to fail");
|
fail("Expected core creation to fail");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -122,12 +122,12 @@ public class TestConfigSets extends SolrTestCaseJ4 {
|
||||||
CoreContainer container = new CoreContainer(SolrXmlConfig.fromString(loader, solrxml));
|
CoreContainer container = new CoreContainer(SolrXmlConfig.fromString(loader, solrxml));
|
||||||
container.load();
|
container.load();
|
||||||
|
|
||||||
// We initially don't have a /get handler defined
|
// We initially don't have a /dump handler defined
|
||||||
SolrCore core = container.create(new CoreDescriptor(container, "core1", testDirectory + "/core", "configSet", "configset-2"));
|
SolrCore core = container.create("core1", ImmutableMap.of("configSet", "configset-2"));
|
||||||
assertThat("No /dump handler should be defined in the initial configuration",
|
assertThat("No /dump handler should be defined in the initial configuration",
|
||||||
core.getRequestHandler("/dump"), is(nullValue()));
|
core.getRequestHandler("/dump"), is(nullValue()));
|
||||||
|
|
||||||
// Now copy in a config with a /get handler and reload
|
// Now copy in a config with a /dump handler and reload
|
||||||
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-withgethandler.xml"),
|
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-withgethandler.xml"),
|
||||||
new File(new File(configSetsDir, "configset-2/conf"), "solrconfig.xml"));
|
new File(new File(configSetsDir, "configset-2/conf"), "solrconfig.xml"));
|
||||||
container.reload("core1");
|
container.reload("core1");
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
|
@ -88,11 +90,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
CoreContainer cores = init(CONFIGSETS_SOLR_XML);
|
CoreContainer cores = init(CONFIGSETS_SOLR_XML);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1", "configSet", "minimal");
|
SolrCore core1 = cores.create("core1", ImmutableMap.of("configSet", "minimal"));
|
||||||
SolrCore core1 = cores.create(descriptor1);
|
SolrCore core2 = cores.create("core2", ImmutableMap.of("configSet", "minimal"));
|
||||||
|
|
||||||
CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1", "configSet", "minimal");
|
|
||||||
SolrCore core2 = cores.create(descriptor2);
|
|
||||||
|
|
||||||
assertSame(core1.getLatestSchema(), core2.getLatestSchema());
|
assertSame(core1.getLatestSchema(), core2.getLatestSchema());
|
||||||
|
|
||||||
|
@ -105,9 +104,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
@Test
|
@Test
|
||||||
public void testReloadSequential() throws Exception {
|
public void testReloadSequential() throws Exception {
|
||||||
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
|
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
|
||||||
CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
|
|
||||||
cc.create(descriptor1);
|
|
||||||
try {
|
try {
|
||||||
|
cc.create("core1", ImmutableMap.of("configSet", "minimal"));
|
||||||
cc.reload("core1");
|
cc.reload("core1");
|
||||||
cc.reload("core1");
|
cc.reload("core1");
|
||||||
cc.reload("core1");
|
cc.reload("core1");
|
||||||
|
@ -121,8 +119,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
@Test
|
@Test
|
||||||
public void testReloadThreaded() throws Exception {
|
public void testReloadThreaded() throws Exception {
|
||||||
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
|
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
|
||||||
CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
|
cc.create("core1", ImmutableMap.of("configSet", "minimal"));
|
||||||
cc.create(descriptor1);
|
|
||||||
|
|
||||||
class TestThread extends Thread {
|
class TestThread extends Thread {
|
||||||
@Override
|
@Override
|
||||||
|
@ -159,8 +156,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
assertEquals("There should not be cores", 0, cores.getCores().size());
|
assertEquals("There should not be cores", 0, cores.getCores().size());
|
||||||
|
|
||||||
//add a new core
|
//add a new core
|
||||||
CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", "collection1", CoreDescriptor.CORE_CONFIGSET, "minimal");
|
cores.create("core1", ImmutableMap.of("configSet", "minimal"));
|
||||||
SolrCore newCore = cores.create(coreDescriptor);
|
|
||||||
|
|
||||||
//assert one registered core
|
//assert one registered core
|
||||||
|
|
||||||
|
@ -218,7 +214,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
||||||
|
|
||||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
||||||
CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", "badcore", "configSet", "nosuchconfigset");
|
Path corePath = resourceLoader.getInstancePath().resolve("badcore");
|
||||||
|
CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", corePath, "configSet", "nosuchconfigset");
|
||||||
cl.add(badcore);
|
cl.add(badcore);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -229,7 +226,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
assertThat(cc.getCoreInitFailures().size(), is(0));
|
assertThat(cc.getCoreInitFailures().size(), is(0));
|
||||||
|
|
||||||
// can we create the core now with a good config?
|
// can we create the core now with a good config?
|
||||||
SolrCore core = cc.create(new CoreDescriptor(cc, "badcore", "badcore", "configSet", "minimal"));
|
SolrCore core = cc.create("badcore", ImmutableMap.of("configSet", "minimal"));
|
||||||
assertThat(core, not(nullValue()));
|
assertThat(core, not(nullValue()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -246,8 +243,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
|
||||||
assertSame(contextLoader, sharedLoader.getParent());
|
assertSame(contextLoader, sharedLoader.getParent());
|
||||||
|
|
||||||
CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
|
SolrCore core1 = cc.create("core1", ImmutableMap.of("configSet", "minimal"));
|
||||||
SolrCore core1 = cc.create(descriptor1);
|
|
||||||
ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
|
ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
|
||||||
assertSame(sharedLoader, coreLoader.getParent());
|
assertSame(sharedLoader, coreLoader.getParent());
|
||||||
|
|
||||||
|
@ -413,15 +409,15 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
assertEquals("wrong number of core failures", 0, failures.size());
|
assertEquals("wrong number of core failures", 0, failures.size());
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// try to add a collection with a path that doesn't exist
|
// try to add a collection with a configset that doesn't exist
|
||||||
final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
|
|
||||||
try {
|
try {
|
||||||
ignoreException(Pattern.quote("bogus_path"));
|
ignoreException(Pattern.quote("bogus_path"));
|
||||||
cc.create(bogus);
|
cc.create("bogus", ImmutableMap.of("configSet", "bogus_path"));
|
||||||
fail("bogus inst dir failed to trigger exception from create");
|
fail("bogus inst dir failed to trigger exception from create");
|
||||||
} catch (SolrException e) {
|
} catch (SolrException e) {
|
||||||
assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
|
Throwable cause = Throwables.getRootCause(e);
|
||||||
0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
|
assertTrue("init exception doesn't mention bogus dir: " + cause.getMessage(),
|
||||||
|
0 < cause.getMessage().indexOf("bogus_path"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,8 +432,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
assertEquals("wrong number of core failures", 1, failures.size());
|
assertEquals("wrong number of core failures", 1, failures.size());
|
||||||
fail = failures.get("bogus").exception;
|
fail = failures.get("bogus").exception;
|
||||||
assertNotNull("null failure for test core", fail);
|
assertNotNull("null failure for test core", fail);
|
||||||
assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
|
assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
|
||||||
0 < fail.getCause().getMessage().indexOf("bogus_path"));
|
0 < fail.getMessage().indexOf("bogus_path"));
|
||||||
|
|
||||||
// check that we get null accessing a non-existent core
|
// check that we get null accessing a non-existent core
|
||||||
assertNull(cc.getCore("does_not_exist"));
|
assertNull(cc.getCore("does_not_exist"));
|
||||||
|
@ -447,8 +443,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
fail("Failed to get Exception on accessing core with init failure");
|
fail("Failed to get Exception on accessing core with init failure");
|
||||||
} catch (SolrException ex) {
|
} catch (SolrException ex) {
|
||||||
assertEquals(500, ex.code());
|
assertEquals(500, ex.code());
|
||||||
// double wrapped
|
String cause = Throwables.getRootCause(ex).getMessage();
|
||||||
String cause = ex.getCause().getCause().getMessage();
|
|
||||||
assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
|
assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
|
||||||
0 < cause.indexOf("bogus_path"));
|
0 < cause.indexOf("bogus_path"));
|
||||||
|
|
||||||
|
@ -474,8 +469,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
||||||
|
|
||||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
||||||
cl.add(new CoreDescriptor(cc, "col_ok", "col_ok", "configSet", "minimal"));
|
cl.add(new CoreDescriptor(cc, "col_ok", resourceLoader.getInstancePath().resolve("col_ok"), "configSet", "minimal"));
|
||||||
cl.add(new CoreDescriptor(cc, "col_bad", "col_bad", "configSet", "bad-mergepolicy"));
|
cl.add(new CoreDescriptor(cc, "col_bad", resourceLoader.getInstancePath().resolve("col_bad"), "configSet", "bad-mergepolicy"));
|
||||||
cc.load();
|
cc.load();
|
||||||
|
|
||||||
// check that we have the cores we expect
|
// check that we have the cores we expect
|
||||||
|
@ -513,8 +508,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
|
FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
|
||||||
FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
|
FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
|
||||||
FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
|
FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
|
||||||
final CoreDescriptor fixed = new CoreDescriptor(cc, "col_bad", "col_bad");
|
cc.create("col_bad", ImmutableMap.of());
|
||||||
cc.create(fixed);
|
|
||||||
|
|
||||||
// check that we have the cores we expect
|
// check that we have the cores we expect
|
||||||
cores = cc.getCoreNames();
|
cores = cc.getCoreNames();
|
||||||
|
@ -531,10 +525,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// try to add a collection with a path that doesn't exist
|
// try to add a collection with a path that doesn't exist
|
||||||
final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
|
|
||||||
try {
|
try {
|
||||||
ignoreException(Pattern.quote("bogus_path"));
|
ignoreException(Pattern.quote("bogus_path"));
|
||||||
cc.create(bogus);
|
cc.create("bogus", ImmutableMap.of("configSet", "bogus_path"));
|
||||||
fail("bogus inst dir failed to trigger exception from create");
|
fail("bogus inst dir failed to trigger exception from create");
|
||||||
} catch (SolrException e) {
|
} catch (SolrException e) {
|
||||||
assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
|
assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
|
||||||
|
@ -555,8 +548,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
assertEquals("wrong number of core failures", 1, failures.size());
|
assertEquals("wrong number of core failures", 1, failures.size());
|
||||||
fail = failures.get("bogus").exception;
|
fail = failures.get("bogus").exception;
|
||||||
assertNotNull("null failure for test core", fail);
|
assertNotNull("null failure for test core", fail);
|
||||||
assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
|
assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
|
||||||
0 < fail.getCause().getMessage().indexOf("bogus_path"));
|
0 < fail.getMessage().indexOf("bogus_path"));
|
||||||
|
|
||||||
// check that we get null accessing a non-existent core
|
// check that we get null accessing a non-existent core
|
||||||
assertNull(cc.getCore("does_not_exist"));
|
assertNull(cc.getCore("does_not_exist"));
|
||||||
|
@ -567,7 +560,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
} catch (SolrException ex) {
|
} catch (SolrException ex) {
|
||||||
assertEquals(500, ex.code());
|
assertEquals(500, ex.code());
|
||||||
// double wrapped
|
// double wrapped
|
||||||
String cause = ex.getCause().getCause().getMessage();
|
String cause = ex.getCause().getMessage();
|
||||||
assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
|
assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
|
||||||
0 < cause.indexOf("bogus_path"));
|
0 < cause.indexOf("bogus_path"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
|
@ -68,7 +69,6 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
|
||||||
props.put(CoreDescriptor.CORE_TRANSIENT, Boolean.toString(isLazy));
|
props.put(CoreDescriptor.CORE_TRANSIENT, Boolean.toString(isLazy));
|
||||||
props.put(CoreDescriptor.CORE_LOADONSTARTUP, Boolean.toString(loadOnStartup));
|
props.put(CoreDescriptor.CORE_LOADONSTARTUP, Boolean.toString(loadOnStartup));
|
||||||
props.put(CoreDescriptor.CORE_DATADIR, "${core.dataDir:stuffandnonsense}");
|
props.put(CoreDescriptor.CORE_DATADIR, "${core.dataDir:stuffandnonsense}");
|
||||||
props.put(CoreDescriptor.CORE_INSTDIR, "totallybogus"); // For testing that this property is ignored if present.
|
|
||||||
|
|
||||||
for (String extra : extraProps) {
|
for (String extra : extraProps) {
|
||||||
String[] parts = extra.split("=");
|
String[] parts = extra.split("=");
|
||||||
|
@ -155,9 +155,6 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
|
||||||
// This is too long and ugly to put in. Besides, it varies.
|
// This is too long and ugly to put in. Besides, it varies.
|
||||||
assertNotNull(desc.getInstanceDir());
|
assertNotNull(desc.getInstanceDir());
|
||||||
|
|
||||||
// Prove we're ignoring this even though it's set in the properties file
|
|
||||||
assertFalse("InstanceDir should be ignored", desc.getInstanceDir().contains("totallybogus"));
|
|
||||||
|
|
||||||
assertEquals("core1", desc.getDataDir());
|
assertEquals("core1", desc.getDataDir());
|
||||||
assertEquals("solrconfig-minimal.xml", desc.getConfigName());
|
assertEquals("solrconfig-minimal.xml", desc.getConfigName());
|
||||||
assertEquals("schema-tiny.xml", desc.getSchemaName());
|
assertEquals("schema-tiny.xml", desc.getSchemaName());
|
||||||
|
@ -302,8 +299,8 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
assertNull(cc.getCore("core0"));
|
assertNull(cc.getCore("core0"));
|
||||||
|
|
||||||
SolrCore core3 = cc.create(new CoreDescriptor(cc, "core3", "core3", "configSet", "minimal"));
|
SolrCore core3 = cc.create("core3", ImmutableMap.of("configSet", "minimal"));
|
||||||
assertThat(core3.getCoreDescriptor().getInstanceDir(), containsString("relative"));
|
assertThat(core3.getCoreDescriptor().getInstanceDir().toAbsolutePath().toString(), containsString("relative"));
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
cc.shutdown();
|
cc.shutdown();
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
private File solrHomeDirectory;
|
private File solrHomeDirectory;
|
||||||
|
|
||||||
private static CoreDescriptor makeCoreDescriptor(CoreContainer cc, String coreName, String instanceDir, String isTransient, String loadOnStartup) {
|
private static CoreDescriptor makeCoreDescriptor(CoreContainer cc, String coreName, String isTransient, String loadOnStartup) {
|
||||||
return new CoreDescriptor(cc, coreName, instanceDir,
|
return new CoreDescriptor(cc, coreName, cc.getCoreRootDirectory().resolve(coreName),
|
||||||
CoreDescriptor.CORE_TRANSIENT, isTransient,
|
CoreDescriptor.CORE_TRANSIENT, isTransient,
|
||||||
CoreDescriptor.CORE_LOADONSTARTUP, loadOnStartup);
|
CoreDescriptor.CORE_LOADONSTARTUP, loadOnStartup);
|
||||||
}
|
}
|
||||||
|
@ -59,15 +59,15 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
@Override
|
@Override
|
||||||
public List<CoreDescriptor> discover(CoreContainer cc) {
|
public List<CoreDescriptor> discover(CoreContainer cc) {
|
||||||
return ImmutableList.of(
|
return ImmutableList.of(
|
||||||
new CoreDescriptor(cc, "collection1", "collection1"),
|
makeCoreDescriptor(cc, "collection1", "false", "true"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy2", "collection2", "true", "true"),
|
makeCoreDescriptor(cc, "collection2", "true", "true"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy3", "collection3", "on", "false"),
|
makeCoreDescriptor(cc, "collection3", "on", "false"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy4", "collection4", "false", "false"),
|
makeCoreDescriptor(cc, "collection4", "false", "false"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy5", "collection5", "false", "true"),
|
makeCoreDescriptor(cc, "collection5", "false", "true"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy6", "collection6", "true", "false"),
|
makeCoreDescriptor(cc, "collection6", "true", "false"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy7", "collection7", "true", "false"),
|
makeCoreDescriptor(cc, "collection7", "true", "false"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy8", "collection8", "true", "false"),
|
makeCoreDescriptor(cc, "collection8", "true", "false"),
|
||||||
makeCoreDescriptor(cc, "collectionLazy9", "collection9", "true", "false")
|
makeCoreDescriptor(cc, "collection9", "true", "false")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -91,28 +91,28 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// NOTE: This checks the initial state for loading, no need to do this elsewhere.
|
// NOTE: This checks the initial state for loading, no need to do this elsewhere.
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy5");
|
checkInCores(cc, "collection1", "collection2", "collection5");
|
||||||
checkNotInCores(cc, "collectionLazy3", "collectionLazy4", "collectionLazy6", "collectionLazy7",
|
checkNotInCores(cc, "collection3", "collection4", "collection6", "collection7",
|
||||||
"collectionLazy8", "collectionLazy9");
|
"collection8", "collection9");
|
||||||
|
|
||||||
SolrCore core1 = cc.getCore("collection1");
|
SolrCore core1 = cc.getCore("collection1");
|
||||||
assertFalse("core1 should not be transient", core1.getCoreDescriptor().isTransient());
|
assertFalse("core1 should not be transient", core1.getCoreDescriptor().isTransient());
|
||||||
assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());
|
assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());
|
||||||
assertNotNull(core1.getSolrConfig());
|
assertNotNull(core1.getSolrConfig());
|
||||||
|
|
||||||
SolrCore core2 = cc.getCore("collectionLazy2");
|
SolrCore core2 = cc.getCore("collection2");
|
||||||
assertTrue("core2 should be transient", core2.getCoreDescriptor().isTransient());
|
assertTrue("core2 should be transient", core2.getCoreDescriptor().isTransient());
|
||||||
assertTrue("core2 should be loadable", core2.getCoreDescriptor().isLoadOnStartup());
|
assertTrue("core2 should be loadable", core2.getCoreDescriptor().isLoadOnStartup());
|
||||||
|
|
||||||
SolrCore core3 = cc.getCore("collectionLazy3");
|
SolrCore core3 = cc.getCore("collection3");
|
||||||
assertTrue("core3 should be transient", core3.getCoreDescriptor().isTransient());
|
assertTrue("core3 should be transient", core3.getCoreDescriptor().isTransient());
|
||||||
assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());
|
assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());
|
||||||
|
|
||||||
SolrCore core4 = cc.getCore("collectionLazy4");
|
SolrCore core4 = cc.getCore("collection4");
|
||||||
assertFalse("core4 should not be transient", core4.getCoreDescriptor().isTransient());
|
assertFalse("core4 should not be transient", core4.getCoreDescriptor().isTransient());
|
||||||
assertFalse("core4 should not be loadable", core4.getCoreDescriptor().isLoadOnStartup());
|
assertFalse("core4 should not be loadable", core4.getCoreDescriptor().isLoadOnStartup());
|
||||||
|
|
||||||
SolrCore core5 = cc.getCore("collectionLazy5");
|
SolrCore core5 = cc.getCore("collection5");
|
||||||
assertFalse("core5 should not be transient", core5.getCoreDescriptor().isTransient());
|
assertFalse("core5 should not be transient", core5.getCoreDescriptor().isTransient());
|
||||||
assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());
|
assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
CoreContainer cc = init();
|
CoreContainer cc = init();
|
||||||
try {
|
try {
|
||||||
// Make sure Lazy4 isn't loaded. Should be loaded on the get
|
// Make sure Lazy4 isn't loaded. Should be loaded on the get
|
||||||
checkNotInCores(cc, "collectionLazy4");
|
checkNotInCores(cc, "collection4");
|
||||||
SolrCore core4 = cc.getCore("collectionLazy4");
|
SolrCore core4 = cc.getCore("collection4");
|
||||||
|
|
||||||
checkSearch(core4);
|
checkSearch(core4);
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
, "//result[@numFound='0']"
|
, "//result[@numFound='0']"
|
||||||
);
|
);
|
||||||
|
|
||||||
checkInCores(cc, "collectionLazy4");
|
checkInCores(cc, "collection4");
|
||||||
|
|
||||||
core4.close();
|
core4.close();
|
||||||
collection1.close();
|
collection1.close();
|
||||||
|
@ -196,40 +196,39 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
try {
|
try {
|
||||||
// First check that all the cores that should be loaded at startup actually are.
|
// First check that all the cores that should be loaded at startup actually are.
|
||||||
|
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy5");
|
checkInCores(cc, "collection1", "collection2", "collection5");
|
||||||
checkNotInCores(cc, "collectionLazy3", "collectionLazy4", "collectionLazy6",
|
checkNotInCores(cc, "collection3", "collection4", "collection6", "collection7", "collection8", "collection9");
|
||||||
"collectionLazy7", "collectionLazy8", "collectionLazy9");
|
|
||||||
|
|
||||||
// By putting these in non-alpha order, we're also checking that we're not just seeing an artifact.
|
// By putting these in non-alpha order, we're also checking that we're not just seeing an artifact.
|
||||||
SolrCore core1 = cc.getCore("collection1");
|
SolrCore core1 = cc.getCore("collection1");
|
||||||
SolrCore core3 = cc.getCore("collectionLazy3");
|
SolrCore core3 = cc.getCore("collection3");
|
||||||
SolrCore core4 = cc.getCore("collectionLazy4");
|
SolrCore core4 = cc.getCore("collection4");
|
||||||
SolrCore core2 = cc.getCore("collectionLazy2");
|
SolrCore core2 = cc.getCore("collection2");
|
||||||
SolrCore core5 = cc.getCore("collectionLazy5");
|
SolrCore core5 = cc.getCore("collection5");
|
||||||
|
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5");
|
checkInCores(cc, "collection1", "collection2", "collection3", "collection4", "collection5");
|
||||||
checkNotInCores(cc, "collectionLazy6", "collectionLazy7", "collectionLazy8", "collectionLazy9");
|
checkNotInCores(cc, "collection6", "collection7", "collection8", "collection9");
|
||||||
|
|
||||||
// map should be full up, add one more and verify
|
// map should be full up, add one more and verify
|
||||||
SolrCore core6 = cc.getCore("collectionLazy6");
|
SolrCore core6 = cc.getCore("collection6");
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5",
|
checkInCores(cc, "collection1", "collection2", "collection3", "collection4", "collection5",
|
||||||
"collectionLazy6");
|
"collection6");
|
||||||
checkNotInCores(cc, "collectionLazy7", "collectionLazy8", "collectionLazy9");
|
checkNotInCores(cc, "collection7", "collection8", "collection9");
|
||||||
|
|
||||||
SolrCore core7 = cc.getCore("collectionLazy7");
|
SolrCore core7 = cc.getCore("collection7");
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy5",
|
checkInCores(cc, "collection1", "collection2", "collection3", "collection4", "collection5",
|
||||||
"collectionLazy6", "collectionLazy7");
|
"collection6", "collection7");
|
||||||
checkNotInCores(cc, "collectionLazy8", "collectionLazy9");
|
checkNotInCores(cc, "collection8", "collection9");
|
||||||
|
|
||||||
SolrCore core8 = cc.getCore("collectionLazy8");
|
SolrCore core8 = cc.getCore("collection8");
|
||||||
checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy4", "collectionLazy5", "collectionLazy6",
|
checkInCores(cc, "collection1", "collection2", "collection4", "collection5", "collection6",
|
||||||
"collectionLazy7", "collectionLazy8");
|
"collection7", "collection8");
|
||||||
checkNotInCores(cc, "collectionLazy3", "collectionLazy9");
|
checkNotInCores(cc, "collection3", "collection9");
|
||||||
|
|
||||||
SolrCore core9 = cc.getCore("collectionLazy9");
|
SolrCore core9 = cc.getCore("collection9");
|
||||||
checkInCores(cc, "collection1", "collectionLazy4", "collectionLazy5", "collectionLazy6", "collectionLazy7",
|
checkInCores(cc, "collection1", "collection4", "collection5", "collection6", "collection7",
|
||||||
"collectionLazy8", "collectionLazy9");
|
"collection8", "collection9");
|
||||||
checkNotInCores(cc, "collectionLazy2", "collectionLazy3");
|
checkNotInCores(cc, "collection2", "collection3");
|
||||||
|
|
||||||
|
|
||||||
// Note decrementing the count when the core is removed from the lazyCores list is appropriate, since the
|
// Note decrementing the count when the core is removed from the lazyCores list is appropriate, since the
|
||||||
|
@ -261,7 +260,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
threads[idx] = new Thread() {
|
threads[idx] = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SolrCore core = cc.getCore("collectionLazy3");
|
SolrCore core = cc.getCore("collection3");
|
||||||
synchronized (theCores) {
|
synchronized (theCores) {
|
||||||
theCores.add(core);
|
theCores.add(core);
|
||||||
}
|
}
|
||||||
|
@ -312,10 +311,10 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
try {
|
try {
|
||||||
// First, try all 4 combinations of load on startup and transient
|
// First, try all 4 combinations of load on startup and transient
|
||||||
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
||||||
SolrCore lc2 = cc.getCore("collectionLazy2");
|
SolrCore lc2 = cc.getCore("collection2");
|
||||||
SolrCore lc4 = cc.getCore("collectionLazy4");
|
SolrCore lc4 = cc.getCore("collection4");
|
||||||
SolrCore lc5 = cc.getCore("collectionLazy5");
|
SolrCore lc5 = cc.getCore("collection5");
|
||||||
SolrCore lc6 = cc.getCore("collectionLazy6");
|
SolrCore lc6 = cc.getCore("collection6");
|
||||||
|
|
||||||
copyMinConf(new File(solrHomeDirectory, "t2"));
|
copyMinConf(new File(solrHomeDirectory, "t2"));
|
||||||
copyMinConf(new File(solrHomeDirectory, "t4"));
|
copyMinConf(new File(solrHomeDirectory, "t4"));
|
||||||
|
@ -324,10 +323,10 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
|
|
||||||
// Should also fail with the same name
|
// Should also fail with the same name
|
||||||
tryCreateFail(admin, "collectionLazy2", "t12", "Core with name", "collectionLazy2", "already exists");
|
tryCreateFail(admin, "collection2", "t12", "Core with name", "collection2", "already exists");
|
||||||
tryCreateFail(admin, "collectionLazy4", "t14", "Core with name", "collectionLazy4", "already exists");
|
tryCreateFail(admin, "collection4", "t14", "Core with name", "collection4", "already exists");
|
||||||
tryCreateFail(admin, "collectionLazy5", "t15", "Core with name", "collectionLazy5", "already exists");
|
tryCreateFail(admin, "collection5", "t15", "Core with name", "collection5", "already exists");
|
||||||
tryCreateFail(admin, "collectionLazy6", "t16", "Core with name", "collectionLazy6", "already exists");
|
tryCreateFail(admin, "collection6", "t16", "Core with name", "collection6", "already exists");
|
||||||
|
|
||||||
lc2.close();
|
lc2.close();
|
||||||
lc4.close();
|
lc4.close();
|
||||||
|
@ -339,7 +338,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createViaAdmin(CoreContainer cc, String name, String instanceDir, boolean isTransient,
|
private void createViaAdmin(CoreContainer cc, String name, boolean isTransient,
|
||||||
boolean loadOnStartup) throws Exception {
|
boolean loadOnStartup) throws Exception {
|
||||||
|
|
||||||
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
final CoreAdminHandler admin = new CoreAdminHandler(cc);
|
||||||
|
@ -347,7 +346,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
admin.handleRequestBody
|
admin.handleRequestBody
|
||||||
(req(CoreAdminParams.ACTION,
|
(req(CoreAdminParams.ACTION,
|
||||||
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
||||||
CoreAdminParams.INSTANCE_DIR, instanceDir,
|
|
||||||
CoreAdminParams.NAME, name,
|
CoreAdminParams.NAME, name,
|
||||||
CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
|
CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
|
||||||
CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
|
CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
|
||||||
|
@ -379,11 +377,11 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
copyMinConf(new File(solrHomeDirectory, "core4"));
|
copyMinConf(new File(solrHomeDirectory, "core4"));
|
||||||
copyMinConf(new File(solrHomeDirectory, "core5"));
|
copyMinConf(new File(solrHomeDirectory, "core5"));
|
||||||
|
|
||||||
createViaAdmin(cc, "core1", "./core1", true, true);
|
createViaAdmin(cc, "core1", true, true);
|
||||||
createViaAdmin(cc, "core2", "./core2", true, false);
|
createViaAdmin(cc, "core2", true, false);
|
||||||
createViaAdmin(cc, "core3", "./core3", true, true);
|
createViaAdmin(cc, "core3", true, true);
|
||||||
createViaAdmin(cc, "core4", "./core4", true, false);
|
createViaAdmin(cc, "core4", true, false);
|
||||||
createViaAdmin(cc, "core5", "./core5", true, false);
|
createViaAdmin(cc, "core5", true, false);
|
||||||
|
|
||||||
SolrCore c1 = cc.getCore("core1");
|
SolrCore c1 = cc.getCore("core1");
|
||||||
SolrCore c2 = cc.getCore("core2");
|
SolrCore c2 = cc.getCore("core2");
|
||||||
|
@ -391,10 +389,10 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
||||||
SolrCore c4 = cc.getCore("core4");
|
SolrCore c4 = cc.getCore("core4");
|
||||||
SolrCore c5 = cc.getCore("core5");
|
SolrCore c5 = cc.getCore("core5");
|
||||||
|
|
||||||
checkNotInCores(cc, "core1", "collectionLazy2", "collectionLazy3", "collectionLazy4", "collectionLazy6"
|
checkNotInCores(cc, "core1", "collection2", "collection3", "collection4", "collection6"
|
||||||
, "collectionLazy7", "collectionLazy8", "collectionLazy9");
|
, "collection7", "collection8", "collection9");
|
||||||
|
|
||||||
checkInCores(cc, "collection1", "collectionLazy5", "core2", "core3", "core4", "core5");
|
checkInCores(cc, "collection1", "collection5", "core2", "core3", "core4", "core5");
|
||||||
|
|
||||||
// While we're at it, a test for SOLR-5366, unloading transient core that's been unloaded b/c it's
|
// While we're at it, a test for SOLR-5366, unloading transient core that's been unloaded b/c it's
|
||||||
// transient generates a "too many closes" errorl
|
// transient generates a "too many closes" errorl
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
|
|
||||||
package org.apache.solr.handler.admin;
|
package org.apache.solr.handler.admin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
@ -38,9 +43,6 @@ import org.junit.Test;
|
||||||
import org.junit.rules.RuleChain;
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TestRule;
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
|
public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@ -117,16 +119,15 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
final CoreAdminHandler admin = new CoreAdminHandler(cores);
|
final CoreAdminHandler admin = new CoreAdminHandler(cores);
|
||||||
|
|
||||||
String instDir;
|
Path instDir;
|
||||||
try (SolrCore template = cores.getCore("collection1")) {
|
try (SolrCore template = cores.getCore("collection1")) {
|
||||||
assertNotNull(template);
|
assertNotNull(template);
|
||||||
instDir = template.getCoreDescriptor().getInstanceDir();
|
instDir = template.getCoreDescriptor().getInstanceDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
final File instDirFile = new File(instDir);
|
assertTrue("instDir doesn't exist: " + instDir, Files.exists(instDir));
|
||||||
assertTrue("instDir doesn't exist: " + instDir, instDirFile.exists());
|
|
||||||
final File instPropFile = new File(workDir, "instProp");
|
final File instPropFile = new File(workDir, "instProp");
|
||||||
FileUtils.copyDirectory(instDirFile, instPropFile);
|
FileUtils.copyDirectory(instDir.toFile(), instPropFile);
|
||||||
|
|
||||||
// create a new core (using CoreAdminHandler) w/ properties
|
// create a new core (using CoreAdminHandler) w/ properties
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.solr.handler.admin;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
|
@ -44,16 +46,15 @@ public class CoreAdminRequestStatusTest extends SolrTestCaseJ4{
|
||||||
|
|
||||||
final CoreAdminHandler admin = new CoreAdminHandler(cores);
|
final CoreAdminHandler admin = new CoreAdminHandler(cores);
|
||||||
|
|
||||||
String instDir;
|
Path instDir;
|
||||||
try (SolrCore template = cores.getCore("collection1")) {
|
try (SolrCore template = cores.getCore("collection1")) {
|
||||||
assertNotNull(template);
|
assertNotNull(template);
|
||||||
instDir = template.getCoreDescriptor().getInstanceDir();
|
instDir = template.getCoreDescriptor().getInstanceDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
final File instDirFile = new File(instDir);
|
assertTrue("instDir doesn't exist: " + instDir, Files.exists(instDir));
|
||||||
assertTrue("instDir doesn't exist: " + instDir, instDirFile.exists());
|
|
||||||
final File instPropFile = new File(workDir, "instProp");
|
final File instPropFile = new File(workDir, "instProp");
|
||||||
FileUtils.copyDirectory(instDirFile, instPropFile);
|
FileUtils.copyDirectory(instDir.toFile(), instPropFile);
|
||||||
|
|
||||||
// create a new core (using CoreAdminHandler) w/ properties
|
// create a new core (using CoreAdminHandler) w/ properties
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,16 @@ import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
import org.apache.solr.core.CoreDescriptor;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.search.SolrIndexSearcher;
|
|
||||||
import org.apache.solr.spelling.suggest.SuggesterParams;
|
import org.apache.solr.spelling.suggest.SuggesterParams;
|
||||||
import org.apache.solr.util.RefCounted;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class SuggestComponentTest extends SolrTestCaseJ4 {
|
public class SuggestComponentTest extends SolrTestCaseJ4 {
|
||||||
static String rh = "/suggest";
|
|
||||||
|
|
||||||
|
private static final String rh = "/suggest";
|
||||||
|
|
||||||
|
private static CoreContainer cc;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
|
@ -506,8 +506,9 @@ public class SuggestComponentTest extends SolrTestCaseJ4 {
|
||||||
SolrCore core = h.getCore();
|
SolrCore core = h.getCore();
|
||||||
String dataDir1 = core.getDataDir();
|
String dataDir1 = core.getDataDir();
|
||||||
CoreDescriptor cd = core.getCoreDescriptor();
|
CoreDescriptor cd = core.getCoreDescriptor();
|
||||||
cores.unload(core.getName());
|
h.close();
|
||||||
SolrCore createdCore = cores.create(cd);
|
createCore();
|
||||||
|
SolrCore createdCore = h.getCore();
|
||||||
assertEquals(dataDir1, createdCore.getDataDir());
|
assertEquals(dataDir1, createdCore.getDataDir());
|
||||||
assertEquals(createdCore, h.getCore());
|
assertEquals(createdCore, h.getCore());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexReaderContext;
|
import org.apache.lucene.index.IndexReaderContext;
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
|
@ -219,9 +220,8 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
|
||||||
MockSearcherListener.numberOfTimesCalledFirstSearcher = new AtomicInteger();
|
MockSearcherListener.numberOfTimesCalledFirstSearcher = new AtomicInteger();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CoreDescriptor newCd = new CoreDescriptor(cores, "core1", cd.getInstanceDir(), "config", "solrconfig-searcher-listeners1.xml");
|
|
||||||
// Create a new core, this should call all the firstSearcherListeners
|
// Create a new core, this should call all the firstSearcherListeners
|
||||||
newCore = cores.create(newCd);
|
newCore = cores.create("core1", cd.getInstanceDir(), ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"));
|
||||||
|
|
||||||
//validate that the new core was created with the correct solrconfig
|
//validate that the new core was created with the correct solrconfig
|
||||||
assertNotNull(newCore.getSearchComponent("mock"));
|
assertNotNull(newCore.getSearchComponent("mock"));
|
||||||
|
@ -270,9 +270,8 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
|
||||||
final SolrCore newCore;
|
final SolrCore newCore;
|
||||||
boolean coreCreated = false;
|
boolean coreCreated = false;
|
||||||
try {
|
try {
|
||||||
CoreDescriptor newCd = new CoreDescriptor(cores, "core1", cd.getInstanceDir(), "config", "solrconfig-searcher-listeners1.xml");
|
|
||||||
// Create a new core, this should call all the firstSearcherListeners
|
// Create a new core, this should call all the firstSearcherListeners
|
||||||
newCore = cores.create(newCd);
|
newCore = cores.create("core1", cd.getInstanceDir(), ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"));
|
||||||
coreCreated = true;
|
coreCreated = true;
|
||||||
|
|
||||||
//validate that the new core was created with the correct solrconfig
|
//validate that the new core was created with the correct solrconfig
|
||||||
|
@ -337,9 +336,8 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
|
||||||
boolean coreCreated = false;
|
boolean coreCreated = false;
|
||||||
try {
|
try {
|
||||||
System.setProperty("tests.solr.useColdSearcher", "true");
|
System.setProperty("tests.solr.useColdSearcher", "true");
|
||||||
CoreDescriptor newCd = new CoreDescriptor(cores, "core1", cd.getInstanceDir(), "config", "solrconfig-searcher-listeners1.xml");
|
|
||||||
// Create a new core, this should call all the firstSearcherListeners
|
// Create a new core, this should call all the firstSearcherListeners
|
||||||
newCore = cores.create(newCd);
|
newCore = cores.create("core1", cd.getInstanceDir(), ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"));
|
||||||
coreCreated = true;
|
coreCreated = true;
|
||||||
|
|
||||||
//validate that the new core was created with the correct solrconfig
|
//validate that the new core was created with the correct solrconfig
|
||||||
|
|
|
@ -17,6 +17,12 @@ package org.apache.solr.update;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.lucene.index.DirectoryReader;
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
|
@ -28,7 +34,6 @@ import org.apache.solr.common.cloud.CompositeIdRouter;
|
||||||
import org.apache.solr.common.cloud.DocRouter;
|
import org.apache.solr.common.cloud.DocRouter;
|
||||||
import org.apache.solr.common.cloud.PlainIdRouter;
|
import org.apache.solr.common.cloud.PlainIdRouter;
|
||||||
import org.apache.solr.common.util.Hash;
|
import org.apache.solr.common.util.Hash;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
|
||||||
import org.apache.solr.core.DirectoryFactory;
|
import org.apache.solr.core.DirectoryFactory;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||||
|
@ -36,11 +41,6 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
|
public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
|
||||||
File indexDir1 = null, indexDir2 = null, indexDir3 = null;
|
File indexDir1 = null, indexDir2 = null, indexDir3 = null;
|
||||||
|
|
||||||
|
@ -159,15 +159,11 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
SolrCore core1 = null, core2 = null;
|
SolrCore core1 = null, core2 = null;
|
||||||
try {
|
try {
|
||||||
String instanceDir = h.getCore().getCoreDescriptor().getInstanceDir();
|
|
||||||
|
|
||||||
CoreDescriptor dcore1 = buildCoreDescriptor(h.getCoreContainer(), "split1", instanceDir)
|
core1 = h.getCoreContainer().create("split1",
|
||||||
.withDataDir(indexDir1.getAbsolutePath()).withSchema("schema12.xml").build();
|
ImmutableMap.of("dataDir", indexDir1.getAbsolutePath(), "configSet", "minimal"));
|
||||||
core1 = h.getCoreContainer().create(dcore1);
|
core2 = h.getCoreContainer().create("split2",
|
||||||
|
ImmutableMap.of("dataDir", indexDir2.getAbsolutePath(), "configSet", "minimal"));
|
||||||
CoreDescriptor dcore2 = buildCoreDescriptor(h.getCoreContainer(), "split2", instanceDir)
|
|
||||||
.withDataDir(indexDir2.getAbsolutePath()).withSchema("schema12.xml").build();
|
|
||||||
core2 = h.getCoreContainer().create(dcore2);
|
|
||||||
|
|
||||||
LocalSolrQueryRequest request = null;
|
LocalSolrQueryRequest request = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,6 +17,9 @@ package org.apache.solr.util;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
import org.apache.solr.core.CoreDescriptor;
|
||||||
|
|
||||||
|
@ -24,7 +27,7 @@ import org.apache.solr.core.CoreDescriptor;
|
||||||
public class MockCoreContainer extends CoreContainer {
|
public class MockCoreContainer extends CoreContainer {
|
||||||
public static class MockCoreDescriptor extends CoreDescriptor {
|
public static class MockCoreDescriptor extends CoreDescriptor {
|
||||||
public MockCoreDescriptor() {
|
public MockCoreDescriptor() {
|
||||||
super(new MockCoreContainer(), "mock", "path");
|
super(new MockCoreContainer(), "mock", Paths.get("path"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +35,7 @@ public class MockCoreContainer extends CoreContainer {
|
||||||
super(new Object());
|
super(new Object());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCoreRootDirectory() {
|
public Path getCoreRootDirectory() {
|
||||||
return "coreroot";
|
return Paths.get("coreroot");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,6 @@ import org.apache.solr.common.util.ObjectReleaseTracker;
|
||||||
import org.apache.solr.common.util.SuppressForbidden;
|
import org.apache.solr.common.util.SuppressForbidden;
|
||||||
import org.apache.solr.common.util.XML;
|
import org.apache.solr.common.util.XML;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
|
||||||
import org.apache.solr.core.CoresLocator;
|
import org.apache.solr.core.CoresLocator;
|
||||||
import org.apache.solr.core.NodeConfig;
|
import org.apache.solr.core.NodeConfig;
|
||||||
import org.apache.solr.core.SolrConfig;
|
import org.apache.solr.core.SolrConfig;
|
||||||
|
@ -397,9 +396,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
configString = config;
|
configString = config;
|
||||||
schemaString = schema;
|
schemaString = schema;
|
||||||
testSolrHome = Paths.get(solrHome);
|
testSolrHome = Paths.get(solrHome);
|
||||||
if (solrHome != null) {
|
System.setProperty("solr.solr.home", solrHome);
|
||||||
System.setProperty("solr.solr.home", solrHome);
|
|
||||||
}
|
|
||||||
initCore();
|
initCore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1862,53 +1859,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
FileUtils.copyFile(new File(top, "synonyms.txt"), new File(subHome, "synonyms.txt"));
|
FileUtils.copyFile(new File(top, "synonyms.txt"), new File(subHome, "synonyms.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CoreDescriptorBuilder buildCoreDescriptor(CoreContainer container, String name, String instancedir) {
|
|
||||||
return new CoreDescriptorBuilder(container, name, instancedir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CoreDescriptorBuilder {
|
|
||||||
|
|
||||||
final String name;
|
|
||||||
final String instanceDir;
|
|
||||||
final CoreContainer container;
|
|
||||||
final Properties properties = new Properties();
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder(CoreContainer container, String name, String instancedir) {
|
|
||||||
this.name = name;
|
|
||||||
this.instanceDir = instancedir;
|
|
||||||
this.container = container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder withSchema(String schema) {
|
|
||||||
properties.setProperty(CoreDescriptor.CORE_SCHEMA, schema);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder withConfig(String config) {
|
|
||||||
properties.setProperty(CoreDescriptor.CORE_CONFIG, config);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder withDataDir(String datadir) {
|
|
||||||
properties.setProperty(CoreDescriptor.CORE_DATADIR, datadir);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptor build() {
|
|
||||||
return new CoreDescriptor(container, name, instanceDir, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder isTransient(boolean isTransient) {
|
|
||||||
properties.setProperty(CoreDescriptor.CORE_TRANSIENT, Boolean.toString(isTransient));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreDescriptorBuilder loadOnStartup(boolean loadOnStartup) {
|
|
||||||
properties.setProperty(CoreDescriptor.CORE_LOADONSTARTUP, Boolean.toString(loadOnStartup));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean compareSolrDocument(Object expected, Object actual) {
|
public boolean compareSolrDocument(Object expected, Object actual) {
|
||||||
|
|
||||||
if (!(expected instanceof SolrDocument) || !(actual instanceof SolrDocument)) {
|
if (!(expected instanceof SolrDocument) || !(actual instanceof SolrDocument)) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class TestHarness extends BaseTestHarness {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CoreDescriptor> discover(CoreContainer cc) {
|
public List<CoreDescriptor> discover(CoreContainer cc) {
|
||||||
return ImmutableList.of(new CoreDescriptor(cc, coreName, coreName,
|
return ImmutableList.of(new CoreDescriptor(cc, coreName, cc.getCoreRootDirectory().resolve(coreName),
|
||||||
CoreDescriptor.CORE_DATADIR, dataDir,
|
CoreDescriptor.CORE_DATADIR, dataDir,
|
||||||
CoreDescriptor.CORE_CONFIG, solrConfig,
|
CoreDescriptor.CORE_CONFIG, solrConfig,
|
||||||
CoreDescriptor.CORE_SCHEMA, schema,
|
CoreDescriptor.CORE_SCHEMA, schema,
|
||||||
|
|
Loading…
Reference in New Issue