SOLR-6715: ZkSolrResourceLoader constructors accept a parameter called 'collection' but it should be 'configName'

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1637296 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-11-07 06:39:26 +00:00
parent 497e64e2b9
commit 4905248879
11 changed files with 30 additions and 27 deletions

View File

@ -369,6 +369,9 @@ Other Changes
References to zkCredentialProvider in System properties or configurations should be References to zkCredentialProvider in System properties or configurations should be
changed to zkCredentialsProvider. (Gregory Chanan) changed to zkCredentialsProvider. (Gregory Chanan)
* SOLR-6715: ZkSolrResourceLoader constructors accept a parameter called 'collection'
but it should be 'configName'. (shalin)
================== 4.10.3 ================== ================== 4.10.3 ==================
Bug Fixes Bug Fixes

View File

@ -88,7 +88,7 @@ public class CloudUtil {
/** /**
* Returns a displayable unified path to the given resource. For non-solrCloud that will be the * Returns a displayable unified path to the given resource. For non-solrCloud that will be the
* same as getConfigDir, but for Cloud it will be getCollectionZkPath ending in a / * same as getConfigDir, but for Cloud it will be getConfigSetZkPath ending in a /
* <p/> * <p/>
* <b>Note:</b> Do not use this to generate a valid file path, but for debug printing etc * <b>Note:</b> Do not use this to generate a valid file path, but for debug printing etc
* @param loader Resource loader instance * @param loader Resource loader instance
@ -96,7 +96,7 @@ public class CloudUtil {
*/ */
public static String unifiedResourcePath(SolrResourceLoader loader) { public static String unifiedResourcePath(SolrResourceLoader loader) {
return (loader instanceof ZkSolrResourceLoader) ? return (loader instanceof ZkSolrResourceLoader) ?
((ZkSolrResourceLoader) loader).getCollectionZkPath() + "/" : ((ZkSolrResourceLoader) loader).getConfigSetZkPath() + "/" :
loader.getConfigDir(); loader.getConfigDir();
} }
} }

View File

