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 2015/09/02 08:38:32 UTC
svn commit: r1700710 - in /stanbol/branches/release-0.12:
commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/
commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/
enhancement-engines/lucenefstlinking/src/main/java/org/a...
Author: rwesten
Date: Wed Sep 2 06:38:32 2015
New Revision: 1700710
URL: http://svn.apache.org/r1700710
Log:
reverting commit r1700708
Modified:
stanbol/branches/release-0.12/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/ClerezzaRDFParser.java
stanbol/branches/release-0.12/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/FstLinkingEngineComponent.java
stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/IndexConfiguration.java
stanbol/branches/release-0.12/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
Modified: stanbol/branches/release-0.12/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/ClerezzaRDFParser.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/ClerezzaRDFParser.java?rev=1700710&r1=1700709&r2=1700710&view=diff
==============================================================================
--- stanbol/branches/release-0.12/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/ClerezzaRDFParser.java (original)
+++ stanbol/branches/release-0.12/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/clerezza/ClerezzaRDFParser.java Wed Sep 2 06:38:32 2015
@@ -99,7 +99,7 @@ public class ClerezzaRDFParser implement
bNodeId = Integer.toString(bNodeMap.size());
bNodeMap.put((BNode)nl, bNodeId);
}
- return new StringBuilder("_:b").append(bNodeId).toString();
+ return new StringBuilder("_:").append(bNodeId).toString();
} else {
throw new IllegalStateException("Unknwon NonLiteral type "+nl.getClass().getName()+"!");
}
Modified: stanbol/branches/release-0.12/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java?rev=1700710&r1=1700709&r2=1700710&view=diff
==============================================================================
--- stanbol/branches/release-0.12/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java (original)
+++ stanbol/branches/release-0.12/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java Wed Sep 2 06:38:32 2015
@@ -267,6 +267,7 @@ public class SolrServerAdapter {
} finally { //decrease the reference count
core.close();
}
+
}
}
/**
@@ -491,16 +492,14 @@ public class SolrServerAdapter {
CoreRegistration current;
synchronized (registrations) {
CoreRegistration old = registrations.remove(name);
- //NOTE: we register the new before unregistering the old to allow
- // uninterrupted usage of this core by components.
- current = new CoreRegistration(name,core);
- log.info(" ... register {}",current);
- registrations.put(name,current);
if(old != null){
sameCore = this.server.getCore(name); //2nd reference to the core
log.info(" ... unregister old registration {}", old);
old.unregister();
}
+ current = new CoreRegistration(name,core);
+ log.info(" ... register {}",current);
+ registrations.put(name,current);
}
return current.getServiceReference();
} finally {
Modified: stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/FstLinkingEngineComponent.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/FstLinkingEngineComponent.java?rev=1700710&r1=1700709&r2=1700710&view=diff
==============================================================================
--- stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/FstLinkingEngineComponent.java (original)
+++ stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/FstLinkingEngineComponent.java Wed Sep 2 06:38:32 2015
@@ -664,12 +664,8 @@ public class FstLinkingEngineComponent {
@Override
public void removedService(ServiceReference reference, Object service) {
log.info(" ... SolrCore for {} was removed!", reference);
- if(reference.equals(FstLinkingEngineComponent.this.indexReference)){
- //try to get an other serviceReference from the tracker
- updateEngineRegistration(solrServerTracker.getServiceReference(), null);
- } else {
- log.info(" - removed SolrCore was not used for FST linking");
- }
+ //try to get an other serviceReference from the tracker
+ updateEngineRegistration(solrServerTracker.getServiceReference(), null);
super.removedService(reference, service);
}
@@ -732,11 +728,6 @@ public class FstLinkingEngineComponent {
return; //and return
}
BundleContext bundleContext = this.bundleContext;
- //We need to keep the old configuration vars for unregistering the
- //current engine (see #unregisterEngine(..) method)
- ServiceRegistration<?> oldEngineRegistration = this.engineRegistration;
- SolrCore oldSolrCore = this.solrCore;
- IndexConfiguration oldIndexConfig = this.indexConfig;
synchronized (this) { //init one after the other in case of multiple calls
SolrCore core;
IndexConfiguration indexConfig; // the indexConfig build by this call
@@ -744,15 +735,21 @@ public class FstLinkingEngineComponent {
if(bundleContext == null){ //already deactivated
return; //NOTE: unregistering is done in finally block
}
- core = getSolrCore(server);
+ if(reference != null){
+ if(reference.equals(this.solrServerReference)){
+ //use the current core
+ core = solrCore;
+ } else { //get the SolrCore from the EmbeddedSolrServer
+ core = getSolrCore(server);
+ }
+ } else {//SolrCore not available
+ core = null;
+ }
if(core == null){ //no SolrCore
log.info(" - SolrCore {} present", this.solrCore == null ?
"not yet" : "no longer");
return; //NOTE: unregistering is done in finally block
- } else { //- we do have a SolrCore
- log.info(" - solrCore (name: {} | indexDir: {}",
- core.getName(), core.getIndexDir());
- }
+ } //else - we do have a SolrCore
//File fstDir = new File(dataDir,"fst");
//now collect the FST configuration
indexConfig = new IndexConfiguration(fstConfig, core, fieldEncoding);
@@ -794,48 +791,54 @@ public class FstLinkingEngineComponent {
Arrays.toString(langArray));
}
}
- //check if we need to create some FST files
- for(CorpusInfo fstInfo : indexConfig.getCorpora()){
- //check if the fst does not exist and the fstInfo allows creation
- if(!fstInfo.fst.exists() && fstInfo.allowCreation){
- //create a task on the FST corpus creation service
- fstCreatorService.execute(new CorpusCreationTask(indexConfig, fstInfo));
- }
- }
- //set the default linking corpora
- String defaultLanguage = entityLinkerConfig.getDefaultLanguage();
- if(defaultLanguage == null){
- defaultLanguage = ""; //FST uses an empty string for the default
- }
- CorpusInfo defaultCoprous = indexConfig.getCorpus(defaultLanguage);
- if(defaultCoprous != null){
- log.info(" ... set '{}' as default FST Corpus: {}", defaultCoprous.language, defaultCoprous);
- indexConfig.setDefaultCorpus(defaultCoprous);
- } else {
- log.info(" ... no corpus for default language {} available", defaultCoprous);
- }
- //create the new configuration
-
- //set the newly configured instances to the fields
- this.indexConfig = indexConfig;
- this.solrServerReference = reference;
- this.solrCore = core;
- //create the new FST linking engine instance
- FstLinkingEngine engine = new FstLinkingEngine(engineName,
- linkingMode, indexConfig,
- textProcessingConfig, entityLinkerConfig, nerTypeMappings);
- //register it as a service
- String[] services = new String [] {
- EnhancementEngine.class.getName(),
- ServiceProperties.class.getName()};
- log.info(" ... register {}: {}", engine.getClass().getSimpleName(),engineName);
- this.engineRegistration = bundleContext.registerService(services,engine, engineMetadata);
} finally {
//in any case (even an Exception) ensure that the current
//engine registration is unregistered and the currently used
//SolrCore is unregistered!
- unregisterEngine(oldEngineRegistration, oldIndexConfig, oldSolrCore);
+ unregisterEngine();
+ }
+ //check if we need to create some FST files
+ for(CorpusInfo fstInfo : indexConfig.getCorpora()){
+ //check if the fst does not exist and the fstInfo allows creation
+ if(!fstInfo.fst.exists() && fstInfo.allowCreation){
+ //create a task on the FST corpus creation service
+ fstCreatorService.execute(new CorpusCreationTask(indexConfig, fstInfo));
+ }
+ }
+ //set the default linking corpora
+ String defaultLanguage = entityLinkerConfig.getDefaultLanguage();
+ if(defaultLanguage == null){
+ defaultLanguage = ""; //FST uses an empty string for the default
}
+ CorpusInfo defaultCoprous = indexConfig.getCorpus(defaultLanguage);
+ if(defaultCoprous != null){
+ log.info(" ... set '{}' as default FST Corpus: {}", defaultCoprous.language, defaultCoprous);
+ indexConfig.setDefaultCorpus(defaultCoprous);
+ } else {
+ log.info(" ... no corpus for default language {} available", defaultCoprous);
+ }
+
+ //check if the old configuration is still present
+ if(this.engineRegistration != null){
+ unregisterEngine();
+ }
+
+ //create the new configuration
+
+ //set the newly configured instances to the fields
+ this.indexConfig = indexConfig;
+ this.solrServerReference = reference;
+ this.solrCore = core;
+ //create the new FST linking engine instance
+ FstLinkingEngine engine = new FstLinkingEngine(engineName,
+ linkingMode, indexConfig,
+ textProcessingConfig, entityLinkerConfig, nerTypeMappings);
+ //register it as a service
+ String[] services = new String [] {
+ EnhancementEngine.class.getName(),
+ ServiceProperties.class.getName()};
+ log.info(" ... register {}: {}", engine.getClass().getSimpleName(),engineName);
+ this.engineRegistration = bundleContext.registerService(services,engine, engineMetadata);
}
@@ -863,6 +866,7 @@ public class FstLinkingEngineComponent {
try {
FileUtils.forceMkdir(fstDir);
} catch (IOException e) {
+ unregisterEngine(); //unregister current engine and clean up
throw new IllegalStateException("Unable to create Directory for"
+ "storing the FST files at location '"+fstDir+"'.");
}
@@ -875,32 +879,35 @@ public class FstLinkingEngineComponent {
* unregisters the Engines service registration, closes the SolrCore and
* rests the fields. If no engine is registered this does nothing!
*/
- private void unregisterEngine(ServiceRegistration<?> engineRegistration,
- IndexConfiguration indexConfig, SolrCore solrCore) {
- log.debug("> clean up (old) FSTLinkingEngine instance ...");
+ private void unregisterEngine() {
+ log.debug("> in unregisterEngine() ...");
//use local copies for method calls to avoid concurrency issues
+ ServiceRegistration engineRegistration = this.engineRegistration;
if(engineRegistration != null){
log.info(" ... unregister Lucene FSTLinkingEngine {}",engineName);
try {
engineRegistration.unregister();
} catch(IllegalStateException e) {
- //already unregistered ... can be ignored
- log.debug("Unexpected State: Service for FSTLinkingEngine "
+ //this is unexpected but can be ignored
+ log.info("Unexpected State: Service for FSTLinkingEngine "
+ engineName+" was already deactivated.", e);
}
this.engineRegistration = null; //reset the field
} else {
- log.debug(" ... no (old) engine registration present");
+ log.debug(" ... no engine registration present");
}
- if(solrCore != null){
- log.debug(" ... unregister SolrCore {}", solrCore.getName());
- solrCore.close(); //decrease the reference count!!
+ solrServerReference = null;
+ SolrCore solrServer = this.solrCore;
+ if(solrServer != null){
+ log.debug(" ... unregister SolrCore {}", solrServer.getName());
+ solrServer.close(); //decrease the reference count!!
+ this.solrCore = null; //rest the field
} else {
- log.debug(" ... no (old) SolrCore present");
+ log.debug(" ... no SolrCore present");
}
//deactivate the index configuration if present
if(indexConfig != null){
- log.debug(" ... deactivate (old) IndexingConfiguration");
+ log.debug(" ... deactivate IndexingConfiguration");
indexConfig.deactivate();
//close the EntityCacheManager (if present
EntityCacheManager cacheManager = indexConfig.getEntityCacheManager();
@@ -908,8 +915,9 @@ public class FstLinkingEngineComponent {
log.debug(" ... deactivate {}", cacheManager.getClass().getSimpleName());
cacheManager.close();
}
+ indexConfig = null;
} else {
- log.debug(" ... no (old) index config present");
+ log.debug(" ... no index config present");
}
}
@@ -1006,11 +1014,8 @@ public class FstLinkingEngineComponent {
unregisterFailier = true;
}
if(unregisterFailier){
- unregisterEngine(this.engineRegistration,this.indexConfig,this.solrCore);
+ unregisterEngine();
}
- this.engineRegistration = null;
- this.indexConfig = null;
- this.solrCore = null;
}
/**
Modified: stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/IndexConfiguration.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/IndexConfiguration.java?rev=1700710&r1=1700709&r2=1700710&view=diff
==============================================================================
--- stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/IndexConfiguration.java (original)
+++ stanbol/branches/release-0.12/enhancement-engines/lucenefstlinking/src/main/java/org/apache/stanbol/enhancer/engines/lucenefstlinking/IndexConfiguration.java Wed Sep 2 06:38:32 2015
@@ -489,6 +489,7 @@ public class IndexConfiguration {
Map<String,File> presentFstFiles = new HashMap<String,File>();
WildcardFileFilter fstFilter = new WildcardFileFilter(
fstName+".*.fst");
+ @SuppressWarnings("unchecked")
Iterator<File> fstFiles = FileUtils.iterateFiles(fstDirectory, fstFilter, null);
while(fstFiles.hasNext()){
File fstFile = fstFiles.next();
Modified: stanbol/branches/release-0.12/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml?rev=1700710&r1=1700709&r2=1700710&view=diff
==============================================================================
--- stanbol/branches/release-0.12/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml (original)
+++ stanbol/branches/release-0.12/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml Wed Sep 2 06:38:32 2015
@@ -338,20 +338,20 @@
</bundle>
<!-- JSON-LD support for Clerezza -->
- <!-- bundle>
+ <bundle> <!-- this for now provides the Parser/Serializer provider for Clerezza -->
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.jsonld</artifactId>
<version>0.12.1-SNAPSHOT</version>
- </bundle> -->
+ </bundle>
<bundle> <!-- this will (in a future version replace the above) -->
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java-clerezza</artifactId>
- <version>0.6.1-SNAPSHOT</version>
+ <version>0.6.0</version>
</bundle>
<bundle> <!-- core jsonld library used by jena, sesame and now clerezza -->
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
- <version>0.6.1-SNAPSHOT</version>
+ <version>0.6.0</version>
</bundle>
</startLevel>
@@ -400,6 +400,12 @@
<artifactId>org.apache.stanbol.commons.owl</artifactId>
<version>0.12.1-SNAPSHOT</version>
</bundle>
+ <!-- support for JSON-LD
+ <bundle>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.jsonld</artifactId>
+ <version>0.12.1-SNAPSHOT</version>
+ </bundle> -->
<!-- Support for Jobs -->
<bundle>
<groupId>org.apache.stanbol</groupId>