HiveMetastoreBootstrap implements BootstrapHadoop { @Override public org.apache.hadoop.conf.Configuration getConfiguration() { return hiveLocalMetaStore.getHiveConf(); } HiveMetastoreBootstrap();  HiveMetastoreBootstrap(URL url); @Override ComponentMetadata getMetadata(); @Override String getProperties(); @Override void loadConfig(Map<String, String> configs); @Override Bootstrap start(); @Override Bootstrap stop(); @Override org.apache.hadoop.conf.Configuration getConfiguration();  }
@Test public void hiveMetastoreShouldStart() throws InterruptedException, NotFoundServiceException { Assertions.assertThat(Utils.available("127.0.0.1", 20102)).isFalse(); try { HiveMetaStoreClient hiveClient = new HiveMetaStoreClient((HiveConf) ((BootstrapHadoop) HadoopBootstrap.INSTANCE.getService("HIVEMETA")).getConfiguration()); hiveClient.dropTable(configuration.getString(HiveConfig.HIVE_TEST_DATABASE_NAME_KEY), configuration.getString(HiveConfig.HIVE_TEST_TABLE_NAME_KEY), true, true); List<FieldSchema> cols = new ArrayList<>(); cols.add(new FieldSchema("id", serdeConstants.INT_TYPE_NAME, "")); cols.add(new FieldSchema("msg", serdeConstants.STRING_TYPE_NAME, "")); String location = new File(configuration.getString(HiveConfig.HIVE_TEST_TABLE_NAME_KEY)).getAbsolutePath(); String inputFormat = "org.apache.hadoop.hive.ql.io.orc.OrcInputFormat"; String outputFormat = "org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat"; int numBuckets = 16; Map<String, String> orcProps = new HashMap<>(); orcProps.put("orc.compress", "NONE"); SerDeInfo serDeInfo = new SerDeInfo(OrcSerde.class.getSimpleName(), OrcSerde.class.getName(), orcProps); List<String> bucketCols = new ArrayList<>(); bucketCols.add("id"); StorageDescriptor sd = new StorageDescriptor(); sd.setCols(cols); sd.setLocation(location); sd.setInputFormat(inputFormat); sd.setOutputFormat(outputFormat); sd.setNumBuckets(numBuckets); sd.setSerdeInfo(serDeInfo); sd.setBucketCols(bucketCols); sd.setSortCols(new ArrayList<>()); sd.setParameters(new HashMap<>()); Table tbl = new Table(); tbl.setDbName(configuration.getString(HiveConfig.HIVE_TEST_DATABASE_NAME_KEY)); tbl.setTableName(configuration.getString(HiveConfig.HIVE_TEST_TABLE_NAME_KEY)); tbl.setSd(sd); tbl.setOwner(System.getProperty("user.name")); tbl.setParameters(new HashMap<>()); tbl.setViewOriginalText(""); tbl.setViewExpandedText(""); tbl.setTableType(TableType.EXTERNAL_TABLE.name()); List<FieldSchema> partitions = new ArrayList<FieldSchema>(); partitions.add(new FieldSchema("dt", serdeConstants.STRING_TYPE_NAME, "")); tbl.setPartitionKeys(partitions); hiveClient.createTable(tbl); Table createdTable = hiveClient.getTable( configuration.getString(HiveConfig.HIVE_TEST_DATABASE_NAME_KEY), configuration.getString(HiveConfig.HIVE_TEST_TABLE_NAME_KEY)); assertThat(createdTable.toString()).contains(configuration.getString(HiveConfig.HIVE_TEST_TABLE_NAME_KEY)); } catch (MetaException e) { e.printStackTrace(); } catch (TException e) { e.printStackTrace(); } }