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/12/06 17:50:32 UTC

svn commit: r1548594 - in /stanbol/trunk/entityhub/indexing: core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java

Author: rwesten
Date: Fri Dec  6 16:50:31 2013
New Revision: 1548594

URL: http://svn.apache.org/r1548594
Log:
STANBOL-1200: if the SesameRepository is parsed in the constructor it is no longer shutdown in close; The IndexerImpl now calls close on all indexing components

Modified:
    stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java
    stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java

Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java?rev=1548594&r1=1548593&r2=1548594&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java Fri Dec  6 16:50:31 2013
@@ -489,7 +489,11 @@ public class IndexerImpl implements Inde
             errorEntityQueue, log));
         //start post-processing and wait until it has finished
         startAndWait(activeIndexingDeamons);        
-        
+        //close all post processors
+        for(EntityProcessor ep : entityPostProcessors){
+            ep.close();
+        }
+
         
         setState(State.POSTPROCESSED);
     }
@@ -550,8 +554,22 @@ public class IndexerImpl implements Inde
             log.info("finalisation started ...");
         }
         indexingDestination.finalise();
+        //close the source and the destination
+        if(entityIterator != null){
+            entityIterator.close();
+        }
+        if(dataIterable != null){
+            dataIterable.close();
+        }
+        if(dataProvider != null){
+            dataProvider.close();
+        }
+        if(scoreProvider != null){
+            scoreProvider.close();
+        }
         setState(State.FINISHED);
     }
+
     @Override
     public void skipIndexEntities() {
         synchronized (stateSync) { //ensure that two threads do not start the
@@ -651,6 +669,10 @@ public class IndexerImpl implements Inde
         startAndWait(activeIndexingDeamons);
         //close the stream with IDs
         IOUtils.closeQuietly(indexedEntityIdOutputStream);
+        //call close on all indexing components
+        for(EntityProcessor ep : entityProcessors){
+            ep.close();
+        }
         //set the new state to INDEXED
         setState(State.INDEXED);
     }

Modified: stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java?rev=1548594&r1=1548593&r2=1548594&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java (original)
+++ stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java Fri Dec  6 16:50:31 2013
@@ -98,6 +98,7 @@ public class RdfIndexingSource extends A
     protected RdfValueFactory vf = RdfValueFactory.getInstance();
     
     Repository repository;
+    boolean shutdownRepository = false; //if we need to shutdown the repo
     //protected RepositoryConnection connection;
 
     /**
@@ -107,7 +108,8 @@ public class RdfIndexingSource extends A
     public RdfIndexingSource() {}
     
     /**
-     * 
+     * Constructs a {@link RdfIndexingSource} for the parsed parameters. This
+     * expects that {@link #setConfiguration(Map)} is not called
      * @param repository
      * @param contexts
      */
@@ -116,11 +118,7 @@ public class RdfIndexingSource extends A
             throw new IllegalArgumentException("The parsed Repository MUST NOT be NULL!");
         }
         if(!repository.isInitialized()){
-            try {
-                repository.initialize();
-            } catch (RepositoryException e) {
-                throw new IllegalStateException("Unable to Initialise the parsed Repository",e);
-            }
+            throw new IllegalStateException("Parsed Repository is not initialized");
         }
         this.repository = repository;
         this.sesameFactory = repository.getValueFactory();
@@ -183,6 +181,7 @@ public class RdfIndexingSource extends A
             repository = factory.getRepository(repoConfig.getRepositoryImplConfig());
             sesameFactory = repository.getValueFactory();
             repository.initialize();
+            shutdownRepository = true; //we created it, so we do shut it down
         } catch (RepositoryConfigException e) {
             throw new IllegalStateException("Unable to initialise Repository (id: "
                 + repoConfig.getID()+ ", title: "+repoConfig.getTitle() + ", impl: "
@@ -343,13 +342,31 @@ public class RdfIndexingSource extends A
         ungetLdPathConnection();
         ungetEntityDataProviderConnection();
         //finally shutdown the repository
-        try {
-            repository.shutDown();
-        } catch (RepositoryException e) {
-            log.warn("Error while closing Sesame Connection", e);
+        if(shutdownRepository){
+            try {
+                repository.shutDown();
+            } catch (RepositoryException e) {
+                log.warn("Error while closing Sesame Connection", e);
+            }
         }
     }
 
+    public final boolean isFollowBNodeState() {
+        return followBNodeState;
+    }
+
+    public final void setFollowBNodeState(boolean followBNodeState) {
+        this.followBNodeState = followBNodeState;
+    }
+
+    public final boolean isIncludeInferred() {
+        return includeInferred;
+    }
+
+    public final void setIncludeInferred(boolean includeInferred) {
+        this.includeInferred = includeInferred;
+    }
+
     @Override
     public Representation getEntityData(String id) {
         try {