dsmiley commented on code in PR #2126: URL: https://github.com/apache/solr/pull/2126#discussion_r1452677893
########## solr/core/src/java/org/apache/solr/api/ClusterPluginsSourceConfigurator.java: ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.api; + +import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.SolrResourceLoader; +import org.apache.solr.util.EnvUtils; + +/** + * Loads the {@link ClusterPluginsSource} depending on the declared implementation. The default + * implementation is {@link ZkClusterPluginsSource}, but can be overridden by teh {@link + * ContainerPluginsRegistry#MUTABLE_CLUSTER_PLUGINS} property + */ +public class ClusterPluginsSourceConfigurator { Review Comment: This is just a couple static methods related to ClusterPluginsSource. Shouldn't these be on ClusterPluginsSource instead of having this class to hold them? ########## solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java: ########## @@ -160,8 +160,6 @@ public static NodeConfig fromConfig( configBuilder.setSolrResourceLoader(loader); configBuilder.setUpdateShardHandlerConfig(updateConfig); configBuilder.setShardHandlerFactoryConfig(getPluginInfo(root.get("shardHandlerFactory"))); - // configBuilder.setReplicaPlacementFactoryConfig( - // getPluginInfo(root.get("replicaPlacementFactory"))); Review Comment: to be removed? ########## solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java: ########## @@ -647,6 +649,68 @@ private static PluginInfo[] getBackupRepositoryPluginInfos(List<ConfigNode> cfg) return configs; } + private static PluginInfo[] getClusterPlugins(SolrResourceLoader loader, ConfigNode root) { + List<PluginInfo> clusterPlugins = new ArrayList<>(); + + Collections.addAll( + clusterPlugins, getClusterSingletonPluginInfos(loader, root.getAll("clusterSingleton"))); + + PluginInfo replicaPlacementFactory = getPluginInfo(root.get("replicaPlacementFactory")); + if (replicaPlacementFactory != null) { + if (replicaPlacementFactory.name != null + && !replicaPlacementFactory.name.equals(PlacementPluginFactory.PLUGIN_NAME)) { + throw new SolrException( + SolrException.ErrorCode.SERVER_ERROR, + "The replicaPlacementFactory name attribute must be " + + PlacementPluginFactory.PLUGIN_NAME); + } + clusterPlugins.add(replicaPlacementFactory); + } + + return clusterPlugins.toArray(new PluginInfo[0]); + } + + private static PluginInfo[] getClusterSingletonPluginInfos( + SolrResourceLoader loader, List<ConfigNode> nodes) { + if (nodes == null || nodes.isEmpty()) { + return new PluginInfo[0]; + } + + List<PluginInfo> plugins = + nodes.stream() + .map(n -> new PluginInfo(n, n.name(), true, true)) + .collect(Collectors.toList()); + + // Cluster plugin names must be unique Review Comment: Indeed, it seems to be that Container/Cluster plugins have names in one namespace, but that's weird -- Solr doesn't work that way anywhere else. I'd rather fix that limitation in a follow-up -- ContainerPluginsRegistry ought to have a a map keyed by type. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
