Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill, mail # dev - [01/10] git commit: DRILL-317: StorageEngineRegistry creates a new StorageEngine everytime getEngine() is called


Copy link to this message
-
[01/10] git commit: DRILL-317: StorageEngineRegistry creates a new StorageEngine everytime getEngine() is called
jacques@... 2013-12-02, 04:23
Updated Branches:
  refs/heads/master 3e2000341 -> 4a83dae35
DRILL-317: StorageEngineRegistry creates a new StorageEngine everytime getEngine() is called
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/622aad0f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/622aad0f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/622aad0f

Branch: refs/heads/master
Commit: 622aad0fa976608bbf95a573091fa4429d9b0bf5
Parents: 3e20003
Author: Aditya Kishore <[EMAIL PROTECTED]>
Authored: Sun Dec 1 19:33:34 2013 -0800
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Sun Dec 1 19:33:34 2013 -0800

----------------------------------------------------------------------
 .../drill/exec/store/StorageEngineRegistry.java    | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/622aad0f/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
index bd4efcd..4cc7346 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
@@ -28,12 +28,11 @@ import org.apache.drill.common.exceptions.ExecutionSetupException;
 import org.apache.drill.common.logical.StorageEngineConfig;
 import org.apache.drill.common.util.PathScanner;
 import org.apache.drill.exec.ExecConstants;
-import org.apache.drill.exec.exception.SetupException;
 import org.apache.drill.exec.server.DrillbitContext;
 
 public class StorageEngineRegistry {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StorageEngineRegistry.class);
-  
+
   private Map<Object, Constructor<? extends StorageEngine>> availableEngines = new HashMap<Object, Constructor<? extends StorageEngine>>();
   private Map<StorageEngineConfig, StorageEngine> activeEngines = new HashMap<StorageEngineConfig, StorageEngine>();
 
@@ -42,7 +41,7 @@ public class StorageEngineRegistry {
     init(context.getConfig());
     this.context = context;
   }
-  
+
   @SuppressWarnings("unchecked")
   public void init(DrillConfig config){
     Collection<Class<? extends StorageEngine>> engines = PathScanner.scanForImplementations(StorageEngine.class, config.getStringList(ExecConstants.STORAGE_ENGINE_SCAN_PACKAGES));
@@ -63,21 +62,23 @@ public class StorageEngineRegistry {
       }
     }
   }
-  
-  public StorageEngine getEngine(StorageEngineConfig engineConfig) throws ExecutionSetupException{
+
+  public synchronized StorageEngine getEngine(StorageEngineConfig engineConfig) throws ExecutionSetupException{
     StorageEngine engine = activeEngines.get(engineConfig);
     if(engine != null) return engine;
     Constructor<? extends StorageEngine> c = availableEngines.get(engineConfig.getClass());
     if(c == null) throw new ExecutionSetupException(String.format("Failure finding StorageEngine constructor for config %s", engineConfig));
     try {
-      return c.newInstance(engineConfig, context);
+      engine = c.newInstance(engineConfig, context);
+      activeEngines.put(engineConfig, engine);
+      return engine;
     } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
       Throwable t = e instanceof InvocationTargetException ? ((InvocationTargetException)e).getTargetException() : e;
       if(t instanceof ExecutionSetupException) throw ((ExecutionSetupException) t);
       throw new ExecutionSetupException(String.format("Failure setting up new storage engine configuration for config %s", engineConfig), t);
     }
   }
-  
 
-  
+
+
 }