SOLR-13739: Optimized large managed schema modifications

Internal O(n^2) problem.
Fixes #855
This commit is contained in:
Thomas Wöckinger 2019-09-13 12:35:27 -04:00 committed by David Smiley
parent 46a03fff95
commit e788024b84
3 changed files with 8 additions and 5 deletions

View File

@ -157,6 +157,8 @@ Improvements
* SOLR-13742: Allow optional redaction of data saved by 'bin/solr autoscaling -save'. (ab)
* SOLR-13739: Optimized large managed schema modifications; Internal O(n^2) problem. (Thomas Wöckinger via David Smiley)
Bug Fixes
----------------------

View File

@ -18,6 +18,7 @@ package org.apache.solr.rest;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
@ -79,7 +80,7 @@ public abstract class ManagedResource {
* Called once during core initialization to get the managed
* data loaded from storage and notify observers.
*/
public void loadManagedDataAndNotify(List<ManagedResourceObserver> observers)
public void loadManagedDataAndNotify(Collection<ManagedResourceObserver> observers)
throws SolrException {
// load managed data from storage
@ -101,8 +102,7 @@ public abstract class ManagedResource {
* reload the core to get updates applied to the analysis components that
* depend on the ManagedResource data.
*/
@SuppressWarnings("unchecked")
protected void notifyObserversDuringInit(NamedList<?> args, List<ManagedResourceObserver> observers)
protected void notifyObserversDuringInit(NamedList<?> args, Collection<ManagedResourceObserver> observers)
throws SolrException {
if (observers == null || observers.isEmpty())

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -76,7 +77,7 @@ public class RestManager {
private static class ManagedResourceRegistration {
String resourceId;
Class<? extends ManagedResource> implClass;
List<ManagedResourceObserver> observers = new ArrayList<>();
Set<ManagedResourceObserver> observers = new LinkedHashSet<>();
private ManagedResourceRegistration(String resourceId,
Class<? extends ManagedResource> implClass,
@ -229,7 +230,7 @@ public class RestManager {
}
// there may be a RestManager, in which case, we want to add this new ManagedResource immediately
if (initializedRestManager != null) {
if (initializedRestManager != null && initializedRestManager.getManagedResourceOrNull(resourceId) == null) {
initializedRestManager.addRegisteredResource(registered.get(resourceId));
}
}