You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/06/13 10:39:12 UTC
svn commit: r1492566 - in
/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr:
RegisteredSolrServerTracker.java SolrServerAdapter.java
Author: rwesten
Date: Thu Jun 13 08:39:11 2013
New Revision: 1492566
URL: http://svn.apache.org/r1492566
Log:
STANBOL-1081: Improvements on how Registered SolrCores are unregistererd. Logging improvements to further investigate the issue of multiple registrations/unregistrations of SolrCores
Modified:
stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java
stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
Modified: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java?rev=1492566&r1=1492565&r2=1492566&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java (original)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java Thu Jun 13 08:39:11 2013
@@ -141,12 +141,12 @@ public class RegisteredSolrServerTracker
return null;
}
coreName = core.getName();
- CoreDescriptor descriptior = core.getCoreDescriptor();
- if(descriptior == null){ //core not registered with a container!
+ CoreDescriptor descriptor = core.getCoreDescriptor();
+ if(descriptor == null){ //core not registered with a container!
context.ungetService(reference);
return null; //ignore
} else {
- server = descriptior.getCoreContainer();
+ server = descriptor.getCoreContainer();
}
} else {
if(service instanceof CoreContainer){
Modified: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java?rev=1492566&r1=1492565&r2=1492566&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java (original)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java Thu Jun 13 08:39:11 2013
@@ -158,6 +158,7 @@ public class SolrServerAdapter {
@Override
public void preClose(SolrCore core) {
+ log.debug(" ... in preClose SolrCore {}", core.getName());
Collection<String> names = server.getCoreNames(core);
if(names != null){
synchronized (registrations) {
@@ -169,8 +170,10 @@ public class SolrServerAdapter {
if(coreRegistration.getCore().equals(core)){
log.info("unregister Core with name '{}' based on call to" +
" CloseHook#close()",name);
- registrations.remove(name);
- coreRegistration.unregister();
+ CoreRegistration removed = registrations.remove(name);
+ if(removed != null){
+ removed.unregister();
+ } //else removed in the meantime by an other thread ... nothing to do
} else {
log.info("Core registered for name '{}' is not the same as" +
" parsed to CloseHook#close()",name);
@@ -276,6 +279,7 @@ public class SolrServerAdapter {
* this instance. This will also cause all OSGI services to be unregistered
*/
public void shutdown(){
+ log.debug(" ... in shutdown for SolrServer {}",serverProperties.getServerName());
Collection<CoreRegistration> coreRegistrations;
synchronized (registrations) {
coreRegistrations = new ArrayList<CoreRegistration>(registrations.values());
@@ -481,10 +485,11 @@ public class SolrServerAdapter {
//the reference count of the SolrCore does not reach 0)
CoreRegistration current = new CoreRegistration(name,core);
CoreRegistration old = registrations.put(name,current);
+ log.info("added Registration for SolrCore {}",name);
if(old != null){
+ log.info(" ... unregister old registration {}", old);
old.unregister();
}
- log.info("added Registration for SolrCore {}",name);
return current.getServiceReference();
}
@@ -703,7 +708,7 @@ public class SolrServerAdapter {
*/
private class CoreRegistration {
protected final String name;
- protected final SolrCore core;
+ protected SolrCore core;
private ServiceRegistration registration;
/**
* Creates and registers a {@link CoreRegistration}
@@ -767,15 +772,26 @@ public class SolrServerAdapter {
registration = null;
}
}
-
try {
- tmp.unregister(); //unregister the service
- } catch (IllegalStateException e) {
- log.info(String.format(
- "Looks like that the registration for SolrCore %s was already unregisterd",
- name),e);
- } finally {
- core.close(); //close the core to decrease the refernece count!!
+ if(tmp != null){
+ try {
+ tmp.unregister(); //unregister the service
+ } catch (IllegalStateException e) {
+ log.info(String.format(
+ "Looks like that the registration for SolrCore %s was already unregisterd",
+ name),e);
+ }
+ }
+ } finally { //ensure that the core is closed to decrease the reference count
+ //ensure this is only done once
+ SolrCore core;
+ synchronized (this) {
+ core = this.core; //copy over to a local variable
+ this.core = null; //set the field to null
+ }
+ if(core != null){
+ core.close(); //decrease the reference count!!
+ }
}
}
/**