Updated Branches: refs/heads/master b48d0f09a -> 92b98bc6d
DRILL-55: RSERegistry correctly store built engines Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/92b98bc6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/92b98bc6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/92b98bc6 Branch: refs/heads/master Commit: 92b98bc6d987a72f4ddae0cd97d87b5aa612c90d Parents: b48d0f0 Author: David Ribeiro Alves <[email protected]> Authored: Tue Apr 23 08:43:30 2013 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Tue Apr 23 08:43:30 2013 -0700 ---------------------------------------------------------------------- .../org/apache/drill/exec/ref/rse/RSERegistry.java | 4 +- .../org/apache/drill/exec/ref/RSERegistryTest.java | 40 +++++++++++++++ 2 files changed, 43 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/92b98bc6/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rse/RSERegistry.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rse/RSERegistry.java b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rse/RSERegistry.java index 4266aac..33c93c7 100644 --- a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rse/RSERegistry.java +++ b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rse/RSERegistry.java @@ -72,7 +72,9 @@ public class RSERegistry { Constructor<? extends ReferenceStorageEngine> c = availableEngines.get(engineConfig.getClass()); if(c == null) throw new SetupException(String.format("Failure finding StorageEngine constructor for config %s", engineConfig)); try { - return c.newInstance(engineConfig, config); + engine = c.newInstance(engineConfig, config); + activeEngines.put(engineConfig,engine); + return engine; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Throwable t = e instanceof InvocationTargetException ? ((InvocationTargetException)e).getTargetException() : e; if(t instanceof SetupException) throw ((SetupException) t); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/92b98bc6/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/RSERegistryTest.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/RSERegistryTest.java b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/RSERegistryTest.java new file mode 100644 index 0000000..efb3855 --- /dev/null +++ b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/RSERegistryTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +package org.apache.drill.exec.ref; + +import org.apache.drill.common.config.DrillConfig; +import org.apache.drill.common.logical.StorageEngineConfig; +import org.apache.drill.exec.ref.rse.ConsoleRSE; +import org.apache.drill.exec.ref.rse.RSERegistry; +import org.junit.Test; + +import static junit.framework.Assert.assertSame; + + +public class RSERegistryTest { + + @Test + public void testEnginesWithTheSameNameAreEqual() { + DrillConfig config = DrillConfig.create(); + RSERegistry rses = new RSERegistry(config); + StorageEngineConfig hconfig = new ConsoleRSE.ConsoleRSEConfig("console"); + ConsoleRSE engine = (ConsoleRSE) rses.getEngine(hconfig); + ConsoleRSE engine2 = (ConsoleRSE) rses.getEngine(hconfig); + assertSame(engine, engine2); + } +}
