mirror of https://github.com/apache/lucene.git
SOLR-6533 , changed the node name from solrConfig to config. handle empty command list
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1649486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d7e0fd28dd
commit
c8545d6dbf
|
@ -2151,10 +2151,9 @@ public final class ZkController {
|
|||
*
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean persistConfigResourceToZooKeeper( SolrResourceLoader loader, int znodeVersion ,
|
||||
public static boolean persistConfigResourceToZooKeeper( ZkSolrResourceLoader zkLoader, int znodeVersion ,
|
||||
String resourceName, byte[] content,
|
||||
boolean createIfNotExists) {
|
||||
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
|
||||
final ZkController zkController = zkLoader.getZkController();
|
||||
final SolrZkClient zkClient = zkController.getZkClient();
|
||||
final String resourceLocation = zkLoader.getConfigSetZkPath() + "/" + resourceName;
|
||||
|
@ -2162,12 +2161,12 @@ public final class ZkController {
|
|||
try {
|
||||
try {
|
||||
zkClient.setData(resourceLocation , content,znodeVersion, true);
|
||||
zkClient.setData(zkLoader.getConfigSetZkPath(),new byte[]{0},true);
|
||||
touchConfDir(zkLoader);
|
||||
} catch (NoNodeException e) {
|
||||
if(createIfNotExists){
|
||||
try {
|
||||
zkClient.create(resourceLocation,content, CreateMode.PERSISTENT,true);
|
||||
zkClient.setData(zkLoader.getConfigSetZkPath(), new byte[]{0}, true);
|
||||
touchConfDir(zkLoader);
|
||||
} catch (KeeperException.NodeExistsException nee) {
|
||||
try {
|
||||
Stat stat = zkClient.exists(resourceLocation, null, true);
|
||||
|
@ -2206,6 +2205,21 @@ public final class ZkController {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void touchConfDir(ZkSolrResourceLoader zkLoader) {
|
||||
SolrZkClient zkClient = zkLoader.getZkController().getZkClient();
|
||||
try {
|
||||
zkClient.setData(zkLoader.getConfigSetZkPath(),new byte[]{0},true);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof InterruptedException) {
|
||||
Thread.currentThread().interrupt(); // Restore the interrupted status
|
||||
}
|
||||
final String msg = "Error 'touching' conf location " + zkLoader.getConfigSetZkPath();
|
||||
log.error(msg, e);
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, msg, e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class ResourceModifiedInZkException extends SolrException {
|
||||
public ResourceModifiedInZkException(ErrorCode code, String msg) {
|
||||
super(code, msg);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
private void handleGET() {
|
||||
if(parts.size() == 1) {
|
||||
resp.add("solrConfig", req.getCore().getSolrConfig().toMap());
|
||||
resp.add("config", req.getCore().getSolrConfig().toMap());
|
||||
} else {
|
||||
if(ConfigOverlay.NAME.equals(parts.get(1))){
|
||||
resp.add(ConfigOverlay.NAME, req.getCore().getSolrConfig().getOverlay().toMap());
|
||||
|
@ -119,7 +119,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
} else {
|
||||
Map<String, Object> m = req.getCore().getSolrConfig().toMap();
|
||||
resp.add("solrConfig", ZkNodeProps.makeMap(parts.get(1),m.get(parts.get(1))));
|
||||
resp.add("config", ZkNodeProps.makeMap(parts.get(1),m.get(parts.get(1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,8 +236,13 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
SolrResourceLoader loader = req.getCore().getResourceLoader();
|
||||
if (loader instanceof ZkSolrResourceLoader) {
|
||||
ZkController.persistConfigResourceToZooKeeper(loader,params.getZnodeVersion(),
|
||||
RequestParams.RESOURCE,params.toByteArray(),true);
|
||||
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) loader;
|
||||
if(ops.isEmpty()) {
|
||||
ZkController.touchConfDir(zkLoader);
|
||||
}else {
|
||||
ZkController.persistConfigResourceToZooKeeper(zkLoader, params.getZnodeVersion(),
|
||||
RequestParams.RESOURCE, params.toByteArray(), true);
|
||||
}
|
||||
|
||||
} else {
|
||||
SolrResourceLoader.persistConfLocally(loader, ConfigOverlay.RESOURCE_NAME, params.toByteArray());
|
||||
|
@ -278,7 +283,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
SolrResourceLoader loader = req.getCore().getResourceLoader();
|
||||
if (loader instanceof ZkSolrResourceLoader) {
|
||||
ZkController.persistConfigResourceToZooKeeper(loader,overlay.getZnodeVersion(),
|
||||
ZkController.persistConfigResourceToZooKeeper((ZkSolrResourceLoader) loader,overlay.getZnodeVersion(),
|
||||
ConfigOverlay.RESOURCE_NAME,overlay.toByteArray(),true);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class SchemaManager {
|
|||
if (!errs.isEmpty()) return errs;
|
||||
SolrResourceLoader loader = req.getCore().getResourceLoader();
|
||||
if (loader instanceof ZkSolrResourceLoader) {
|
||||
|
||||
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) loader;
|
||||
StringWriter sw = new StringWriter();
|
||||
try {
|
||||
managedIndexSchema.persist(sw);
|
||||
|
@ -145,7 +145,7 @@ public class SchemaManager {
|
|||
}
|
||||
|
||||
try {
|
||||
ZkController.persistConfigResourceToZooKeeper(loader,
|
||||
ZkController.persistConfigResourceToZooKeeper(zkLoader,
|
||||
managedIndexSchema.getSchemaZkVersion(),
|
||||
managedIndexSchema.getResourceName(),
|
||||
sw.toString().getBytes(StandardCharsets.UTF_8),
|
||||
|
|
|
@ -103,7 +103,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
assertEquals("100", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs")) ));
|
||||
assertEquals("10", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxTime")) ));
|
||||
|
||||
m = (Map) getRespMap("/config?wt=json" ,harness).get("solrConfig");
|
||||
m = (Map) getRespMap("/config?wt=json" ,harness).get("config");
|
||||
assertNotNull(m);
|
||||
|
||||
assertEquals( "100",String.valueOf(getObjectByPath(m, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs"))));
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
|
|||
Map map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient);
|
||||
assertNotNull(map);
|
||||
assertEquals("solr.BlobHandler", getObjectByPath(map, true, Arrays.asList(
|
||||
"solrConfig",
|
||||
"config",
|
||||
"requestHandler",
|
||||
"/blob",
|
||||
"class")));
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {
|
|||
log.info("live_nodes_count : " + cloudClient.getZkStateReader().getClusterState().getLiveNodes());
|
||||
String confPath = ZkController.CONFIGS_ZKNODE+"/conf1/";
|
||||
// checkConfReload(client, confPath + ConfigOverlay.RESOURCE_NAME, "overlay");
|
||||
checkConfReload(client, confPath + SolrConfig.DEFAULT_CONF_FILE,"solrConfig", "/config");
|
||||
checkConfReload(client, confPath + SolrConfig.DEFAULT_CONF_FILE,"config", "/config");
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue