You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vi...@apache.org on 2018/07/19 19:55:38 UTC
[39/51] [partial] hive git commit: HIVE-20188 : Split server-specific
code outside of standalone metastore-common (Alexander Kolbasov reviewed by
Vihang Karajgaonkar)
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionContext.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionContext.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionContext.java
deleted file mode 100644
index 998531f..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionContext.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-/**
- * Base class which provides context to implementations of MetaStoreEndFunctionListener
- */
-
-public class MetaStoreEndFunctionContext {
-
- /**
- * whether method was successful or not.
- */
- private final boolean success;
- private final Exception e;
- private final String inputTableName;
-
- public MetaStoreEndFunctionContext(boolean success, Exception e, String inputTableName) {
- this.success = success;
- this.e = e;
- this.inputTableName = inputTableName;
- }
-
- public MetaStoreEndFunctionContext(boolean success) {
- this(success, null, null);
- }
-
- /**
- * @return whether or not the method succeeded.
- */
- public boolean isSuccess() {
- return success;
- }
-
- public Exception getException() {
- return e;
- }
-
- public String getInputTableName() {
- return inputTableName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionListener.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionListener.java
deleted file mode 100644
index bc7e0be..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEndFunctionListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import java.util.AbstractMap;
-
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * This abstract class needs to be extended to provide implementation of actions that need
- * to be performed when a function ends. These methods are called whenever a function ends.
- *
- * It also provides a way to add fb303 counters through the exportCounters method.
- */
-
-public abstract class MetaStoreEndFunctionListener implements Configurable {
-
- private Configuration conf;
-
- public MetaStoreEndFunctionListener(Configuration config){
- this.conf = config;
- }
-
- public abstract void onEndFunction(String functionName, MetaStoreEndFunctionContext context);
-
- // Unless this is overridden, it does nothing
- public void exportCounters(AbstractMap<String, Long> counters) {
- }
-
- @Override
- public Configuration getConf() {
- return this.conf;
- }
-
- @Override
- public void setConf(Configuration config) {
- this.conf = config;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
deleted file mode 100644
index de226bf..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.events.AddForeignKeyEvent;
-import org.apache.hadoop.hive.metastore.events.AddNotNullConstraintEvent;
-import org.apache.hadoop.hive.metastore.events.AddPrimaryKeyEvent;
-import org.apache.hadoop.hive.metastore.events.AddSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.AddUniqueConstraintEvent;
-import org.apache.hadoop.hive.metastore.events.AlterCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.AlterDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.AlterISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.AlterSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
-import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent;
-import org.apache.hadoop.hive.metastore.events.CreateCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.CreateFunctionEvent;
-import org.apache.hadoop.hive.metastore.events.CreateISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
-import org.apache.hadoop.hive.metastore.events.DropCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.DropConstraintEvent;
-import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.DropFunctionEvent;
-import org.apache.hadoop.hive.metastore.events.DropISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.DropSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.DropTableEvent;
-import org.apache.hadoop.hive.metastore.events.InsertEvent;
-import org.apache.hadoop.hive.metastore.events.LoadPartitionDoneEvent;
-import org.apache.hadoop.hive.metastore.events.OpenTxnEvent;
-import org.apache.hadoop.hive.metastore.events.CommitTxnEvent;
-import org.apache.hadoop.hive.metastore.events.AbortTxnEvent;
-import org.apache.hadoop.hive.metastore.events.AllocWriteIdEvent;
-import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
-import org.apache.hadoop.hive.metastore.tools.SQLGenerator;
-import java.sql.Connection;
-
-/**
- * This abstract class needs to be extended to provide implementation of actions that needs
- * to be performed when a particular event occurs on a metastore. These methods
- * are called whenever an event occurs on metastore. Status of the event whether
- * it was successful or not is contained in container event object.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Stable
-public abstract class MetaStoreEventListener implements Configurable {
-
- private Configuration conf;
-
- public MetaStoreEventListener(Configuration config){
- this.conf = config;
- }
-
- /**
- * @param tableEvent table event.
- * @throws MetaException
- */
- public void onConfigChange(ConfigChangeEvent tableEvent) throws MetaException {
- }
-
- /**
- * @param tableEvent table event.
- * @throws MetaException
- */
- public void onCreateTable (CreateTableEvent tableEvent) throws MetaException {
- }
-
- /**
- * @param tableEvent table event.
- * @throws MetaException
- */
- public void onDropTable (DropTableEvent tableEvent) throws MetaException {
- }
-
- /**
- * @param tableEvent alter table event
- * @throws MetaException
- */
- public void onAlterTable (AlterTableEvent tableEvent) throws MetaException {
- }
-
- /**
- * @param partitionEvent add partition event
- * @throws MetaException
- */
- public void onAddPartition (AddPartitionEvent partitionEvent) throws MetaException {
- }
-
- /**
- * @param partitionEvent partition event
- * @throws MetaException
- */
- public void onDropPartition (DropPartitionEvent partitionEvent) throws MetaException {
- }
-
- /**
- * @param partitionEvent partition event
- * @throws MetaException
- */
- public void onAlterPartition (AlterPartitionEvent partitionEvent) throws MetaException {
- }
-
- /**
- * @param dbEvent database event
- * @throws MetaException
- */
- public void onCreateDatabase (CreateDatabaseEvent dbEvent) throws MetaException {
- }
-
- /**
- * @param dbEvent database event
- * @throws MetaException
- */
- public void onDropDatabase (DropDatabaseEvent dbEvent) throws MetaException {
- }
-
- /**
- * @param dbEvent alter database event
- * @throws MetaException
- */
- public void onAlterDatabase(AlterDatabaseEvent dbEvent) throws MetaException {
- }
-
- /**
- * @param partSetDoneEvent
- * @throws MetaException
- */
- public void onLoadPartitionDone(LoadPartitionDoneEvent partSetDoneEvent) throws MetaException {
- }
-
- /**
- * @param fnEvent function event
- * @throws MetaException
- */
- public void onCreateFunction (CreateFunctionEvent fnEvent) throws MetaException {
- }
-
- /**
- * @param fnEvent function event
- * @throws MetaException
- */
- public void onDropFunction (DropFunctionEvent fnEvent) throws MetaException {
- }
-
- /**
- * This will be called when an insert is executed that does not cause a partition to be added.
- * If an insert causes a partition to be added it will cause {@link #onAddPartition} to be
- * called instead.
- * @param insertEvent
- * @throws MetaException
- */
- public void onInsert(InsertEvent insertEvent) throws MetaException {
- }
-
- /**
- * @param addPrimaryKeyEvent add primary key event
- * @throws MetaException
- */
- public void onAddPrimaryKey(AddPrimaryKeyEvent addPrimaryKeyEvent) throws MetaException {
- }
-
- /**
- * @param addForeignKeyEvent add foreign key event
- * @throws MetaException
- */
- public void onAddForeignKey(AddForeignKeyEvent addForeignKeyEvent) throws MetaException {
- }
-
- /**
- * @param addUniqueConstraintEvent add unique constraint event
- * @throws MetaException
- */
- public void onAddUniqueConstraint(AddUniqueConstraintEvent addUniqueConstraintEvent) throws MetaException {
- }
-
- /**
- * @param addNotNullConstraintEvent add not null constraint event
- * @throws MetaException
- */
- public void onAddNotNullConstraint(AddNotNullConstraintEvent addNotNullConstraintEvent) throws MetaException {
- }
-
- /**
- * @param dropConstraintEvent drop constraint event
- * @throws MetaException
- */
- public void onDropConstraint(DropConstraintEvent dropConstraintEvent) throws MetaException {
- }
-
- public void onCreateISchema(CreateISchemaEvent createISchemaEvent) throws MetaException {
- }
-
- public void onAlterISchema(AlterISchemaEvent alterISchemaEvent) throws MetaException {
- }
-
- public void onDropISchema(DropISchemaEvent dropISchemaEvent) throws MetaException {
- }
-
- public void onAddSchemaVersion(AddSchemaVersionEvent addSchemaVersionEvent) throws MetaException {
- }
-
- public void onAlterSchemaVersion(AlterSchemaVersionEvent alterSchemaVersionEvent)
- throws MetaException {
- }
-
- public void onDropSchemaVersion(DropSchemaVersionEvent dropSchemaVersionEvent)
- throws MetaException {
- }
-
- public void onCreateCatalog(CreateCatalogEvent createCatalogEvent) throws MetaException {
- }
-
- public void onAlterCatalog(AlterCatalogEvent alterCatalogEvent) throws MetaException {
- }
-
- public void onDropCatalog(DropCatalogEvent dropCatalogEvent) throws MetaException {
- }
-
- /**
- * This will be called when a new transaction is started.
- * @param openTxnEvent event to be processed
- * @param dbConn jdbc connection to remote meta store db.
- * @param sqlGenerator helper class to generate db specific sql string.
- * @throws MetaException
- */
- public void onOpenTxn(OpenTxnEvent openTxnEvent, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
- }
-
- /**
- * This will be called to commit a transaction.
- * @param commitTxnEvent event to be processed
- * @param dbConn jdbc connection to remote meta store db.
- * @param sqlGenerator helper class to generate db specific sql string.
- * @throws MetaException
- */
- public void onCommitTxn(CommitTxnEvent commitTxnEvent, Connection dbConn, SQLGenerator sqlGenerator) throws
- MetaException {
- }
-
- /**
- * This will be called to abort a transaction.
- * @param abortTxnEvent event to be processed
- * @param dbConn jdbc connection to remote meta store db.
- * @param sqlGenerator helper class to generate db specific sql string.
- * @throws MetaException
- */
- public void onAbortTxn(AbortTxnEvent abortTxnEvent, Connection dbConn, SQLGenerator sqlGenerator)
- throws MetaException {
- }
-
- /**
- * This will be called to alloc a new write id.
- * @param allocWriteIdEvent event to be processed
- * @param dbConn jdbc connection to remote meta store db.
- * @param sqlGenerator helper class to generate db specific sql string.
- * @throws MetaException
- */
- public void onAllocWriteId(AllocWriteIdEvent allocWriteIdEvent, Connection dbConn, SQLGenerator sqlGenerator)
- throws MetaException {
- }
-
- /**
- * This will be called to perform acid write operation.
- * @param acidWriteEvent event to be processed
- * @param dbConn jdbc connection to remote meta store db.
- * @param sqlGenerator helper class to generate db specific sql string.
- * @throws MetaException
- */
- public void onAcidWrite(AcidWriteEvent acidWriteEvent, Connection dbConn, SQLGenerator sqlGenerator)
- throws MetaException {
- }
-
- @Override
- public Configuration getConf() {
- return this.conf;
- }
-
- @Override
- public void setConf(Configuration config) {
- this.conf = config;
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListenerConstants.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListenerConstants.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListenerConstants.java
deleted file mode 100644
index 0b3de49..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListenerConstants.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-/**
- * Keeps a list of reserved keys used by Hive listeners when updating the ListenerEvent
- * parameters.
- */
-public class MetaStoreEventListenerConstants {
- /*
- * DbNotificationListener keys reserved for updating ListenerEvent parameters.
- *
- * DB_NOTIFICATION_EVENT_ID_KEY_NAME This key will have the event identifier that DbNotificationListener
- * processed during an event. This event identifier might be shared
- * across other MetaStoreEventListener implementations.
- */
- public static final String DB_NOTIFICATION_EVENT_ID_KEY_NAME = "DB_NOTIFICATION_EVENT_ID_KEY_NAME";
-
- /*
- * HiveMetaStore keys reserved for updating ListenerEvent parameters.
- *
- * HIVE_METASTORE_TRANSACTION_ACTIVE This key is used to check if a listener event is run inside a current
- * transaction. A boolean value is used for active (true) or no active (false).
- */
- public static final String HIVE_METASTORE_TRANSACTION_ACTIVE = "HIVE_METASTORE_TRANSACTION_ACTIVE";
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreFS.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreFS.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreFS.java
deleted file mode 100644
index ddcda4c..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreFS.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-
-/**
- * Define a set of APIs that may vary in different environments
- */
-public interface MetaStoreFS {
-
- /**
- * delete a directory
- *
- * @param f
- * @param ifPurge
- * @param recursive
- * @return true on success
- * @throws MetaException
- */
- public boolean deleteDir(FileSystem fs, Path f, boolean recursive,
- boolean ifPurge, Configuration conf) throws MetaException;
-
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInit.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInit.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInit.java
deleted file mode 100644
index 9417cf5..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInit.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.hooks.JDOConnectionURLHook;
-import org.apache.hadoop.util.ReflectionUtils;
-
-/**
- * MetaStoreInit defines functions to init/update MetaStore connection url.
- *
- */
-public class MetaStoreInit {
-
- private static final Logger LOG = LoggerFactory.getLogger(MetaStoreInit.class);
-
- static class MetaStoreInitData {
- JDOConnectionURLHook urlHook = null;
- String urlHookClassName = "";
- }
-
- /**
- * Updates the connection URL in hiveConf using the hook (if a hook has been
- * set using hive.metastore.ds.connection.url.hook property)
- * @param originalConf - original configuration used to look up hook settings
- * @param activeConf - the configuration file in use for looking up db url
- * @param badUrl
- * @param updateData - hook information
- * @return true if a new connection URL was loaded into the thread local
- * configuration
- * @throws MetaException
- */
- static boolean updateConnectionURL(Configuration originalConf, Configuration activeConf,
- String badUrl, MetaStoreInitData updateData)
- throws MetaException {
- String connectUrl = null;
- String currentUrl = MetaStoreInit.getConnectionURL(activeConf);
- try {
- // We always call init because the hook name in the configuration could
- // have changed.
- initConnectionUrlHook(originalConf, updateData);
- if (updateData.urlHook != null) {
- if (badUrl != null) {
- updateData.urlHook.notifyBadConnectionUrl(badUrl);
- }
- connectUrl = updateData.urlHook.getJdoConnectionUrl(originalConf);
- }
- } catch (Exception e) {
- LOG.error("Exception while getting connection URL from the hook: " +
- e);
- }
-
- if (connectUrl != null && !connectUrl.equals(currentUrl)) {
- LOG.error(
- String.format("Overriding %s with %s",
- MetastoreConf.ConfVars.CONNECT_URL_KEY.toString(),
- connectUrl));
- MetastoreConf.setVar(activeConf, ConfVars.CONNECT_URL_KEY, connectUrl);
- return true;
- }
- return false;
- }
-
- static String getConnectionURL(Configuration conf) {
- return MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY, "");
- }
-
- // Multiple threads could try to initialize at the same time.
- synchronized private static void initConnectionUrlHook(Configuration conf,
- MetaStoreInitData updateData) throws ClassNotFoundException {
-
- String className = MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_HOOK, "").trim();
- if (className.equals("")) {
- updateData.urlHookClassName = "";
- updateData.urlHook = null;
- return;
- }
- boolean urlHookChanged = !updateData.urlHookClassName.equals(className);
- if (updateData.urlHook == null || urlHookChanged) {
- updateData.urlHookClassName = className.trim();
-
- Class<?> urlHookClass = Class.forName(updateData.urlHookClassName, true,
- JavaUtils.getClassLoader());
- updateData.urlHook = (JDOConnectionURLHook) ReflectionUtils.newInstance(urlHookClass, null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitContext.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitContext.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitContext.java
deleted file mode 100644
index 0968f42..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitContext.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-/**
- * Base class which provides context to implementations of MetaStoreInitListener
- */
-
-public class MetaStoreInitContext {
-
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitListener.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitListener.java
deleted file mode 100644
index 12130ea..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreInitListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-
-/**
- * This abstract class needs to be extended to provide implementation of actions
- * that needs to be performed when HMSHandler is initialized
- */
-
-public abstract class MetaStoreInitListener implements Configurable {
-
- private Configuration conf;
-
- public MetaStoreInitListener(Configuration config){
- this.conf = config;
- }
-
- public abstract void onInit(MetaStoreInitContext context) throws MetaException;
-
- @Override
- public Configuration getConf() {
- return this.conf;
- }
-
- @Override
- public void setConf(Configuration config) {
- this.conf = config;
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
deleted file mode 100644
index c296f57..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.events.AddForeignKeyEvent;
-import org.apache.hadoop.hive.metastore.events.AddNotNullConstraintEvent;
-import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.AddPrimaryKeyEvent;
-import org.apache.hadoop.hive.metastore.events.AddSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.AddUniqueConstraintEvent;
-import org.apache.hadoop.hive.metastore.events.AlterCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.AlterDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.AlterISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.AlterSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
-import org.apache.hadoop.hive.metastore.events.CreateCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.CreateFunctionEvent;
-import org.apache.hadoop.hive.metastore.events.CreateISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
-import org.apache.hadoop.hive.metastore.events.DropCatalogEvent;
-import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
-import org.apache.hadoop.hive.metastore.events.DropFunctionEvent;
-import org.apache.hadoop.hive.metastore.events.DropISchemaEvent;
-import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
-import org.apache.hadoop.hive.metastore.events.DropSchemaVersionEvent;
-import org.apache.hadoop.hive.metastore.events.DropTableEvent;
-import org.apache.hadoop.hive.metastore.events.InsertEvent;
-import org.apache.hadoop.hive.metastore.events.ListenerEvent;
-import org.apache.hadoop.hive.metastore.events.OpenTxnEvent;
-import org.apache.hadoop.hive.metastore.events.CommitTxnEvent;
-import org.apache.hadoop.hive.metastore.events.AbortTxnEvent;
-import org.apache.hadoop.hive.metastore.events.AllocWriteIdEvent;
-import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
-import org.apache.hadoop.hive.metastore.tools.SQLGenerator;
-import java.sql.Connection;
-import java.util.List;
-import java.util.Map;
-import static org.apache.hadoop.hive.metastore.MetaStoreEventListenerConstants.HIVE_METASTORE_TRANSACTION_ACTIVE;
-import static org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
-
-/**
- * This class is used to notify a list of listeners about specific MetaStore events.
- */
-@InterfaceAudience.Private
-public class MetaStoreListenerNotifier {
-
- private interface EventNotifier {
- void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException;
- }
-
- private static Map<EventType, EventNotifier> notificationEvents = Maps.newHashMap(
- ImmutableMap.<EventType, EventNotifier>builder()
- .put(EventType.CREATE_DATABASE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener,
- ListenerEvent event) throws MetaException {
- listener.onCreateDatabase((CreateDatabaseEvent)event);
- }
- })
- .put(EventType.DROP_DATABASE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropDatabase((DropDatabaseEvent)event);
- }
- })
- .put(EventType.CREATE_TABLE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onCreateTable((CreateTableEvent)event);
- }
- })
- .put(EventType.DROP_TABLE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropTable((DropTableEvent)event);
- }
- })
- .put(EventType.ADD_PARTITION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddPartition((AddPartitionEvent)event);
- }
- })
- .put(EventType.DROP_PARTITION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropPartition((DropPartitionEvent)event);
- }
- })
- .put(EventType.ALTER_DATABASE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener,
- ListenerEvent event) throws MetaException {
- listener.onAlterDatabase((AlterDatabaseEvent)event);
- }
- })
- .put(EventType.ALTER_TABLE, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAlterTable((AlterTableEvent)event);
- }
- })
- .put(EventType.ALTER_PARTITION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAlterPartition((AlterPartitionEvent)event);
- }
- })
- .put(EventType.INSERT, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onInsert((InsertEvent)event);
- }
- })
- .put(EventType.CREATE_FUNCTION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onCreateFunction((CreateFunctionEvent)event);
- }
- })
- .put(EventType.DROP_FUNCTION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropFunction((DropFunctionEvent)event);
- }
- })
- .put(EventType.ADD_PRIMARYKEY, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddPrimaryKey((AddPrimaryKeyEvent)event);
- }
- })
- .put(EventType.ADD_FOREIGNKEY, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddForeignKey((AddForeignKeyEvent)event);
- }
- })
- .put(EventType.ADD_UNIQUECONSTRAINT, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddUniqueConstraint((AddUniqueConstraintEvent)event);
- }
- })
- .put(EventType.ADD_NOTNULLCONSTRAINT, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddNotNullConstraint((AddNotNullConstraintEvent)event);
- }
- })
- .put(EventType.CREATE_ISCHEMA, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onCreateISchema((CreateISchemaEvent)event);
- }
- })
- .put(EventType.ALTER_ISCHEMA, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAlterISchema((AlterISchemaEvent)event);
- }
- })
- .put(EventType.DROP_ISCHEMA, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropISchema((DropISchemaEvent)event);
- }
- })
- .put(EventType.ADD_SCHEMA_VERSION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAddSchemaVersion((AddSchemaVersionEvent) event);
- }
- })
- .put(EventType.ALTER_SCHEMA_VERSION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onAlterSchemaVersion((AlterSchemaVersionEvent) event);
- }
- })
- .put(EventType.DROP_SCHEMA_VERSION, new EventNotifier() {
- @Override
- public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
- listener.onDropSchemaVersion((DropSchemaVersionEvent) event);
- }
- })
- .put(EventType.CREATE_CATALOG,
- (listener, event) -> listener.onCreateCatalog((CreateCatalogEvent)event))
- .put(EventType.DROP_CATALOG,
- (listener, event) -> listener.onDropCatalog((DropCatalogEvent)event))
- .put(EventType.ALTER_CATALOG,
- (listener, event) -> listener.onAlterCatalog((AlterCatalogEvent)event))
- .put(EventType.OPEN_TXN,
- (listener, event) -> listener.onOpenTxn((OpenTxnEvent) event, null, null))
- .put(EventType.COMMIT_TXN,
- (listener, event) -> listener.onCommitTxn((CommitTxnEvent) event, null, null))
- .put(EventType.ABORT_TXN,
- (listener, event) -> listener.onAbortTxn((AbortTxnEvent) event, null, null))
- .put(EventType.ALLOC_WRITE_ID,
- (listener, event) -> listener.onAllocWriteId((AllocWriteIdEvent) event, null, null))
- .put(EventType.ACID_WRITE,
- (listener, event) -> listener.onAcidWrite((AcidWriteEvent) event, null, null))
- .build()
- );
-
-
- private interface TxnEventNotifier {
- void notify(MetaStoreEventListener listener, ListenerEvent event, Connection dbConn, SQLGenerator sqlGenerator)
- throws MetaException;
- }
-
- private static Map<EventType, TxnEventNotifier> txnNotificationEvents = Maps.newHashMap(
- ImmutableMap.<EventType, TxnEventNotifier>builder()
- .put(EventType.OPEN_TXN,
- (listener, event, dbConn, sqlGenerator) -> listener.onOpenTxn((OpenTxnEvent) event, dbConn, sqlGenerator))
- .put(EventType.COMMIT_TXN,
- (listener, event, dbConn, sqlGenerator) -> listener.onCommitTxn((CommitTxnEvent) event, dbConn, sqlGenerator))
- .put(EventType.ABORT_TXN,
- (listener, event, dbConn, sqlGenerator) -> listener.onAbortTxn((AbortTxnEvent) event, dbConn, sqlGenerator))
- .put(EventType.ALLOC_WRITE_ID,
- (listener, event, dbConn, sqlGenerator) ->
- listener.onAllocWriteId((AllocWriteIdEvent) event, dbConn, sqlGenerator))
- .put(EventType.ACID_WRITE,
- (listener, event, dbConn, sqlGenerator) ->
- listener.onAcidWrite((AcidWriteEvent) event, dbConn, sqlGenerator))
- .build()
- );
-
- /**
- * Notify a list of listeners about a specific metastore event. Each listener notified might update
- * the (ListenerEvent) event by setting a parameter key/value pair. These updated parameters will
- * be returned to the caller.
- *
- * @param listeners List of MetaStoreEventListener listeners.
- * @param eventType Type of the notification event.
- * @param event The ListenerEvent with information about the event.
- * @return A list of key/value pair parameters that the listeners set. The returned object will return an empty
- * map if no parameters were updated or if no listeners were notified.
- * @throws MetaException If an error occurred while calling the listeners.
- */
- public static Map<String, String> notifyEvent(List<? extends MetaStoreEventListener> listeners,
- EventType eventType,
- ListenerEvent event) throws MetaException {
-
- Preconditions.checkNotNull(listeners, "Listeners must not be null.");
- Preconditions.checkNotNull(event, "The event must not be null.");
-
- for (MetaStoreEventListener listener : listeners) {
- notificationEvents.get(eventType).notify(listener, event);
- }
-
- // Each listener called above might set a different parameter on the event.
- // This write permission is allowed on the listener side to avoid breaking compatibility if we change the API
- // method calls.
- return event.getParameters();
- }
-
- /**
- * Notify a list of listeners about a specific metastore event to be executed within a txn. Each listener notified
- * might update the (ListenerEvent) event by setting a parameter key/value pair. These updated parameters will
- * be returned to the caller.
- *
- * @param listeners List of MetaStoreEventListener listeners.
- * @param eventType Type of the notification event.
- * @param event The ListenerEvent with information about the event.
- * @param dbConn The JDBC connection to the remote meta store db.
- * @param sqlGenerator The helper class to generate db specific SQL string.
- * @return A list of key/value pair parameters that the listeners set. The returned object will return an empty
- * map if no parameters were updated or if no listeners were notified.
- * @throws MetaException If an error occurred while calling the listeners.
- */
- public static Map<String, String> notifyEventWithDirectSql(List<? extends MetaStoreEventListener> listeners,
- EventType eventType,
- ListenerEvent event,
- Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
-
- Preconditions.checkNotNull(listeners, "Listeners must not be null.");
- Preconditions.checkNotNull(event, "The event must not be null.");
-
- for (MetaStoreEventListener listener : listeners) {
- txnNotificationEvents.get(eventType).notify(listener, event, dbConn, sqlGenerator);
- }
-
- // Each listener called above might set a different parameter on the event.
- // This write permission is allowed on the listener side to avoid breaking compatibility if we change the API
- // method calls.
- return event.getParameters();
- }
-
- /**
- * Notify a list of listeners about a specific metastore event. Each listener notified might update
- * the (ListenerEvent) event by setting a parameter key/value pair. These updated parameters will
- * be returned to the caller.
- *
- * @param listeners List of MetaStoreEventListener listeners.
- * @param eventType Type of the notification event.
- * @param event The ListenerEvent with information about the event.
- * @param environmentContext An EnvironmentContext object with parameters sent by the HMS client.
- * @return A list of key/value pair parameters that the listeners set. The returned object will return an empty
- * map if no parameters were updated or if no listeners were notified.
- * @throws MetaException If an error occurred while calling the listeners.
- */
- public static Map<String, String> notifyEvent(List<? extends MetaStoreEventListener> listeners,
- EventType eventType,
- ListenerEvent event,
- EnvironmentContext environmentContext) throws MetaException {
-
- Preconditions.checkNotNull(event, "The event must not be null.");
-
- event.setEnvironmentContext(environmentContext);
- return notifyEvent(listeners, eventType, event);
- }
-
- /**
- * Notify a list of listeners about a specific metastore event. Each listener notified might update
- * the (ListenerEvent) event by setting a parameter key/value pair. These updated parameters will
- * be returned to the caller.
- *
- * Sometimes these events are run inside a DB transaction and might cause issues with the listeners,
- * for instance, Sentry blocks the HMS until an event is seen committed on the DB. To notify the listener about this,
- * a new parameter to verify if a transaction is active is added to the ListenerEvent, and is up to the listener
- * to skip this notification if so.
- *
- * @param listeners List of MetaStoreEventListener listeners.
- * @param eventType Type of the notification event.
- * @param event The ListenerEvent with information about the event.
- * @param environmentContext An EnvironmentContext object with parameters sent by the HMS client.
- * @param parameters A list of key/value pairs with the new parameters to add.
- * @param ms The RawStore object from where to check if a transaction is active.
- * @return A list of key/value pair parameters that the listeners set. The returned object will return an empty
- * map if no parameters were updated or if no listeners were notified.
- * @throws MetaException If an error occurred while calling the listeners.
- */
- public static Map<String, String> notifyEvent(List<? extends MetaStoreEventListener> listeners,
- EventType eventType,
- ListenerEvent event,
- EnvironmentContext environmentContext,
- Map<String, String> parameters,
- final RawStore ms) throws MetaException {
-
- Preconditions.checkNotNull(event, "The event must not be null.");
-
- event.putParameters(parameters);
-
- if (ms != null) {
- event.putParameter(HIVE_METASTORE_TRANSACTION_ACTIVE, Boolean.toString(ms.isActiveTransaction()));
- }
-
- return notifyEvent(listeners, eventType, event, environmentContext);
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePreEventListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePreEventListener.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePreEventListener.java
deleted file mode 100644
index a757dff..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePreEventListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
-import org.apache.hadoop.hive.metastore.events.PreEventContext;
-
-/**
- * This abstract class needs to be extended to provide implementation of actions that needs
- * to be performed before a particular event occurs on a metastore. These methods
- * are called before an event occurs on metastore.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Stable
-public abstract class MetaStorePreEventListener implements Configurable {
-
- private Configuration conf;
-
- public MetaStorePreEventListener(Configuration config){
- this.conf = config;
- }
-
- public abstract void onEvent(PreEventContext context)
- throws MetaException, NoSuchObjectException, InvalidOperationException;
-
- @Override
- public Configuration getConf() {
- return this.conf;
- }
-
- @Override
- public void setConf(Configuration config) {
- this.conf = config;
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfo.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfo.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfo.java
deleted file mode 100644
index 88bd42d..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfo.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper;
-import org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.MetaStoreConnectionInfo;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo;
-
-
-public class MetaStoreSchemaInfo implements IMetaStoreSchemaInfo {
- protected static final String UPGRADE_FILE_PREFIX = "upgrade-";
- protected static final String INIT_FILE_PREFIX = "hive-schema-";
- protected static final String VERSION_UPGRADE_LIST = "upgrade.order";
- protected static final String PRE_UPGRADE_PREFIX = "pre-";
- protected static final String CREATE_USER_PREFIX = "create-user";
-
- private String[] hiveSchemaVersions;
- private final String metastoreHome;
- protected final String dbType;
-
- // Some version upgrades often don't change schema. So they are equivalent to
- // a version
- // that has a corresponding schema. eg "0.13.1" is equivalent to "0.13.0"
- private static final Map<String, String> EQUIVALENT_VERSIONS =
- ImmutableMap.of("0.13.1", "0.13.0",
- "1.0.0", "0.14.0",
- "1.0.1", "1.0.0",
- "1.1.1", "1.1.0",
- "1.2.1", "1.2.0"
- );
-
- public MetaStoreSchemaInfo(String metastoreHome, String dbType) throws HiveMetaException {
- this.metastoreHome = metastoreHome;
- this.dbType = dbType;
- }
-
- private void loadAllUpgradeScripts(String dbType) throws HiveMetaException {
- // load upgrade order for the given dbType
- List<String> upgradeOrderList = new ArrayList<>();
- String upgradeListFile = getMetaStoreScriptDir() + File.separator +
- VERSION_UPGRADE_LIST + "." + dbType;
- try (FileReader fr = new FileReader(upgradeListFile);
- BufferedReader bfReader = new BufferedReader(fr)) {
- String currSchemaVersion;
- while ((currSchemaVersion = bfReader.readLine()) != null) {
- upgradeOrderList.add(currSchemaVersion.trim());
- }
- } catch (FileNotFoundException e) {
- throw new HiveMetaException("File " + upgradeListFile + "not found ", e);
- } catch (IOException e) {
- throw new HiveMetaException("Error reading " + upgradeListFile, e);
- }
- hiveSchemaVersions = upgradeOrderList.toArray(new String[0]);
- }
-
- /***
- * Get the list of sql scripts required to upgrade from the give version to current
- * @param fromVersion
- * @return
- * @throws HiveMetaException
- */
- @Override
- public List<String> getUpgradeScripts(String fromVersion)
- throws HiveMetaException {
- List <String> upgradeScriptList = new ArrayList<>();
-
- // check if we are already at current schema level
- if (getHiveSchemaVersion().equals(fromVersion)) {
- return upgradeScriptList;
- }
- loadAllUpgradeScripts(dbType);
- // Find the list of scripts to execute for this upgrade
- int firstScript = hiveSchemaVersions.length;
- for (int i=0; i < hiveSchemaVersions.length; i++) {
- if (hiveSchemaVersions[i].startsWith(fromVersion)) {
- firstScript = i;
- }
- }
- if (firstScript == hiveSchemaVersions.length) {
- throw new HiveMetaException("Unknown version specified for upgrade " +
- fromVersion + " Metastore schema may be too old or newer");
- }
-
- for (int i=firstScript; i < hiveSchemaVersions.length; i++) {
- String scriptFile = generateUpgradeFileName(hiveSchemaVersions[i]);
- upgradeScriptList.add(scriptFile);
- }
- return upgradeScriptList;
- }
-
- /***
- * Get the name of the script to initialize the schema for given version
- * @param toVersion Target version. If it's null, then the current server version is used
- * @return
- * @throws HiveMetaException
- */
- @Override
- public String generateInitFileName(String toVersion) throws HiveMetaException {
- if (toVersion == null) {
- toVersion = getHiveSchemaVersion();
- }
- String initScriptName = INIT_FILE_PREFIX + toVersion + "." +
- dbType + SQL_FILE_EXTENSION;
- // check if the file exists
- if (!(new File(getMetaStoreScriptDir() + File.separatorChar +
- initScriptName).exists())) {
- throw new HiveMetaException("Unknown version specified for initialization: " + toVersion);
- }
- return initScriptName;
- }
-
- @Override
- public String getCreateUserScript() throws HiveMetaException {
- String createScript = CREATE_USER_PREFIX + "." + dbType + SQL_FILE_EXTENSION;
- // check if the file exists
- if (!(new File(getMetaStoreScriptDir() + File.separatorChar +
- createScript).exists())) {
- throw new HiveMetaException("Unable to find create user file, expected: " + createScript);
- }
- return createScript;
- }
-
- /**
- * Find the directory of metastore scripts
- * @return
- */
- @Override
- public String getMetaStoreScriptDir() {
- return metastoreHome + File.separatorChar +
- "scripts" + File.separatorChar + "metastore" +
- File.separatorChar + "upgrade" + File.separatorChar + dbType;
- }
-
- // format the upgrade script name eg upgrade-x-y-dbType.sql
- private String generateUpgradeFileName(String fileVersion) {
- return UPGRADE_FILE_PREFIX + fileVersion + "." + dbType + SQL_FILE_EXTENSION;
- }
-
- @Override
- public String getPreUpgradeScriptName(int index, String upgradeScriptName) {
- return PRE_UPGRADE_PREFIX + index + "-" + upgradeScriptName;
- }
-
- @Override
- public String getHiveSchemaVersion() {
- String hiveVersion = MetastoreVersionInfo.getShortVersion();
- return getEquivalentVersion(hiveVersion);
- }
-
- private static String getEquivalentVersion(String hiveVersion) {
- // if there is an equivalent version, return that, else return this version
- String equivalentVersion = EQUIVALENT_VERSIONS.get(hiveVersion);
- if (equivalentVersion != null) {
- return equivalentVersion;
- } else {
- return hiveVersion;
- }
- }
-
- @Override
- public boolean isVersionCompatible(String hiveVersion, String dbVersion) {
- hiveVersion = getEquivalentVersion(hiveVersion);
- dbVersion = getEquivalentVersion(dbVersion);
- if (hiveVersion.equals(dbVersion)) {
- return true;
- }
- String[] hiveVerParts = hiveVersion.split("\\.");
- String[] dbVerParts = dbVersion.split("\\.");
- if (hiveVerParts.length != 3 || dbVerParts.length != 3) {
- // these are non standard version numbers. can't perform the
- // comparison on these, so assume that they are incompatible
- return false;
- }
-
- for (int i = 0; i < dbVerParts.length; i++) {
- int dbVerPart = Integer.parseInt(dbVerParts[i]);
- int hiveVerPart = Integer.parseInt(hiveVerParts[i]);
- if (dbVerPart > hiveVerPart) {
- return true;
- } else if (dbVerPart < hiveVerPart) {
- return false;
- } else {
- continue; // compare next part
- }
- }
-
- return true;
- }
-
- @Override
- public String getMetaStoreSchemaVersion(MetaStoreConnectionInfo connectionInfo) throws HiveMetaException {
- String versionQuery;
- boolean needsQuotedIdentifier = HiveSchemaHelper.getDbCommandParser(connectionInfo.getDbType(),
- connectionInfo.getMetaDbType(), false).needsQuotedIdentifier();
- if (needsQuotedIdentifier) {
- versionQuery = "select t.\"SCHEMA_VERSION\" from \"VERSION\" t";
- } else {
- versionQuery = "select t.SCHEMA_VERSION from VERSION t";
- }
- String schema = ( HiveSchemaHelper.DB_HIVE.equals(connectionInfo.getDbType()) ? "SYS" : null );
- try (Connection metastoreDbConnection = HiveSchemaHelper.getConnectionToMetastore(connectionInfo, schema);
- Statement stmt = metastoreDbConnection.createStatement()) {
- ResultSet res = stmt.executeQuery(versionQuery);
- if (!res.next()) {
- throw new HiveMetaException("Could not find version info in metastore VERSION table.");
- }
- String currentSchemaVersion = res.getString(1);
- if (res.next()) {
- throw new HiveMetaException("Multiple versions were found in metastore.");
- }
- return currentSchemaVersion;
- } catch (SQLException e) {
- throw new HiveMetaException("Failed to get schema version, Cause:" + e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfoFactory.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfoFactory.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfoFactory.java
deleted file mode 100644
index d03b7ae..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfoFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Factory class implementation to create instances of IMetaStoreSchemaInfo
- * based on the provided configuration
- */
-public class MetaStoreSchemaInfoFactory {
- public static final Logger LOG = LoggerFactory.getLogger(MetaStoreSchemaInfoFactory.class);
-
- public static IMetaStoreSchemaInfo get(Configuration conf) {
- String hiveHome = System.getenv("HIVE_HOME");
- if (hiveHome == null) {
- LOG.debug("HIVE_HOME is not set. Using current directory instead");
- hiveHome = ".";
- }
- return get(conf, hiveHome, null);
- }
-
- public static IMetaStoreSchemaInfo get(Configuration conf, String hiveHome, String dbType) {
- String className = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.SCHEMA_INFO_CLASS);
- Class<?> clasz;
- try {
- clasz = conf.getClassByName(className);
- } catch (ClassNotFoundException e) {
- LOG.error("Unable to load class " + className, e);
- throw new IllegalArgumentException(e);
- }
- Constructor<?> constructor;
- try {
- constructor = clasz.getConstructor(String.class, String.class);
- constructor.setAccessible(true);
- return (IMetaStoreSchemaInfo) constructor.newInstance(hiveHome, dbType);
- } catch (NoSuchMethodException | InstantiationException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {
- LOG.error("Unable to create instance of class " + className, e);
- throw new IllegalArgumentException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreThread.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreThread.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreThread.java
deleted file mode 100644
index 6ef2e35..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreThread.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * A thread that runs in the metastore, separate from the threads in the thrift service.
- */
-public interface MetaStoreThread extends Configurable {
-
- /**
- * Set the id for this thread.
- * @param threadId id of the thread
- */
- void setThreadId(int threadId);
-
- /**
- * Initialize the thread. This must not be called until after
- * {@link #setConf(Configuration)} and {@link #setThreadId(int)}
- * have been called.
- * @param stop a flag to watch for when to stop. If this value is set to true,
- * the thread will terminate the next time through its main loop.
- * @param looped a flag that is set to true everytime a thread goes through it's main loop.
- * This is purely for testing so that tests can assure themselves that the thread
- * has run through it's loop once. The test can set this value to false. The
- * thread should then assure that the loop has been gone completely through at
- * least once.
- */
- // TODO: move these test parameters to more specific places... there's no need to have them here
- void init(AtomicBoolean stop, AtomicBoolean looped) throws MetaException;
-
- /**
- * Run the thread in the background. This must not be called until
- * {@link MetaStoreThread#init(java.util.concurrent.atomic.AtomicBoolean,java.util.concurrent.atomic.AtomicBoolean)} has
- * been called.
- */
- void start();
-}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetadataStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetadataStore.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetadataStore.java
deleted file mode 100644
index 26e2c49..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetadataStore.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.hadoop.hive.metastore;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-
-public interface MetadataStore {
- /**
- * @param fileIds file ID list.
- * @param result The ref parameter, used to return the serialized file metadata.
- */
- void getFileMetadata(List<Long> fileIds, ByteBuffer[] result) throws IOException;
-
- /**
- * @param fileIds file ID list.
- * @param metadataBuffers Serialized file metadata, one per file ID.
- * @param addedCols The column names for additional columns created by file-format-specific
- * metadata handler, to be stored in the cache.
- * @param addedVals The values for addedCols; one value per file ID per added column.
- */
- void storeFileMetadata(List<Long> fileIds, List<ByteBuffer> metadataBuffers,
- ByteBuffer[] addedCols, ByteBuffer[][] addedVals) throws IOException, InterruptedException;
-
- /**
- * @param fileId The file ID.
- * @param metadata Serialized file metadata.
- * @param addedCols The column names for additional columns created by file-format-specific
- * metadata handler, to be stored in the cache.
- * @param addedVals The values for addedCols; one value per added column.
- */
- void storeFileMetadata(long fileId, ByteBuffer metadata, ByteBuffer[] addedCols,
- ByteBuffer[] addedVals) throws IOException, InterruptedException;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetastoreTaskThread.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetastoreTaskThread.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetastoreTaskThread.java
deleted file mode 100644
index e5d21b0..0000000
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetastoreTaskThread.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.hadoop.hive.metastore;
-
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Any task that will run as a separate thread in the metastore should implement this
- * interface.
- */
-public interface MetastoreTaskThread extends Configurable, Runnable {
-
- /**
- * Get the frequency at which the thread should be scheduled in the thread pool. You must call
- * {@link #setConf(Configuration)} before calling this method.
- * @param unit TimeUnit to express the frequency in.
- * @return frequency
- */
- long runFrequency(TimeUnit unit);
-}