[ 
https://issues.apache.org/jira/browse/DRILL-6436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16488278#comment-16488278
 ] 

ASF GitHub Bot commented on DRILL-6436:
---------------------------------------

Ben-Zvi closed pull request #1282: DRILL-6436: Storage Plugin to have name and 
context moved to Abstract…
URL: https://github.com/apache/drill/pull/1282
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseStoragePlugin.java
 
b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseStoragePlugin.java
index 62f351c458..18428c6907 100644
--- 
a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseStoragePlugin.java
+++ 
b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseStoragePlugin.java
@@ -38,7 +38,6 @@
 public class HBaseStoragePlugin extends AbstractStoragePlugin {
   private static final HBaseConnectionManager hbaseConnectionManager = 
HBaseConnectionManager.INSTANCE;
 
-  private final DrillbitContext context;
   private final HBaseStoragePluginConfig storeConfig;
   private final HBaseSchemaFactory schemaFactory;
   private final HBaseConnectionKey connectionKey;
@@ -47,17 +46,13 @@
 
   public HBaseStoragePlugin(HBaseStoragePluginConfig storeConfig, 
DrillbitContext context, String name)
       throws IOException {
-    this.context = context;
+    super(context, name);
     this.schemaFactory = new HBaseSchemaFactory(this, name);
     this.storeConfig = storeConfig;
     this.name = name;
     this.connectionKey = new HBaseConnectionKey();
   }
 
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
   @Override
   public boolean supportsRead() {
     return true;
diff --git 
a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
 
b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
index 1ac1525c22..449a6f90b3 100644
--- 
a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
+++ 
b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
@@ -55,14 +55,12 @@
 
   private final HiveStoragePluginConfig config;
   private HiveSchemaFactory schemaFactory;
-  private final DrillbitContext context;
-  private final String name;
   private final HiveConf hiveConf;
 
-  public HiveStoragePlugin(HiveStoragePluginConfig config, DrillbitContext 
context, String name) throws ExecutionSetupException {
+  public HiveStoragePlugin(HiveStoragePluginConfig config, DrillbitContext 
context, String name)
+      throws ExecutionSetupException {
+    super(context, name);
     this.config = config;
-    this.context = context;
-    this.name = name;
     this.hiveConf = createHiveConf(config.getHiveConfigOverride());
     this.schemaFactory = new HiveSchemaFactory(this, name, hiveConf);
   }
@@ -75,14 +73,6 @@ public HiveStoragePluginConfig getConfig() {
     return config;
   }
 
-  public String getName(){
-    return name;
-  }
-
-  public DrillbitContext getContext() {
-    return context;
-  }
-
   @Override
   public HiveScan getPhysicalScan(String userName, JSONOptions selection, 
List<SchemaPath> columns) throws IOException {
     HiveReadEntry hiveReadEntry = selection.getListWith(new ObjectMapper(), 
new TypeReference<HiveReadEntry>(){});
@@ -150,7 +140,7 @@ public synchronized void registerSchemas(SchemaConfig 
schemaConfig, SchemaPlus p
       logger.warn("Schema factory forced close failed, error ignored", t);
     }
     try {
-      schemaFactory = new HiveSchemaFactory(this, name, hiveConf);
+      schemaFactory = new HiveSchemaFactory(this, getName(), hiveConf);
     } catch (ExecutionSetupException e) {
       throw new DrillRuntimeException(e);
     }
diff --git 
a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
 
b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
index 7a58f7c13b..c38ea3b97b 100755
--- 
a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
+++ 
b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
@@ -77,17 +77,14 @@
 
 
   private final JdbcStorageConfig config;
-  private final DrillbitContext context;
   private final DataSource source;
-  private final String name;
   private final SqlDialect dialect;
   private final DrillJdbcConvention convention;
 
 
   public JdbcStoragePlugin(JdbcStorageConfig config, DrillbitContext context, 
String name) {
-    this.context = context;
+    super(context, name);
     this.config = config;
-    this.name = name;
     BasicDataSource source = new BasicDataSource();
     source.setDriverClassName(config.getDriver());
     source.setUrl(config.getUrl());
@@ -429,8 +426,8 @@ public Table getTable(String name) {
 
   @Override
   public void registerSchemas(SchemaConfig config, SchemaPlus parent) {
-    JdbcCatalogSchema schema = new JdbcCatalogSchema(name);
-    SchemaPlus holder = parent.add(name, schema);
+    JdbcCatalogSchema schema = new JdbcCatalogSchema(getName());
+    SchemaPlus holder = parent.add(getName(), schema);
     schema.setHolder(holder);
   }
 
@@ -440,14 +437,6 @@ public JdbcStorageConfig getConfig() {
     return config;
   }
 
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
-  public String getName() {
-    return this.name;
-  }
-
   @Override
   public boolean supportsRead() {
     return true;
diff --git 
a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaStoragePlugin.java
 
b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaStoragePlugin.java
index 8986ea7f60..157e3673ea 100644
--- 
a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaStoragePlugin.java
+++ 
b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaStoragePlugin.java
@@ -44,21 +44,16 @@
   private static final Logger logger = 
LoggerFactory.getLogger(KafkaStoragePlugin.class);
   private final KafkaSchemaFactory kafkaSchemaFactory;
   private final KafkaStoragePluginConfig config;
-  private final DrillbitContext context;
   private final Closer closer = Closer.create();
 
   public KafkaStoragePlugin(KafkaStoragePluginConfig config, DrillbitContext 
context, String name)
       throws ExecutionSetupException {
+    super(context, name);
     logger.debug("Initializing {}", KafkaStoragePlugin.class.getName());
     this.config = config;
-    this.context = context;
     this.kafkaSchemaFactory = new KafkaSchemaFactory(this, name);
   }
 
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
   @Override
   public KafkaStoragePluginConfig getConfig() {
     return this.config;
diff --git 
a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduStoragePlugin.java
 
b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduStoragePlugin.java
index a3863931fa..b1ae708265 100644
--- 
a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduStoragePlugin.java
+++ 
b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduStoragePlugin.java
@@ -32,20 +32,16 @@
 public class KuduStoragePlugin extends AbstractStoragePlugin {
   static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(KuduStoragePlugin.class);
 
-  private final DrillbitContext context;
   private final KuduStoragePluginConfig engineConfig;
   private final KuduSchemaFactory schemaFactory;
 
-  @SuppressWarnings("unused")
-  private final String name;
   private final KuduClient client;
 
   public KuduStoragePlugin(KuduStoragePluginConfig configuration, 
DrillbitContext context, String name)
       throws IOException {
-    this.context = context;
+    super(context, name);
     this.schemaFactory = new KuduSchemaFactory(this, name);
     this.engineConfig = configuration;
-    this.name = name;
     this.client = new 
KuduClient.KuduClientBuilder(configuration.getMasterAddresses()).build();
   }
 
@@ -63,10 +59,6 @@ public void close() throws Exception {
     client.close();
   }
 
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
   @Override
   public boolean supportsRead() {
     return true;
@@ -93,4 +85,4 @@ public KuduStoragePluginConfig getConfig() {
     return engineConfig;
   }
 
-}
\ No newline at end of file
+}
diff --git 
a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoStoragePlugin.java
 
b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoStoragePlugin.java
index c7d0f6c3b5..8ab0c554ee 100644
--- 
a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoStoragePlugin.java
+++ 
b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoStoragePlugin.java
@@ -54,7 +54,6 @@
   static final Logger logger = LoggerFactory
       .getLogger(MongoStoragePlugin.class);
 
-  private final DrillbitContext context;
   private final MongoStoragePluginConfig mongoConfig;
   private final MongoSchemaFactory schemaFactory;
   private final Cache<MongoCnxnKey, MongoClient> addressClientMap;
@@ -63,7 +62,7 @@
   public MongoStoragePlugin(MongoStoragePluginConfig mongoConfig,
       DrillbitContext context, String name) throws IOException,
       ExecutionSetupException {
-    this.context = context;
+    super(context, name);
     this.mongoConfig = mongoConfig;
     this.clientURI = new MongoClientURI(this.mongoConfig.getConnection());
     this.addressClientMap = CacheBuilder.newBuilder()
@@ -72,10 +71,6 @@ public MongoStoragePlugin(MongoStoragePluginConfig 
mongoConfig,
     this.schemaFactory = new MongoSchemaFactory(this, name);
   }
 
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
   @Override
   public MongoStoragePluginConfig getConfig() {
     return mongoConfig;
diff --git 
a/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/OpenTSDBStoragePlugin.java
 
b/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/OpenTSDBStoragePlugin.java
index 176dff0610..2de763bdc5 100644
--- 
a/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/OpenTSDBStoragePlugin.java
+++ 
b/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/OpenTSDBStoragePlugin.java
@@ -31,15 +31,14 @@
 
 public class OpenTSDBStoragePlugin extends AbstractStoragePlugin {
 
-  private final DrillbitContext context;
-
   private final OpenTSDBStoragePluginConfig engineConfig;
   private final OpenTSDBSchemaFactory schemaFactory;
 
   private final ServiceImpl db;
 
-  public OpenTSDBStoragePlugin(OpenTSDBStoragePluginConfig configuration, 
DrillbitContext context, String name) throws IOException {
-    this.context = context;
+  public OpenTSDBStoragePlugin(OpenTSDBStoragePluginConfig configuration, 
DrillbitContext context, String name)
+      throws IOException {
+    super(context, name);
     this.schemaFactory = new OpenTSDBSchemaFactory(this, name);
     this.engineConfig = configuration;
     this.db = new ServiceImpl(configuration.getConnection());
@@ -70,8 +69,4 @@ public void registerSchemas(SchemaConfig schemaConfig, 
SchemaPlus parent) throws
   public ServiceImpl getClient() {
     return db;
   }
-
-  DrillbitContext getContext() {
-    return this.context;
-  }
 }
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStoragePlugin.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStoragePlugin.java
index 548518f87e..17c132c18e 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStoragePlugin.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStoragePlugin.java
@@ -29,13 +29,20 @@
 import org.apache.drill.exec.planner.PlannerPhase;
 
 import com.google.common.collect.ImmutableSet;
+import org.apache.drill.exec.server.DrillbitContext;
 
 /** Abstract class for StorePlugin implementations.
  * See StoragePlugin for description of the interface intent and its methods.
  */
 public abstract class AbstractStoragePlugin implements StoragePlugin {
 
-  protected AbstractStoragePlugin() { }
+  private final DrillbitContext context;
+  private final String name;
+
+  protected AbstractStoragePlugin(DrillbitContext inContext, String inName) {
+    this.context = inContext;
+    this.name = inName;
+  }
 
   @Override
   public boolean supportsRead() {
@@ -49,7 +56,7 @@ public boolean supportsWrite() {
 
   /**
    * @deprecated Marking for deprecation in next major version release. Use
-   *             {@link 
#getPhysicalOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
+   *             {@link 
#getOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
    */
   @Override
   @Deprecated
@@ -59,7 +66,7 @@ public boolean supportsWrite() {
 
   /**
    * @deprecated Marking for deprecation in next major version release. Use
-   *             {@link 
#getPhysicalOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
+   *             {@link 
#getOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
    */
   @Deprecated
   public Set<? extends RelOptRule> 
getLogicalOptimizerRules(OptimizerRulesContext optimizerContext) {
@@ -68,7 +75,7 @@ public boolean supportsWrite() {
 
   /**
    * @deprecated Marking for deprecation in next major version release. Use
-   *             {@link 
#getPhysicalOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
+   *             {@link 
#getOptimizerRules(org.apache.drill.exec.ops.OptimizerRulesContext, 
org.apache.drill.exec.planner.PlannerPhase)}
    */
   @Deprecated
   public Set<? extends RelOptRule> 
getPhysicalOptimizerRules(OptimizerRulesContext optimizerRulesContext) {
@@ -110,4 +117,12 @@ public void start() throws IOException { }
 
   @Override
   public void close() throws Exception { }
+
+  public DrillbitContext getContext() {
+    return context;
+  }
+
+  public String getName() {
+    return name;
+  }
 }
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemPlugin.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemPlugin.java
index 5d382fe376..734ab735d9 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemPlugin.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemPlugin.java
@@ -62,7 +62,9 @@
   private final Configuration fsConf;
   private final LogicalPlanPersistence lpPersistance;
 
-  public FileSystemPlugin(FileSystemConfig config, DrillbitContext context, 
String name) throws ExecutionSetupException{
+  public FileSystemPlugin(FileSystemConfig config, DrillbitContext context, 
String name)
+      throws ExecutionSetupException{
+    super(context, name);
     this.config = config;
     this.lpPersistance = context.getLpPersistence();
 
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaStoragePlugin.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaStoragePlugin.java
index 1fd42e88e7..fc1f01ab81 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaStoragePlugin.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaStoragePlugin.java
@@ -45,13 +45,10 @@
   static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(InfoSchemaStoragePlugin.class);
 
   private final InfoSchemaConfig config;
-  private final DrillbitContext context;
-  private final String name;
 
   public InfoSchemaStoragePlugin(InfoSchemaConfig config, DrillbitContext 
context, String name){
+    super(context, name);
     this.config = config;
-    this.context = context;
-    this.name = name;
   }
 
   @Override
@@ -62,7 +59,7 @@ public boolean supportsRead() {
   @Override
   public InfoSchemaGroupScan getPhysicalScan(String userName, JSONOptions 
selection, List<SchemaPath> columns)
       throws IOException {
-    InfoSchemaTableType table = selection.getWith(context.getLpPersistence(),  
InfoSchemaTableType.class);
+    InfoSchemaTableType table = 
selection.getWith(getContext().getLpPersistence(),  InfoSchemaTableType.class);
     return new InfoSchemaGroupScan(table);
   }
 
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/MockStorageEngine.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/MockStorageEngine.java
index 8dd4e2e4e5..fb4c9e34ef 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/MockStorageEngine.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/MockStorageEngine.java
@@ -56,6 +56,7 @@
   private final MockSchema schema;
 
   public MockStorageEngine(MockStorageEngineConfig configuration, 
DrillbitContext context, String name) {
+    super(context, name);
     this.configuration = configuration;
     this.schema = new MockSchema(this, name);
   }
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
index 21ed028a84..10e082fd61 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTablePlugin.java
@@ -32,7 +32,6 @@
 import org.apache.drill.exec.store.SchemaConfig;
 import org.apache.drill.exec.store.pojo.PojoDataType;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
@@ -45,15 +44,12 @@
 
   public static final String SYS_SCHEMA_NAME = "sys";
 
-  private final DrillbitContext context;
-  private final String name;
   private final SystemTablePluginConfig config;
   private final SystemSchema schema = new SystemSchema();
 
   public SystemTablePlugin(SystemTablePluginConfig config, DrillbitContext 
context, String name) {
+    super(context, name);
     this.config = config;
-    this.context = context;
-    this.name = name;
   }
 
   @Override
@@ -61,11 +57,6 @@ public StoragePluginConfig getConfig() {
     return config;
   }
 
-  @JsonIgnore
-  public DrillbitContext getContext() {
-    return this.context;
-  }
-
   @Override
   public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) {
     parent.add(schema.getName(), schema);
@@ -73,7 +64,7 @@ public void registerSchemas(SchemaConfig schemaConfig, 
SchemaPlus parent) {
 
   @Override
   public AbstractGroupScan getPhysicalScan(String userName, JSONOptions 
selection, List<SchemaPath> columns) {
-    SystemTable table = selection.getWith(context.getLpPersistence(), 
SystemTable.class);
+    SystemTable table = selection.getWith(getContext().getLpPersistence(), 
SystemTable.class);
     return new SystemTableScan(table, this);
   }
 
@@ -102,7 +93,7 @@ public SystemSchema() {
     public DrillTable getTable(String name) {
       for (SystemTable table : SystemTable.values()) {
         if (table.getTableName().equalsIgnoreCase(name)) {
-          return new StaticDrillTable(SystemTablePlugin.this.name, 
SystemTablePlugin.this, TableType.SYSTEM_TABLE,
+          return new StaticDrillTable(getName(), SystemTablePlugin.this, 
TableType.SYSTEM_TABLE,
             table, new PojoDataType(table.getPojoClass()));
         }
       }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Store context and name in AbstractStoragePlugin instead of replicating fields 
> in each StoragePlugin
> ---------------------------------------------------------------------------------------------------
>
>                 Key: DRILL-6436
>                 URL: https://issues.apache.org/jira/browse/DRILL-6436
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Timothy Farkas
>            Assignee: Timothy Farkas
>            Priority: Major
>             Fix For: 1.14.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to