rdblue commented on a change in pull request #166: Update Hive Metastore tables 
for Spark
URL: https://github.com/apache/incubator-iceberg/pull/166#discussion_r277904610
 
 

 ##########
 File path: hive/src/test/java/org/apache/iceberg/hive/HiveTableBaseTest.java
 ##########
 @@ -126,93 +116,91 @@ public void cleanup() {
     }
   }
 
-  private HiveConf hiveConf(Configuration conf, int port) {
-    final HiveConf hiveConf = new HiveConf(conf, this.getClass());
-    hiveConf.set(THRIFT_URIS.getVarname(), "thrift://localhost:" + port);
-    hiveConf.set(WAREHOUSE.getVarname(), "file:" + 
hiveLocalDir.getAbsolutePath());
-    hiveConf.set(WAREHOUSE.getHiveName(), "file:" + 
hiveLocalDir.getAbsolutePath());
-    hiveConf.set(CONNECT_URL_KEY.getVarname(), "jdbc:derby:" + getDerbyPath() 
+ ";create=true");
+  HiveTables tables;
+
+  @Before
+  public void createTestTable() throws Exception {
+    this.tables = new HiveTables(hiveConf);
+    tables.create(schema, partitionSpec, DB_NAME, TABLE_NAME);
+  }
+
+  @After
+  public void dropTestTable() throws Exception {
+    metastoreClient.dropTable(DB_NAME, TABLE_NAME);
+    tables.close();
+    this.tables = null;
+  }
+
+  private static HiveConf hiveConf(Configuration conf, int port) {
+    final HiveConf hiveConf = new HiveConf(conf, HiveTableBaseTest.class);
+    hiveConf.set(HiveConf.ConfVars.METASTOREURIS.varname, 
"thrift://localhost:" + port);
+    hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, "file:" + 
hiveLocalDir.getAbsolutePath());
     return hiveConf;
   }
 
-  private String getDerbyPath() {
+  private static String getDerbyPath() {
     final File metastore_db = new File(hiveLocalDir, "metastore_db");
     return metastore_db.getPath();
   }
 
-  private TServer thriftServer() throws IOException,
-          TTransportException,
-          MetaException,
-          InvocationTargetException,
-          NoSuchMethodException,
-          IllegalAccessException,
-          NoSuchFieldException {
-    final TServerSocketKeepAlive socket = new TServerSocketKeepAlive(new 
TServerSocket(0));
-    this.hiveConf = hiveConf(new Configuration(), 
socket.getServerSocket().getLocalPort());
-    HiveMetaStore.HMSHandler baseHandler = new HiveMetaStore.HMSHandler("new 
db based metaserver", hiveConf);
-    IHMSHandler handler = RetryingHMSHandler.getProxy(hiveConf, baseHandler, 
true);
-    final TTransportFactory transportFactory = new TTransportFactory();
-    final TSetIpAddressProcessor<IHMSHandler> processor = new 
TSetIpAddressProcessor<>(handler);
+  private static TServer thriftServer() throws Exception {
+    TServerSocket socket = new TServerSocket(0);
+    HiveTableBaseTest.hiveConf = hiveConf(new Configuration(), 
socket.getServerSocket().getLocalPort());
+    HiveConf serverConf = new HiveConf(hiveConf);
+    serverConf.set(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, 
"jdbc:derby:" + getDerbyPath() + ";create=true");
+    HiveMetaStore.HMSHandler baseHandler = new HiveMetaStore.HMSHandler("new 
db based metaserver", serverConf);
+    //IHMSHandler handler = RetryingHMSHandler.getProxy(serverConf, 
baseHandler, false);
 
     TThreadPoolServer.Args args = new TThreadPoolServer.Args(socket)
-            .processor(processor)
-            .transportFactory(transportFactory)
+            .processor(new TSetIpAddressProcessor<>(baseHandler))
+            .transportFactory(new TTransportFactory())
             .protocolFactory(new TBinaryProtocol.Factory())
             .minWorkerThreads(3)
             .maxWorkerThreads(5);
 
     return new TThreadPoolServer(args);
   }
 
-  private void setupDB(String dbURL) throws SQLException, IOException {
+  private static void setupDB(String dbURL) throws SQLException, IOException {
     Connection connection = DriverManager.getConnection(dbURL);
     ScriptRunner scriptRunner = new ScriptRunner(connection, true, true);
 
-    URL hiveSqlScript = 
getClass().getClassLoader().getResource("hive-schema-3.1.0.derby.sql");
+    URL hiveSqlScript = 
HiveTableBaseTest.class.getClassLoader().getResource("hive-schema-3.1.0.derby.sql");
 
 Review comment:
   I made a small update so this one works with the 1.2.1 code.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to