Merge branch 'branch_8x' of https://gitbox.apache.org/repos/asf/lucene-solr into branch_8x

This commit is contained in:
Uwe Schindler 2019-04-20 02:58:46 +02:00
commit 8cfda21c50
5 changed files with 19 additions and 36 deletions

View File

@ -60,6 +60,9 @@ Upgrade Notes
* SolrGangliaReporter has been removed from Solr because support for Ganglia has been removed from Dropwizard Metrics 4
due to a transitive dependency on LGPL.
* Custom TransientSolrCoreCache implementations no longer use the Observer/Observable pattern. To notify Solr that
a core has been aged out of the cache, call CoreContainer.queueCoreToClose(SolrCore). See SOLR-13400 for details.
New Features
----------------------
@ -263,6 +266,8 @@ Other Changes
* SOLR-12461: Upgrade Dropwizard Metrics to 4.0.5 release. (ab)
* SOLR-13400: Replace Observable pattern in TransientSolrCoreCache (Erick Erickson)
================== 8.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -1838,6 +1838,11 @@ public class CoreContainer {
return solrCores.isLoadedNotPendingClose(name);
}
// Primarily for transient core when a core is aged out
public void queueCoreToClose(SolrCore coreToClose) {
solrCores.queueCoreToClose(coreToClose);
}
/**
* Gets a solr core descriptor for a core that is not loaded. Note that if the caller calls this on a
* loaded core, the unloaded descriptor will be returned.

View File

@ -33,8 +33,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
@ -42,7 +40,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
class SolrCores implements Observer {
class SolrCores {
private static Object modifyLock = new Object(); // for locking around manipulating any of the core maps.
private final Map<String, SolrCore> cores = new LinkedHashMap<>(); // For "permanent" cores
@ -535,21 +533,9 @@ class SolrCores implements Observer {
}
// Let transient cache implementation tell us when it ages out a core
@Override
public void update(Observable o, Object arg) {
public void queueCoreToClose(SolrCore coreToClose) {
synchronized (modifyLock) {
// Erick Erickson debugging TestLazyCores. With this un-commented, we get no testLazyCores failures.
// SolrCore core = (SolrCore) arg;
// SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
// CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
// cmd.openSearcher = false;
// cmd.waitSearcher = false;
// try {
// core.getUpdateHandler().commit(cmd);
// } catch (IOException e) {
// log.warn("Caught exception trying to close a transient core, ignoring as it should be benign");
// }
pendingCloses.add((SolrCore) arg); // Essentially just queue this core up for closing.
pendingCloses.add(coreToClose); // Essentially just queue this core up for closing.
modifyLock.notifyAll(); // Wakes up closer thread too
}
}

View File

@ -21,7 +21,6 @@ package org.apache.solr.core;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.Set;
import org.apache.http.annotation.Experimental;
@ -65,7 +64,7 @@ import org.apache.http.annotation.Experimental;
* In particular, DO NOT reach into the transientCores structure from a method called to manipulate core descriptors
* or vice-versa.
*/
public abstract class TransientSolrCoreCache extends Observable {
public abstract class TransientSolrCoreCache {
// Gets the core container that encloses this cache.
public abstract CoreContainer getContainer();
@ -115,7 +114,9 @@ public abstract class TransientSolrCoreCache extends Observable {
/**
* Must be called in order to free resources!
*/
public abstract void close();
public void close() {
// Nothing to do for now
}
// These two methods allow custom implementations to communicate arbitrary information as necessary.

View File

@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Observer;
import java.util.Set;
import org.apache.solr.common.util.NamedList;
@ -36,7 +35,6 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
private int cacheSize = NodeConfig.NodeConfigBuilder.DEFAULT_TRANSIENT_CACHE_SIZE;
protected Observer observer;
protected CoreContainer coreContainer;
protected final Map<String, CoreDescriptor> transientDescriptors = new LinkedHashMap<>();
@ -49,8 +47,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
*/
public TransientSolrCoreCacheDefault(final CoreContainer container) {
this.coreContainer = container;
this.observer= coreContainer.solrCores;
NodeConfig cfg = container.getNodeConfig();
if (cfg.getTransientCachePluginInfo() == null) {
// Still handle just having transientCacheSize defined in the body of solr.xml not in a transient handler clause.
@ -80,7 +77,6 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
}
log.info("Allocating transient cache for {} transient cores", cacheSize);
addObserver(this.observer);
// it's possible for cache
if (cacheSize < 0) { // Trap old flag
cacheSize = Integer.MAX_VALUE;
@ -92,9 +88,8 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
protected boolean removeEldestEntry(Map.Entry<String, SolrCore> eldest) {
if (size() > cacheSize) {
SolrCore coreToClose = eldest.getValue();
setChanged();
notifyObservers(coreToClose);
log.info("Closing transient core [{}]", coreToClose.getName());
coreContainer.queueCoreToClose(coreToClose);
return true;
}
return false;
@ -179,15 +174,6 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
return ret;
}
/**
* Must be called in order to free resources!
*/
@Override
public void close() {
deleteObserver(this.observer);
}
// For custom implementations to communicate arbitrary information as necessary.
@Override
public int getStatus(String coreName) { return 0; } //no_op for default handler.