@ -1200,7 +1200,7 @@ public final class ZkController {
boolean removeWatch = true; boolean removeWatch = true;
// if there is no SolrCore which is a member of this collection, remove the watch // if there is no SolrCore which is a member of this collection, remove the watch
for (SolrCore solrCore : cc.getCores()) { for (SolrCore solrCore : cc.getCores()) {
if (((ZkSolrResourceLoader)solrCore.getResourceLoader()).getCollectionZkPath().equals(configLocation)) if (((ZkSolrResourceLoader)solrCore.getResourceLoader()).getConfigSetZkPath().equals(configLocation))
configLocation = null; //if a core uses this config dir , then set it to null configLocation = null; //if a core uses this config dir , then set it to null
@ -2119,7 +2119,7 @@ public final class ZkController {
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader; final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
final ZkController zkController = zkLoader.getZkController(); final ZkController zkController = zkLoader.getZkController();
final SolrZkClient zkClient = zkController.getZkClient(); final SolrZkClient zkClient = zkController.getZkClient();
final String resourceLocation = zkLoader.getCollectionZkPath() + "/" + resourceName; final String resourceLocation = zkLoader.getConfigSetZkPath() + "/" + resourceName;
String errMsg = "Failed to persist resource at {0} - version mismatch"; String errMsg = "Failed to persist resource at {0} - version mismatch";
try { try {
try { try {

View File

@ -38,16 +38,16 @@ import org.apache.zookeeper.data.Stat;
*/ */
public class ZkSolrResourceLoader extends SolrResourceLoader { public class ZkSolrResourceLoader extends SolrResourceLoader {
private final String collectionZkPath; private final String configSetZkPath;
private ZkController zkController; private ZkController zkController;
private ZkIndexSchemaReader zkIndexSchemaReader; private ZkIndexSchemaReader zkIndexSchemaReader;
public ZkSolrResourceLoader(String instanceDir, String collection, public ZkSolrResourceLoader(String instanceDir, String configSet,
ZkController zooKeeperController) { ZkController zooKeeperController) {
super(instanceDir); super(instanceDir);
this.zkController = zooKeeperController; this.zkController = zooKeeperController;
collectionZkPath = ZkController.CONFIGS_ZKNODE + "/" + collection; configSetZkPath = ZkController.CONFIGS_ZKNODE + "/" + configSet;
zkController.watchZKConfDir(collectionZkPath); zkController.watchZKConfDir(configSetZkPath);
} }
/** /**
@ -58,12 +58,12 @@ public class ZkSolrResourceLoader extends SolrResourceLoader {
* the "lib/" directory in the specified instance directory. * the "lib/" directory in the specified instance directory.
* <p> * <p>
*/ */
public ZkSolrResourceLoader(String instanceDir, String collection, ClassLoader parent, public ZkSolrResourceLoader(String instanceDir, String configSet, ClassLoader parent,
Properties coreProperties, ZkController zooKeeperController) { Properties coreProperties, ZkController zooKeeperController) {
super(instanceDir, parent, coreProperties); super(instanceDir, parent, coreProperties);
this.zkController = zooKeeperController; this.zkController = zooKeeperController;
collectionZkPath = ZkController.CONFIGS_ZKNODE + "/" + collection; configSetZkPath = ZkController.CONFIGS_ZKNODE + "/" + configSet;
zkController.watchZKConfDir(collectionZkPath); zkController.watchZKConfDir(configSetZkPath);
} }
/** /**
@ -78,7 +78,7 @@ public class ZkSolrResourceLoader extends SolrResourceLoader {
@Override @Override
public InputStream openResource(String resource) throws IOException { public InputStream openResource(String resource) throws IOException {
InputStream is = null; InputStream is = null;
String file = collectionZkPath + "/" + resource; String file = configSetZkPath + "/" + resource;
try { try {
if (zkController.pathExists(file)) { if (zkController.pathExists(file)) {
Stat stat = new Stat(); Stat stat = new Stat();
@ -96,7 +96,7 @@ public class ZkSolrResourceLoader extends SolrResourceLoader {
} }
if (is == null) { if (is == null) {
throw new IOException("Can't find resource '" + resource throw new IOException("Can't find resource '" + resource
+ "' in classpath or '" + collectionZkPath + "', cwd=" + "' in classpath or '" + configSetZkPath + "', cwd="
+ System.getProperty("user.dir")); + System.getProperty("user.dir"));
} }
return is; return is;
@ -131,7 +131,7 @@ public class ZkSolrResourceLoader extends SolrResourceLoader {
public String[] listConfigDir() { public String[] listConfigDir() {
List<String> list; List<String> list;
try { try {
list = zkController.getZkClient().getChildren(collectionZkPath, null, true); list = zkController.getZkClient().getChildren(configSetZkPath, null, true);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Restore the interrupted status // Restore the interrupted status
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
@ -146,8 +146,8 @@ public class ZkSolrResourceLoader extends SolrResourceLoader {
return list.toArray(new String[0]); return list.toArray(new String[0]);
} }
public String getCollectionZkPath() { public String getConfigSetZkPath() {
return collectionZkPath; return configSetZkPath;
} }
public ZkController getZkController() { public ZkController getZkController() {

View File

@ -684,7 +684,7 @@ public class CoreContainer {
// cancel recovery in cloud mode // cancel recovery in cloud mode
core.getSolrCoreState().cancelRecovery(); core.getSolrCoreState().cancelRecovery();
} }
String collectionZkPath = core.getResourceLoader() instanceof ZkSolrResourceLoader ? ((ZkSolrResourceLoader)core.getResourceLoader()).getCollectionZkPath() : null; String configSetZkPath = core.getResourceLoader() instanceof ZkSolrResourceLoader ? ((ZkSolrResourceLoader)core.getResourceLoader()).getConfigSetZkPath() : null;
core.unloadOnClose(deleteIndexDir, deleteDataDir, deleteInstanceDir); core.unloadOnClose(deleteIndexDir, deleteDataDir, deleteInstanceDir);
if (close) if (close)
@ -692,7 +692,7 @@ public class CoreContainer {
if (zkSys.getZkController() != null) { if (zkSys.getZkController() != null) {
try { try {
zkSys.getZkController().unregister(name, cd, collectionZkPath); zkSys.getZkController().unregister(name, cd, configSetZkPath);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVER_ERROR, "Interrupted while unregistering core [" + name + "] from cloud state"); throw new SolrException(ErrorCode.SERVER_ERROR, "Interrupted while unregistering core [" + name + "] from cloud state");

View File

@ -100,7 +100,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
public void run() { public void run() {
try { try {
if(core.isClosed()) return; if(core.isClosed()) return;
Stat stat = zkSolrResourceLoader.getZkController().getZkClient().exists((zkSolrResourceLoader).getCollectionZkPath() + "/" + ConfigOverlay.RESOURCE_NAME, null, true); Stat stat = zkSolrResourceLoader.getZkController().getZkClient().exists((zkSolrResourceLoader).getConfigSetZkPath() + "/" + ConfigOverlay.RESOURCE_NAME, null, true);
if(stat == null) return; if(stat == null) return;
if (stat.getVersion() > core.getSolrConfig().getOverlay().getZnodeVersion()) { if (stat.getVersion() > core.getSolrConfig().getOverlay().getZnodeVersion()) {
core.getCoreDescriptor().getCoreContainer().reload(core.getName()); core.getCoreDescriptor().getCoreContainer().reload(core.getName());
@ -115,7 +115,7 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
} }
}; };
zkSolrResourceLoader.getZkController().registerConfListenerForCore(zkSolrResourceLoader.getCollectionZkPath(), core,listener); zkSolrResourceLoader.getZkController().registerConfListenerForCore(zkSolrResourceLoader.getConfigSetZkPath(), core,listener);
} }
} }

View File

@ -282,7 +282,7 @@ public class EditFileRequestHandler extends RequestHandlerBase {
if (coreContainer.isZooKeeperAware()) { if (coreContainer.isZooKeeperAware()) {
try { try {
String confPath = ((ZkSolrResourceLoader) core.getResourceLoader()).getCollectionZkPath(); String confPath = ((ZkSolrResourceLoader) core.getResourceLoader()).getConfigSetZkPath();
ZkController.downloadConfigDir(coreContainer.getZkController().getZkClient(), confPath, ZkController.downloadConfigDir(coreContainer.getZkController().getZkClient(), confPath,
new File(coll, "conf")); new File(coll, "conf"));

View File

@ -304,7 +304,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase
final ZkSolrResourceLoader loader = (ZkSolrResourceLoader) core final ZkSolrResourceLoader loader = (ZkSolrResourceLoader) core
.getResourceLoader(); .getResourceLoader();
String confPath = loader.getCollectionZkPath(); String confPath = loader.getConfigSetZkPath();
String fname = req.getParams().get("file", null); String fname = req.getParams().get("file", null);
if (fname == null) { if (fname == null) {

View File

@ -165,7 +165,7 @@ public final class ManagedIndexSchema extends IndexSchema {
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader; final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
final ZkController zkController = zkLoader.getZkController(); final ZkController zkController = zkLoader.getZkController();
final SolrZkClient zkClient = zkController.getZkClient(); final SolrZkClient zkClient = zkController.getZkClient();
final String managedSchemaPath = zkLoader.getCollectionZkPath() + "/" + managedSchemaResourceName; final String managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedSchemaResourceName;
boolean success = true; boolean success = true;
boolean schemaChangedInZk = false; boolean schemaChangedInZk = false;
try { try {

View File

@ -119,7 +119,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
} else { // ZooKeeper } else { // ZooKeeper
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader; final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
final SolrZkClient zkClient = zkLoader.getZkController().getZkClient(); final SolrZkClient zkClient = zkLoader.getZkController().getZkClient();
final String managedSchemaPath = zkLoader.getCollectionZkPath() + "/" + managedSchemaResourceName; final String managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedSchemaResourceName;
Stat stat = new Stat(); Stat stat = new Stat();
try { try {
// Attempt to load the managed schema // Attempt to load the managed schema
@ -224,7 +224,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
SolrResourceLoader loader = config.getResourceLoader(); SolrResourceLoader loader = config.getResourceLoader();
if (loader instanceof ZkSolrResourceLoader) { if (loader instanceof ZkSolrResourceLoader) {
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader; ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
String nonManagedSchemaPath = zkLoader.getCollectionZkPath() + "/" + resourceName; String nonManagedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + resourceName;
try { try {
exists = zkLoader.getZkController().pathExists(nonManagedSchemaPath); exists = zkLoader.getZkController().pathExists(nonManagedSchemaPath);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -349,7 +349,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
} else { } else {
// Rename the non-managed schema znode in ZooKeeper // Rename the non-managed schema znode in ZooKeeper
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader; ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
final String nonManagedSchemaPath = zkLoader.getCollectionZkPath() + "/" + resourceName; final String nonManagedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + resourceName;
try { try {
ZkController zkController = zkLoader.getZkController(); ZkController zkController = zkLoader.getZkController();
ZkCmdExecutor zkCmdExecutor = new ZkCmdExecutor(zkController.getClientTimeout()); ZkCmdExecutor zkCmdExecutor = new ZkCmdExecutor(zkController.getClientTimeout());

View File

@ -43,7 +43,7 @@ public class ZkIndexSchemaReader implements OnReconnect {
this.managedIndexSchemaFactory = managedIndexSchemaFactory; this.managedIndexSchemaFactory = managedIndexSchemaFactory;
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)managedIndexSchemaFactory.getResourceLoader(); ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)managedIndexSchemaFactory.getResourceLoader();
this.zkClient = zkLoader.getZkController().getZkClient(); this.zkClient = zkLoader.getZkController().getZkClient();
managedSchemaPath = zkLoader.getCollectionZkPath() + "/" + managedIndexSchemaFactory.getManagedSchemaResourceName(); managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedIndexSchemaFactory.getManagedSchemaResourceName();
createSchemaWatcher(); createSchemaWatcher();
zkLoader.getZkController().addOnReconnectListener(this); zkLoader.getZkController().addOnReconnectListener(this);
} }