You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by ev...@apache.org on 2017/07/01 13:36:55 UTC

[11/50] [abbrv] bigtop git commit: BIGTOP-2779: new hive charm

BIGTOP-2779: new hive charm

Closes #217


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/2022c147
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/2022c147
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/2022c147

Branch: refs/heads/branch-1.2
Commit: 2022c14740b59a1cc41817aba481fd82d22b44c2
Parents: 3e13150
Author: Kevin W Monroe <ke...@canonical.com>
Authored: Mon Jun 6 15:06:41 2016 +0000
Committer: Evans Ye <ev...@apache.org>
Committed: Sat Jul 1 12:52:55 2017 +0000

----------------------------------------------------------------------
 .../src/charm/hive/layer-hive/README.md         | 237 +++++++++++++++++++
 .../src/charm/hive/layer-hive/actions.yaml      |   4 +
 .../src/charm/hive/layer-hive/actions/restart   |  36 +++
 .../charm/hive/layer-hive/actions/smoke-test    |  49 ++++
 .../src/charm/hive/layer-hive/config.yaml       |   6 +
 .../src/charm/hive/layer-hive/copyright         |  16 ++
 .../src/charm/hive/layer-hive/icon.svg          |  75 ++++++
 .../src/charm/hive/layer-hive/layer.yaml        |  31 +++
 .../layer-hive/lib/charms/layer/bigtop_hive.py  | 138 +++++++++++
 .../src/charm/hive/layer-hive/metadata.yaml     |  19 ++
 .../src/charm/hive/layer-hive/reactive/hive.py  | 184 ++++++++++++++
 .../layer-hive/tests/01-basic-deployment.py     |  39 +++
 .../hive/layer-hive/tests/02-smoke-test.py      |  60 +++++
 .../src/charm/hive/layer-hive/tests/tests.yaml  |   3 +
 14 files changed, 897 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/README.md
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/README.md b/bigtop-packages/src/charm/hive/layer-hive/README.md
new file mode 100644
index 0000000..ae2ddd8
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/README.md
@@ -0,0 +1,237 @@
+<!--
+  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.
+-->
+# Overview
+
+Apache Hive is a data warehouse infrastructure built on top of Hadoop that
+supports data summarization, query, and analysis. Hive provides an SQL-like
+language called HiveQL that transparently converts queries to MapReduce for
+execution on large datasets stored in Hadoop's HDFS. Learn more at
+[hive.apache.org][].
+
+This charm deploys version 1.2.1 of the Hive component from [Apache Bigtop][].
+
+[hive.apache.org]: http://hive.apache.org/
+[Apache Bigtop]: http://bigtop.apache.org/
+
+
+# Deploying
+
+This charm requires Juju 2.0 or greater. If Juju is not yet set up, please
+follow the [getting-started][] instructions prior to deploying this charm.
+
+This charm is intended to be deployed via one of the [bigtop hadoop bundles][].
+For example:
+
+    juju deploy hadoop-processing
+
+This will deploy an Apache Bigtop Hadoop cluster. More information about this
+deployment can be found in the [bundle readme](https://jujucharms.com/hadoop-processing/).
+
+Now add Hive and relate it to the cluster via the hadoop-plugin:
+
+    juju deploy hive
+    juju add-relation hive plugin
+
+## Metastore
+This charm will start the Hive Metastore service using a local Apache Derby
+metastore database by default. This is suitable for unit or smoke testing Hive,
+but this configuration should not be used in production. Deploying an external
+database for the Hive metastore is recommended:
+
+    juju deploy mariadb
+    juju add-relation hive mariadb
+
+## HBase Integration
+This charm supports interacting with HBase using Hive. Enable this by relating
+Hive to a deployment that includes HBase. For example:
+
+    juju deploy hadoop-hbase
+    juju add-relation hive hbase
+
+See the [hadoop-hbase][] bundle for more information about this HBase
+deployment.
+
+> **Note:** Applications that are duplicated in multiple bundles will be
+reused. This means when deploying both `hadoop-processing` and `hadoop-hbase`,
+Juju will reuse (and not duplicate) common applications like the NameNode,
+ResourceManager, Slaves, etc.
+
+## Network-Restricted Environments
+Charms can be deployed in environments with limited network access. To deploy
+in this environment, configure a Juju model with appropriate proxy and/or
+mirror options. See [Configuring Models][] for more information.
+
+[getting-started]: https://jujucharms.com/docs/stable/getting-started
+[bigtop hadoop bundles]: https://jujucharms.com/u/bigdata-charmers/#bundles
+[Configuring Models]: https://jujucharms.com/docs/stable/models-config
+[hadoop-hbase]: https://jujucharms.com/hadoop-hbase/
+
+
+# Verifying
+
+## Status
+Apache Bigtop charms provide extended status reporting to indicate when they
+are ready:
+
+    juju status
+
+This is particularly useful when combined with `watch` to track the on-going
+progress of the deployment:
+
+    watch -n 2 juju status
+
+The message column will provide information about a given unit's state.
+This charm is ready for use once the status message indicates that it is
+ready.
+
+## Smoke Test
+This charm provides a `smoke-test` action that can be used to verify the
+application is functioning as expected. Run the action as follows:
+
+    juju run-action hive/0 smoke-test
+
+Watch the progress of the smoke test actions with:
+
+    watch -n 2 juju show-action-status
+
+Eventually, the action should settle to `status: completed`.  If it
+reports `status: failed`, the application is not working as expected. Get
+more information about a specific smoke test with:
+
+    juju show-action-output <action-id>
+
+
+# Using
+
+This charm provides a variety of actions and interfaces that can be used
+to interact with Hive.
+
+## Actions
+Run a smoke test (as described in the **Verifying** section):
+
+    juju run-action hive/0 smoke-test
+    juju show-action-output <id>  # <-- id from above command
+
+Restart all Hive services on a unit:
+
+    juju run-action hive/0 restart
+    juju show-action-output <id>  # <-- id from above command
+
+## Command Line Interface
+
+    $ juju ssh hive/0
+    $ hive
+    ...
+    hive> create table foo(col1 int, col2 string);
+    OK
+    Time taken: 0.381 seconds
+    hive> show tables;
+    OK
+    foo
+    hivesmoke
+    Time taken: 0.202 seconds, Fetched: 2 row(s)
+    hive> exit;
+
+### HBase
+As mentioned in the **Deploying** section, this charm supports integration
+with HBase. When HBase is deployed and related to Hive, use the Hive CLI to
+interact with HBase:
+
+    $ juju ssh hive/0
+    $ hive
+    ...
+    hive> CREATE TABLE myhivetable(key STRING, mycol STRING)
+    STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
+    WITH SERDEPROPERTIES ('hbase.columns.mapping' = ':key,cf:mycol')
+    TBLPROPERTIES ('hbase.table.name' = 'myhbasetable');
+    OK
+    Time taken: 2.497 seconds
+    hive> DESCRIBE myhivetable;
+    OK
+    key                 	string              	from deserializer
+    mycol               	string              	from deserializer
+    Time taken: 0.174 seconds, Fetched: 2 row(s)
+
+## Thrift Interface
+The HiveServer2 service provides a thrift server that can be used by Hive
+clients. To access this interface from external clients (i.e. applications
+that are not part of the Juju deployment), find the `Public address` of the
+hive unit and expose the application:
+
+    juju status hive
+    juju expose hive
+
+External clients will be able to access Hive using:
+
+    thrift://HIVE_PUBLIC_IP:10000
+
+
+# Configuring
+
+Charm configuration can be changed at runtime with `juju config`. This charm
+supports the following config parameters.
+
+## Heap
+The default heap size for the the Hive shell JVM is 1024MB. Set a different
+value (in MB) with the following:
+
+    juju config hbase heap=4096
+
+
+# Limitations
+
+## Restarting Hive
+Restarting Hive is potentially disruptive when queries are running. Be aware
+that the following events will cause a restart of all Hive services:
+
+- Adding or removing an HBase relation
+- Changing charm configuration with `juju config`
+- Upgrading this charm
+
+## Hive Web Interface
+The Hive Web Interface (HWI) has been removed upstream ([HIVE-15622][]). This
+charm does not provide HWI. Use the command line or thrift interfaces for
+interacting with Hive.
+
+[HIVE-15622]: https://issues.apache.org/jira/browse/HIVE-15622
+
+# Issues
+
+Apache Bigtop tracks issues using JIRA (Apache account required). File an
+issue for this charm at:
+
+https://issues.apache.org/jira/secure/CreateIssue!default.jspa
+
+Ensure `Bigtop` is selected as the project. Typically, charm issues are filed
+in the `deployment` component with the latest stable release selected as the
+affected version. Any uncertain fields may be left blank.
+
+
+# Contact Information
+
+- <bi...@lists.ubuntu.com>
+
+
+# Resources
+
+- [Apache Hive home page](http://hive.apache.org/)
+- [Apache Bigtop home page](http://bigtop.apache.org/)
+- [Apache Bigtop issue tracking](http://bigtop.apache.org/issue-tracking.html)
+- [Apache Bigtop mailing lists](http://bigtop.apache.org/mail-lists.html)
+- [Juju Big Data](https://jujucharms.com/big-data)
+- [Juju Bigtop charms](https://jujucharms.com/q/bigtop)
+- [Juju mailing list](https://lists.ubuntu.com/mailman/listinfo/juju)

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/actions.yaml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/actions.yaml b/bigtop-packages/src/charm/hive/layer-hive/actions.yaml
new file mode 100644
index 0000000..7870f30
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/actions.yaml
@@ -0,0 +1,4 @@
+restart:
+    description: Retart Hive Metastore and HiveServer2.
+smoke-test:
+  description: Verify that Hive is working.

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/actions/restart
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/actions/restart b/bigtop-packages/src/charm/hive/layer-hive/actions/restart
new file mode 100755
index 0000000..904614f
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/actions/restart
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+# 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.
+
+import sys
+sys.path.append('lib')
+
+from charmhelpers.core import hookenv  # noqa: E402
+from charms.layer.bigtop_hive import Hive  # noqa: E402
+from charms.reactive import is_state  # noqa: E402
+
+
+def fail(msg):
+    hookenv.action_set({'outcome': 'failure'})
+    hookenv.action_fail(msg)
+    sys.exit()
+
+
+if not is_state('hive.installed'):
+    fail('Hive is not yet ready')
+
+hive = Hive()
+hive.restart()

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/actions/smoke-test
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/actions/smoke-test b/bigtop-packages/src/charm/hive/layer-hive/actions/smoke-test
new file mode 100755
index 0000000..d6ac244
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/actions/smoke-test
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+# 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.
+
+import sys
+sys.path.append('lib')
+
+from charmhelpers.core import hookenv  # noqa: E402
+from charms.layer.apache_bigtop_base import Bigtop  # noqa: E402
+from charms.reactive import is_state  # noqa: E402
+
+
+def fail(msg):
+    hookenv.action_set({'outcome': 'failure'})
+    hookenv.action_fail(msg)
+    sys.exit()
+
+
+if not is_state('hive.installed'):
+    fail('Charm is not yet ready to run the Bigtop smoke test(s)')
+
+# Bigtop smoke test components
+smoke_components = ['hive']
+
+# Env required by test components
+smoke_env = {
+    'HIVE_HOME': '/usr/lib/hive',
+    'HIVE_CONF_DIR': '/etc/hive/conf',
+}
+
+bigtop = Bigtop()
+result = bigtop.run_smoke_tests(smoke_components, smoke_env)
+if result == 'success':
+    hookenv.action_set({'outcome': 'success'})
+else:
+    fail('{} smoke tests failed with: {}'.format(smoke_components, result))

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/config.yaml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/config.yaml b/bigtop-packages/src/charm/hive/layer-hive/config.yaml
new file mode 100644
index 0000000..90ce337
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/config.yaml
@@ -0,0 +1,6 @@
+options:
+    heap:
+        type: int
+        default: 1024
+        description: |
+          The maximum heap size (in MB) used by the Hive shell JVM.

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/copyright
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/copyright b/bigtop-packages/src/charm/hive/layer-hive/copyright
new file mode 100644
index 0000000..e900b97
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/copyright
@@ -0,0 +1,16 @@
+Format: http://dep.debian.net/deps/dep5/
+
+Files: *
+Copyright: Copyright 2015, Canonical Ltd., All Rights Reserved.
+License: Apache License 2.0
+ Licensed 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.

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/icon.svg
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/icon.svg b/bigtop-packages/src/charm/hive/layer-hive/icon.svg
new file mode 100644
index 0000000..12771d3
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/icon.svg
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg  PUBLIC '-//W3C//DTD SVG 1.1//EN'  'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
+<svg xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" xml:space="preserve" height="100%" width="100%" version="1.1" clip-rule="evenodd" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">
+    <g transform="translate(-2059.4 -1166.5)">
+        <g transform="translate(2109.4 1216.5)">
+            <g transform="translate(-50 -50)">
+                <clipPath id="_clip1">
+                    <rect y="0" x="0" height="100" width="100"/>
+                </clipPath>
+                <g clip-path="url(#_clip1)">
+                    <g id="hive">
+                        <g id="Oval.-Copy" transform="matrix(-1 -7.6571e-16 7.6571e-16 -1 100 100)">
+                            <circle cy="50" cx="50" r="50" fill="#e5e2e1"/>
+                        </g>
+                        <g transform="matrix(.066971 0 0 .066971 46.514 47.563)">
+                            <g transform="translate(-500 -450)">
+                                <clipPath id="_clip2">
+                                    <rect y="0" x="0" height="900" width="1e3"/>
+                                </clipPath>
+                                <g clip-path="url(#_clip2)">
+                                    <g stroke="#fdee21" stroke-width="5.13px" transform="translate(-.53268 66.8)">
+                                        <path d="m597.33 637.79v192.85h47.35v-88.63l9.76 0.18v88.45h47.88v-192.85h-47.88v71.55h-9.76v-71.55h-47.35z"/>
+                                        <path d="m761.25 637.79h-46.12v192.85h46.12v-192.85z"/>
+                                        <path d="m768.8 637.79l36.43 192.85h54.98l36.43-192.85h-48.95l-12.07 82.52c-1 3.16-4.4 3.16-5 0l-12.06-82.52h-49.76z"/>
+                                        <path d="m997.97 637.79h-91.54v192.85h91.54v-50.57l-50.9-0.43v-21.68h24.25v-50.21h-24.25v-19.39h50.9v-50.57z"/>
+                                    </g>
+                                    <g transform="translate(-.53268 66.8)">
+                                        <path d="m503.66 52.952c-7.71-21.115-272.92-124.22-276.31-112.9-48.7 12.695-68.52 68.826-102.02 104.38l-74.393-4.261c-32.771 42.142-49.967 85.199-38.258 129.95 42.002 56.91 90.761 105.33 121.15 176.81 2.4 33.69 145.82 3.53 176.56-3.13-41.99 30.05-78.56 76.65-62.85 210.84 14.35 63.01 24.16 133.36 151.4 204.64 16.75 9.38 51.41 20.2 72.84 28.09 20.5 9.4 44.46 13.27 112.07-7.41 39.13-16.86 81.37-27.02 119.65-43.84l-46.02 2.16c-63.36 1.37-112.29 6.1-127.38-11.6l-58.32-100.68 34-66.04c47.06 4.82 62.68 42.98 104.15 57.51l48.89-36.21c141.99 83.82 198.48-53.12 214.67-159.77-1.73-43.39-93.95 13.61-88.36-6.68 2.16-46.64-35.86-107.67-60.42-155.22l28.43-110.01c12.9-11.49-59.72-133.86-119.02-149.12-52.03-13.391-130.46 52.492-130.46 52.492z" fill="#fdee21"/>
+                                    </g>
+                                        <g transform="translate(-.53268 66.8)" fill="#c8c037">
+                                            <path d="m736.92 286.75c0.51 11.82 0.45 26.19 1.59 35.15-0.19 6.84-5.32 7.09-9.56 8.52l27.63 10.12c5.49 9.23 9.9 18.46 14.35 27.69 5.16 22.71 1.31 23.36-2.13 25.03-10.02 0.11-20.02 0.13-29.36-1.86 4.18 2.21 5.1 3.82 5.55 6.64 0.81 5.22-2.54 12.33-8.07 19.19 8.17 4.53 23.07 8.97 34.14 13.18l12.62-28.09c-5.72-41.27-23.04-79.31-46.76-115.57z"/>
+                                            <path d="m788.49 425.18c15.32 6.39 36.49 4.52 65.85-10.61 4.36-3.11 8.43-1.25 0.62 3.85-38.5 34.55-56.93 17.27-66.47 6.76z"/>
+                                            <path d="m857.28 410.04c4.55 8.72 1.79 15.8 0.27 23.17-4.76 37.45-16.43 67.05-39.33 97.99-74.47 119.74-149.66 44.82-209.62-3.94l-24.79 62.13c-1.32 5.45-6.79 9.69 31.93 26.74l39.46-27.87c150.46 114.48 257.08-160.24 202.08-178.22z"/>
+                                            <path d="m626.75 517.04c-10.15 0.72-40.36 11-41.71 16.95l13.91-20.72 27.8 3.77z"/>
+                                            <path d="m607.01 390.07c1.86 0 10.79 2.4 9.83 1.86-1.37-0.76-0.15 12.52 2.66 19.44l-10.9 23.7c20.87-24.06 53.86-22.46 84.49-25.56l-14.61-9.05c2.54-8.47-0.45-15.17-1.86-22.37l-69.61 11.98z"/>
+                                            <path d="m658.28 318.71c-22.39 6.86-43.82 18.07-58.2 41.98 10.97-39.4 13.21-37.9 16.75-39.85 15.35-6.86 27.93-2.59 41.45-2.13z"/>
+                                        </g>
+                                        <g transform="translate(-.53268 66.8)" fill="#fcf6a0">
+                                            <path d="m538.73 780.45c-27.07 29.87-87.47-2.26-137.63-18.64-127.46-81.05-152.36-157.35-154.09-232.2-6.55-107.22 26.37-169.52 68.01-184.27-27.56 53.13-40.41 148.5-27.63 219.42 10.32 39.46 10.53 106 76.55 141.62 32.32 18.2 23.57 32.37 45.43 49.41 23.95 18.68 90.75 36.44 129.36 24.66z"/>
+                                            <path d="m579.17 284.94c-45.83-64.99-110.29-89.39-182.98-92.05 14.57-4.75 29.14-7.23 43.7-14.25 3.57-3.75 2.41-10.34 1.07-17.04-69.97-18.27-114.13-40.85-170.03-61.782l150.91 36.212c101.91 3.87 93.16 29.03 157.34 148.91h-0.01z"/>
+                                            <path d="m628.24 253.6c-33.87-48.35-66.72-107.03-111.31-144.35-107.64-48.584-214.12-84.666-338.91-117.5l39.83-51.216c132.42 30.227 256.8 80.808 368.21 164.19 18.85 47.66 31.42 95.39 42.17 148.87l0.01 0.01z"/>
+                                            <path d="m696.52 168.16s-18.99-42.6-28.23-58.87c-21.45-23.762-32.29-68.05-76.22-88.918 13.9 3.752 23.4-0.718 51.76 24.992l44.67 84.736 8.02 38.06z"/>
+                                            <path d="m720.14 241.96c4.38-36.91 12.7-96.11 3.15-119.5-26.55-35.624-53.29-72.446-80.04-106.63-4.43-4.123-7.62-9.719-11.11-14.084 37.61 9.744 76.86 35.894 129.79 139.13l-41.79 101.08z"/>
+                                        </g>
+                                        <g transform="translate(-.53268 66.8)">
+                                            <path d="m562.02 246.32c-14.98-11.79-28.33-53.49-51.03-62.16-21.01-1.76-28.71-8.37-56.34-2.74 10.02-5.02 19.48-11.44 30.13-14.88 7.22-1.71 13.98 0.18 20.87 1.13 1.7-0.8 2.81-1.8 2.39-3.31-27.81-17.19-84.86-17.44-123.38-27.25 44.7 1.5 94.16-0.98 127.76 9.79 27.01 23.98 35.78 69.12 49.6 99.42z"/>
+                                            <path d="m643.93 45.227c6.2 0.563 39.57 53.353 41.14 62.133 2.78 19.21 9.62 40.73 11.46 60.82-5.49-19.27-11.48-38.53-18.97-57.8-2.19-5.31-7.73-17.305-23.11-34.272-7.16-11.959-8.71-21.359-10.52-30.88v-0.001z"/>
+                                            <path d="m757.02 332.75h-14.28l15.78 4.14-1.5-4.14z"/>
+                                            <path d="m659.6 318.49c-14.36-1.77-29.09-2-43.45 1.16-5.85 7.86-6.25 15.85-8.81 23.24 17.45-19.23 24.38-20.41 52.26-24.4z"/>
+                                            <path d="m855.42 417.77c-7.99 6.38-8.79 12.38-32.41 19.57-17.23 4.08-26.96-2.83-35.07-12.11 12.29 3.52 14.26 12.81 47.22 2.39l20.26-9.85z"/>
+                                            <path d="m783.82 421.76c-5.75 15.81-11.95 31.79-18.2 46.6-14.88 17.45-8.54 7.51-30.82 34.62 7.13-11 16.4-21.57 21.26-33.02 3.4-7.54 7.65-15.55 9.53-22.25-5.91-2.95-18-3.18-19.64-2.12-19.81 11.68-23.38 24.05-35.06 36.08 8.46-13.53 15.69-28.29 25.51-40.47 1.11-1.58 8.38-1.89 12.84-2.82-6.94-1.19-19.78-3.68-20.82-3.57-12.92 3.1-20.16 14.36-29.75 21.83 6.99-10.1 13.43-20.61 22.31-29.29 0.88-1.02 24.89 1.08 37.33 6.05l0.25 4.95 7.06 2.85 5.31-13.32 12.89-6.12z"/>
+                                            <path d="m627.07 517.09c-3.19-1.09-31.35-4.71-31.35-3.86-10.81 7.69-12.45 15.06-12.22 21.43 17.99-17.69 17.32-17.74 43.57-17.57z"/>
+                                            <path d="m605.68 389.81s20.32-2.96 19.93-1.07c-1.48 7.06 2.48 24.24 2.92 21.84l-11.43 9.32c23.93-12.03 49.12-9.61 74.66-11.45 0 0-21.51-5.94-20.19-6.12 4.8-0.68-1.28-22.43-2.92-22.91 4.09-1.38 8.08-2.42 12.22-3.46-30.76-8.04-48.54-3.3-75.19 13.85z"/>
+                                            <path d="m781.56 404.98l-4.52 2.26c-0.64-13.23-14.85-12.26-26.83-12.38l-9.83-2.4c2.99 2.77 12.23 2.55 8.5 8.53-3.14 1.67-4.58 8.87-6.38 14.91l-5.31 0.26c9.39 3.67 18.1 6.89 28.43 11.19l6.11 0.93 14.61-7.86-4.78-15.44z"/>
+                                        </g>
+                                        <g transform="translate(-.53268 66.8)" fill="#fff">
+                                            <path d="m646.86 396.06c-2.29-4.52-13.79-3.88-16.28-0.96-2.01 2.38-0.12 17.65 2.46 15.07 3.74-3.28 8.62-4.66 14.48-4.39 0.74-2.82 0.48-5.86-0.66-9.72z"/>
+                                            <path d="m757.21 418.8c1.08-0.79 3.37-8.44 2.63-10.73-1.51-5.41-12.21-4.27-12.21-4.27-2.61 1.54-4.9 9.96-3.95 12.74 0.46 2.35 11.81 3.1 13.53 2.26z"/>
+                                        </g>
+                                        <g transform="translate(-.53268 66.8)">
+                                            <path d="m299.64 682.84l6.76 0.66c40.07 19.68 106.05 48.85 201.57 33.17l14.99 23.59c-42.07 20.44-87.31 15.73-129.71 17.17l-93.61-74.59z"/>
+                                            <path d="m242.11 527.3l20.07 84.27c53.74 33.59 145.54 72.07 222.06 68.96l-16.91-38.8c-159.73-33.92-173.24-76.8-225.22-114.44v0.01z"/>
+                                            <path d="m292.06 354.69c9.81 65.3 22.91 114.81 79.69 156.28 34.8 25.03 69.35 49.95 111.37 70.52 0 0-3.68 19.17-6.76 18.83-125.05-13.89-216.6-117.58-227.69-164.94 10.74-36.33 26.15-59.02 43.39-80.69z"/>
+                                            <path d="m352.17 317.69c16.66 72.38 56.4 145.68 95.89 212.18 14.48 18.37 18.26 26.47 40.58 37.66 30.16 9.55 51.48 7.11 73.38 5.67-6-11.1-11.33-22.7-18.22-33.14-49.02-38.76-26.37-74.06-13.35-96.4-27.25-6.89-63.37-21.53-68.34-40.78-8-62.27-3.94-82.02 4.07-114.01-36.91 7.78-74.31 15.49-114.01 28.82z"/>
+                                            <path stroke-width=".11px" d="m216.77-66.742c-12.13 7.925-23.82 19.256-36.39 32.135-20.84 21.575-34.7 42.621-55.92 58.224-4.24 3.659-16.15 9.551-31.117 10.425-7.052 0.352-11.646 1.519-24.604-0.108-11.428-6.188-22.285-2.164-32.881 10.51-11.619 16.709-26.334 48.437-32.453 68.406-12.611 50.94 19.541 92.91 50.374 125.25 27.429 26.8 43.243 43.55 54.501 68.11 8.53 15.93 14.85 37.8 21.69 53.13 2.46 4.86 1.95 4.84 8.59 6.3 14.33 3.06 34.21 3.08 51.91 4.6 7.66 0.11 18.18-0.17 28.14-1.21 13.73-2.59 29.87-5.13 43.39-9.81 13.21-3.26 24.98-7.76 35.59-11.91-1.36 4.65-11.47 9.12-15.26 15-35.97 51.49-45.83 97.31-39.57 169.6 3.55 32.05 10.9 58.61 22 89 5.08 13.91 15.88 35.93 26.23 50.57 30.79 43.5 99.67 99.37 195.56 120.88 16.73 2.28 35.72 1.06 53.57-3.69 47.33-14.35 143.78-48.28 143.78-48.28s-85.62 7.09-124.83 3.21c-9.07-1.42-19.08-1.9-25.4-8.09-1.06-1.37-4.91-9.13-2.43-9.2 3.4-0.1 13.15-4.14 28.2-5.48-32.13-3.46-31.68-3.42-34.02-9.27-3.65-9.09-9.23-21.5-
 14.98-32.37 14.12 1.19 45.38 2.95 55.99-8 0 0-18.5 2.13-34.85 0.22-5.5-0.65-14.89-4-17.71-5.03-7.34-2.86-13.38-3.75-14.79-5.61-2.54-6.49-4.27-8.67-7.35-17.36-4.16-11.5-4.49-24.34-5.29-36.08 10.7 13.18 24.32 24.27 42.36 29.94 0.23-0.49 23.4 10.07 40.23 4.64l3.49-1.13c0 0.32-11.15 0.98-15.24-1.04-34.22-14.55-39.37-27.28-44.9-33.6l-14.77-22.13c4.49-8.97 7.03-9.31 12.99-9.39 18.01 2 25.84 3.54 36.8 0.9 7.41 15.24 9.41 30.57 26.27 41.66 56.16 16.67 68.37-4.95 81.97-24.06 40.41 29.66 106.2 38.81 151.89 0.52 58.09-67.22 76.48-173.17 71.33-179.22-7.26-12.31-16.78-25-24.95-23.25-29.13 7.95-39.87 22.73-68.73 19.36 3.43-0.19 9.21-0.29 9.26-0.61 2.22-24.44-0.18-36.27-1.25-38.3-8.76-19.32-20.27-39.65-28.28-54.88-2.07-3.16-8.14-27.17-18.31-36.65-4.36-3.72-15.04-13.55-15.04-13.55l-0.9 10.44s4.17 0.63 5.76 7.1c6.02 24.52 36.69 82.49 38.94 85.26 10.86 17.55 1.1 39.4 9.36 51.67 0.8 1.55 16.86-0.14 29.31 0.63 20.47-4.41 19.61-13.43 37.29-14.79 11.92-0.91 13.11 21.46 12.96 23.2-2.22 24.7-9.74 53.43-21.
 24 79.66-23.91 46.07-50.69 87.44-88.67 93.21-46.33 8.1-70.4-12.16-95.51-25.05l-9.61 8.19c-32.64 32.5-71.39 29.62-87.24-12.85-7.89-16.47-18.17-26.57-26.97-40.7l-46.69 33.63c-3.89 7.97-8.67 20.54-14.47 34.58-4.04 9.76-7.42 26.52-7.2 40.45-5.99 10.2 20.73 51.55 37.61 76.7 4.98 7.42 14.28 20.38 14.59 21.19 3.34 8.68 10.68 16.35 11.12 17.28 31.34 40.88-39.53 31.46-54.16 28.99-28.88-4.6-57.13-16.66-83.68-32.79-1.54-0.93-3.07-1.88-4.6-2.85-31.55-19.86-60.58-45.28-85.26-70.42-14.72-16.67-28.74-50.83-39.09-75.04-15.51-58.23-37.77-159.15 22.53-235.63 3.83-4.38 7.95-11.65 11.46-13.09 17.92-12.12 37.38-20.38 58.3-24.97l-2.11-13.56c-10.45 2.37-45.63 15.24-55.58 20.63-22.62 6.55-41.39 13.4-70.22 20.62-9.37 1.15-18.59 1.17-27.58-0.05-20.74-2.82-56.09-0.3-58.35-2.4-14.04-19.58-17.89-54.68-30.7-73.46l-0.15-0.18-0.17-0.18c-7.46-10.04-16.172-18.23-24.747-26.75-30.708-30.51-56.991-60.01-64.348-91.27-1.85-9.23-6.614-18.79-4.082-46.1l0.047-0.13 0.044-0.14c7.388-25.51 19.407-46.307 39.806-67.15 21.228 0.3
 42 42.24 0.809 58.61 3.935 7.51 1.256 23.12 3.296 39.25 9.304 40.82 15.207 94.76 40.211 94.76 40.211-40.49-22.238-85.76-51.117-114.35-56.945-4.25-0.602-6.87-2.543-8.13-5.93 43-25.264 50.86-55.009 79.14-81.686 12.93-5.626 17.97-8.498 28.95-9.692 101.57 16.06 165.51 56.515 216.09 83.566 20.53 11.164 39.19 19.606 57.02 29.773 15.62 5.139 62.77 40.734 76.57 59.924 14.01 29.6 24.25 61.56 33.58 92.41 6.69 31.38 12.57 44.1 12.57 44.1s-5.69-26.24-4.74-30.95c5.89 2.2 19.84 6.55 25.62 5.88 0 0-25.82-13.35-29.2-25.14-10.86-37.85-21.75-96.77-24.68-99.84-8.28-10.412-42.78-36.817-63.95-49.031-8-4.62-12.33-7.486-12.67-9.518 6.76-6.83 15.11-15.865 22.6-21.606 7.18-5.503 13.71-11.709 23.71-15.423 43.97-19.8 69.11 7.618 75.07 2.066 0 0-9.46-10.841-5.26-9.056 4.3 2.33 18.33 5.078 19.86 6.509 16.03 12.534 57.92 58.344 83.17 106.68 6.06 11.84 8.53 19.64 5.71 33.89-2.82 14.27-5 22.12-8.08 31.65-2.77 6.37-18.49 49.99-18.43 55.85-3.17 23.93 10.26 53.89 10.26 53.89 0.13-8.13-0.5-12.46 0.24-18.28l0.9-10.39s-
 0.57-2.77-0.47-3.86c0.68-7.19 2.45-13.23 2.97-17.35 5.04-31.25 13.82-53.75 23.77-81.18 2.96-6.92 6.83-10.77 6.63-16.04 0.16-9.35-8.2-21.9-14.25-34.16-6.1-12.39-13.39-26.206-22.96-40.764-21.82-31.376-40.42-55.925-74.48-71.289-9.53-4.182-47.03-8.271-59.98-5.841-15.71 3.273-29.22 6.5-39.99 13.398-16.95 10.854-30.27 27.659-45.89 37.561-34.56-17.282-51.24-30.216-54.35-31.999-20.54-11.006-45.2-23.778-71.73-35.89-12.72-11.862-91.71-40.233-164.04-45.892l-0.01-0.006zm442.08 644.59c-21.3-16.65-39.23-33.79-51.05-51.44-3.86 20.76-17.86 35.54-28.69 50.08-2.15 3.41-3.71 8.06 6.9 22.88 2.86 3.95 13.21 4.62 20.2 4.26-7.11-5.37-17.92-11.05-19.66-15.98 12.5 8.51 24.07 10.96 34.53 9.59 2.4-0.27 5.36-2.8 7.66-6.71 4.66-10.02 8.32-12.43 12-15.13l8.51 10.66 9.6-8.21z" stroke="#000"/>
+                                        </g>
+                                </g>
+                            </g>
+                        </g>
+                    </g>
+                </g>
+            </g>
+        </g>
+    </g>
+</svg>

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/layer.yaml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/layer.yaml b/bigtop-packages/src/charm/hive/layer-hive/layer.yaml
new file mode 100644
index 0000000..5be7ac9
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/layer.yaml
@@ -0,0 +1,31 @@
+repo: https://github.com/apache/bigtop/tree/master/bigtop-packages/src/charm/hive/layer-hive
+includes:
+  - 'layer:apache-bigtop-base'
+  - 'layer:hadoop-client'
+  - 'interface:hbase'
+  - 'interface:hive'
+  - 'interface:mysql'
+options:
+  basic:
+    packages:
+      - 'libmysql-java'
+      - 'mysql-client'
+  apache-bigtop-base:
+    groups:
+      - 'hadoop'
+      - 'hive'
+    users:
+      ubuntu:
+        groups: ['hadoop', 'hive']
+    dirs:
+      hive:
+        path: '/usr/lib/hive'
+      hive_conf:
+        path: '/etc/hive/conf'
+    ports:
+      hive-thrift:
+        port: 10000
+        exposed_on: 'hive'
+      hive-thrift-web:
+        port: 10001
+        exposed_on: 'hive'

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/lib/charms/layer/bigtop_hive.py
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/lib/charms/layer/bigtop_hive.py b/bigtop-packages/src/charm/hive/layer-hive/lib/charms/layer/bigtop_hive.py
new file mode 100755
index 0000000..c7d9cc6
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/lib/charms/layer/bigtop_hive.py
@@ -0,0 +1,138 @@
+# 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.
+
+from charmhelpers.core import hookenv, host, unitdata
+from charms import layer
+from charms.layer.apache_bigtop_base import Bigtop
+from jujubigdata import utils
+
+
+class Hive(object):
+    '''This class manages Hive.'''
+    def __init__(self):
+        self.dist_config = utils.DistConfig(
+            data=layer.options('apache-bigtop-base'))
+
+    def install(self, hbase=None):
+        '''
+        Trigger the Bigtop puppet recipe that handles the Hive service.
+        '''
+        # Dirs are handled by the bigtop deb. No need to call out to
+        # dist_config to do that. We do want 'ubuntu' in the hive group though.
+        self.dist_config.add_users()
+
+        # Prep config
+        roles = ['hive-client', 'hive-metastore', 'hive-server2']
+        metastore = "thrift://{}:9083".format(hookenv.unit_private_ip())
+        if hbase:
+            roles.append('hive-hbase')
+            hb_connect = "{}:{}".format(hbase['host'], hbase['master_port'])
+            zk_connect = hbase['zk_connect']
+        else:
+            hb_connect = ""
+            zk_connect = ""
+
+        override = {
+            'hadoop_hive::common_config::hbase_master': hb_connect,
+            'hadoop_hive::common_config::hbase_zookeeper_quorum': zk_connect,
+            'hadoop_hive::common_config::metastore_uris': metastore,
+            'hadoop_hive::common_config::server2_thrift_port':
+                self.dist_config.port('hive-thrift'),
+            'hadoop_hive::common_config::server2_thrift_http_port':
+                self.dist_config.port('hive-thrift-web'),
+        }
+        bigtop = Bigtop()
+        bigtop.render_site_yaml(roles=roles, overrides=override)
+        bigtop.trigger_puppet()
+
+        # Bigtop doesn't create a hive-env.sh, but we need it for heap config
+        hive_env = self.dist_config.path('hive_conf') / 'hive-env.sh'
+        if not hive_env.exists():
+            (self.dist_config.path('hive_conf') / 'hive-env.sh.template').copy(hive_env)
+
+    def configure_hive(self):
+        '''
+        Called during config-changed events
+        '''
+        config = hookenv.config()
+        hive_env = self.dist_config.path('hive_conf') / 'hive-env.sh'
+        utils.re_edit_in_place(hive_env, {
+            r'.*export HADOOP_HEAPSIZE *=.*': 'export HADOOP_HEAPSIZE=%s' % config['heap'],
+        })
+
+    def configure_remote_db(self, mysql):
+        hive_site = self.dist_config.path('hive_conf') / 'hive-site.xml'
+        jdbc_url = "jdbc:mysql://{}:{}/{}?createDatabaseIfNotExist=true".format(
+            mysql.host(), mysql.port(), mysql.database()
+        )
+        with utils.xmlpropmap_edit_in_place(hive_site) as props:
+            props['javax.jdo.option.ConnectionURL'] = jdbc_url
+            props['javax.jdo.option.ConnectionUserName'] = mysql.user()
+            props['javax.jdo.option.ConnectionPassword'] = mysql.password()
+            props['javax.jdo.option.ConnectionDriverName'] = "com.mysql.jdbc.Driver"
+
+        hive_env = self.dist_config.path('hive_conf') / 'hive-env.sh'
+        utils.re_edit_in_place(hive_env, {
+            r'.*export HIVE_AUX_JARS_PATH *=.*': 'export HIVE_AUX_JARS_PATH=/usr/share/java/mysql-connector-java.jar',
+        })
+
+        # Now that we have db connection info, init our schema (only once)
+        remote_db = hookenv.remote_service_name()
+        if not unitdata.kv().get('hive.schema.initialized.%s' % remote_db):
+            tool_path = "{}/bin/schematool".format(self.dist_config.path('hive'))
+            utils.run_as('ubuntu', tool_path, '-initSchema', '-dbType', 'mysql')
+            unitdata.kv().set('hive.schema.initialized.%s' % remote_db, True)
+            unitdata.kv().flush(True)
+
+    def configure_local_db(self):
+        local_url = 'jdbc:derby:;databaseName=/var/lib/hive/metastore/metastore_db;create=true'
+        local_driver = 'org.apache.derby.jdbc.EmbeddedDriver'
+        hive_site = self.dist_config.path('hive_conf') / 'hive-site.xml'
+        with utils.xmlpropmap_edit_in_place(hive_site) as props:
+            props['javax.jdo.option.ConnectionURL'] = local_url
+            props['javax.jdo.option.ConnectionUserName'] = 'APP'
+            props['javax.jdo.option.ConnectionPassword'] = 'mine'
+            props['javax.jdo.option.ConnectionDriverName'] = local_driver
+
+        hive_env = self.dist_config.path('hive_conf') / 'hive-env.sh'
+        utils.re_edit_in_place(hive_env, {
+            r'.*export HIVE_AUX_JARS_PATH *=.*': '# export HIVE_AUX_JARS_PATH=',
+        })
+
+    def restart(self):
+        self.stop()
+        self.start()
+
+    def start(self):
+        # order is important; metastore must start first.
+        hookenv.log('Starting Hive services')
+        host.service_start('hive-metastore')
+        host.service_start('hive-server2')
+        hookenv.log('Hive services have been started')
+
+    def stop(self):
+        # order is important; metastore must stop last.
+        hookenv.log('Stopping Hive services')
+        host.service_stop('hive-server2')
+        host.service_stop('hive-metastore')
+        hookenv.log('Hive services have been stopped')
+
+    def open_ports(self):
+        for port in self.dist_config.exposed_ports('hive'):
+            hookenv.open_port(port)
+
+    def close_ports(self):
+        for port in self.dist_config.exposed_ports('hive'):
+            hookenv.close_port(port)

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/metadata.yaml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/metadata.yaml b/bigtop-packages/src/charm/hive/layer-hive/metadata.yaml
new file mode 100644
index 0000000..998dd72
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/metadata.yaml
@@ -0,0 +1,19 @@
+name: hive
+summary: Hive from Apache Bigtop
+maintainer: Juju Big Data <bi...@lists.ubuntu.com>
+description: >
+  Apache Hive is a data warehouse infrastructure built on top of Hadoop that
+  supports data summarization, query, and analysis. Hive provides an SQL-like
+  language called HiveQL that transparently converts queries to MapReduce for
+  execution on large datasets stored in Hadoop's HDFS.
+
+  This charm provides version 1.2.1 of the Hive application from Apache Bigtop.
+tags: []
+provides:
+  client:
+    interface: hive
+requires:
+  database:
+    interface: mysql
+  hbase:
+    interface: hbase

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/reactive/hive.py
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/reactive/hive.py b/bigtop-packages/src/charm/hive/layer-hive/reactive/hive.py
new file mode 100644
index 0000000..0deebd4
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/reactive/hive.py
@@ -0,0 +1,184 @@
+# 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.
+
+from charmhelpers.core import hookenv
+from charms.layer.apache_bigtop_base import get_layer_opts, get_package_version
+from charms.layer.bigtop_hive import Hive
+from charms.reactive import (
+    RelationBase,
+    is_state,
+    remove_state,
+    set_state,
+    when,
+    when_not,
+)
+from charms.reactive.helpers import data_changed
+
+
+@when('bigtop.available')
+def report_status():
+    hadoop_joined = is_state('hadoop.joined')
+    hadoop_ready = is_state('hadoop.ready')
+    hbase_joined = is_state('hbase.joined')
+    hbase_ready = is_state('hbase.ready')
+    database_joined = is_state('database.connected')
+    database_ready = is_state('database.available')
+    hive_installed = is_state('hive.installed')
+    if not hadoop_joined:
+        hookenv.status_set('blocked',
+                           'waiting for relation to hadoop plugin')
+    elif not hadoop_ready:
+        hookenv.status_set('waiting',
+                           'waiting for hadoop to become ready')
+    elif database_joined and not database_ready:
+        hookenv.status_set('waiting',
+                           'waiting for database to become ready')
+    elif hbase_joined and not hbase_ready:
+        hookenv.status_set('waiting',
+                           'waiting for hbase to become ready')
+    elif hive_installed and not database_ready:
+        hookenv.status_set('active',
+                           'ready (local metastore)')
+    elif hive_installed and database_ready:
+        hookenv.status_set('active',
+                           'ready (remote metastore)')
+
+
+@when('bigtop.available', 'hadoop.ready')
+def install_hive(hadoop):
+    '''
+    Anytime our dependencies are available, check to see if we have a valid
+    reason to (re)install. These include:
+    - initial install
+    - HBase has joined/departed
+    '''
+    # Hive cannot handle - in the metastore db name and
+    # mysql uses the service name to name the db
+    if "-" in hookenv.service_name():
+        hookenv.status_set('blocked', "application name may not contain '-'; "
+                                      "redeploy with a different name")
+        return
+
+    # Get hbase connection dict if it's available
+    if is_state('hbase.ready'):
+        hbase = RelationBase.from_state('hbase.ready')
+        hbserver = hbase.hbase_servers()[0]
+    else:
+        hbserver = None
+
+    # Use this to determine if we need to reinstall
+    deployment_matrix = {
+        'hbase': hbserver,
+    }
+
+    # Handle nuances when installing versus re-installing
+    if not is_state('hive.installed'):
+        prefix = "installing"
+
+        # On initial install, prime our kv with the current deployment matrix.
+        # Subsequent calls will use this to determine if a reinstall is needed.
+        data_changed('deployment_matrix', deployment_matrix)
+    else:
+        prefix = "configuring"
+
+        # Return if our matrix has not changed
+        if not data_changed('deployment_matrix', deployment_matrix):
+            return
+
+    hookenv.status_set('maintenance', '{} hive'.format(prefix))
+    hookenv.log("{} hive with: {}".format(prefix, deployment_matrix))
+    hive = Hive()
+    hive.install(hbase=hbserver)
+    hive.restart()
+    hive.open_ports()
+    set_state('hive.installed')
+    report_status()
+
+    # set app version string for juju status output
+    hive_version = get_package_version('hive') or 'unknown'
+    hookenv.application_version_set(hive_version)
+
+
+@when('hive.installed', 'config.changed.heap')
+def config_changed():
+    hookenv.status_set('maintenance', 'configuring with new options')
+    hive = Hive()
+    hive.configure_hive()
+    hive.restart()
+    report_status()
+
+
+@when('hive.installed', 'database.available')
+@when_not('hive.db.configured')
+def configure_with_remote_db(db):
+    hookenv.status_set('maintenance', 'configuring external database')
+    hive = Hive()
+    hive.configure_remote_db(db)
+    hive.restart()
+    set_state('hive.db.configured')
+    report_status()
+
+
+@when('hive.installed', 'hive.db.configured')
+@when_not('database.available')
+def configure_with_local_db():
+    '''
+    Reconfigure Hive using a local metastore db.
+
+    The initial installation will configure Hive with a local metastore_db.
+    Once an external db becomes available, we reconfigure Hive to use it. If
+    that external db goes away, we'll use this method to set Hive back into
+    local mode.
+    '''
+    hookenv.status_set('maintenance', 'configuring local database')
+    hive = Hive()
+    hive.configure_local_db()
+    hive.restart()
+    remove_state('hive.db.configured')
+    report_status()
+
+
+@when('hive.installed')
+@when_not('hadoop.ready')
+def stop_hive():
+    '''
+    Hive depends on Hadoop. If we are installed and hadoop goes away, shut down
+    services and remove our installed state.
+    '''
+    hive = Hive()
+    hive.close_ports()
+    hive.stop()
+    remove_state('hive.installed')
+    report_status()
+
+
+@when('hive.installed', 'client.joined')
+def serve_client(client):
+    '''
+    Inform clients when hive is ready to serve.
+    '''
+    port = get_layer_opts().port('hive-thrift')
+    client.send_port(port)
+    client.set_ready()
+
+
+@when('client.joined')
+@when_not('hive.installed')
+def stop_serving_client(client):
+    '''
+    Inform connected clients that Hive is no longer ready. This can happen
+    if Hadoop goes away (the 'installed' state will be removed).
+    '''
+    client.clear_ready()

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/tests/01-basic-deployment.py
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/tests/01-basic-deployment.py b/bigtop-packages/src/charm/hive/layer-hive/tests/01-basic-deployment.py
new file mode 100755
index 0000000..04a614d
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/tests/01-basic-deployment.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+
+# 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.
+
+import amulet
+import re
+import unittest
+
+
+class TestDeploy(unittest.TestCase):
+    """
+    Trivial deployment test for Apache Bigtop Hive.
+    """
+    @classmethod
+    def setUpClass(cls):
+        cls.d = amulet.Deployment(series='xenial')
+        cls.d.add('hive')
+
+        cls.d.setup(timeout=1800)
+        cls.d.sentry.wait_for_messages({'hive': re.compile('ready|waiting')},
+                                       timeout=1800)
+        cls.unit = cls.d.sentry['hive'][0]
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/tests/02-smoke-test.py
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/tests/02-smoke-test.py b/bigtop-packages/src/charm/hive/layer-hive/tests/02-smoke-test.py
new file mode 100755
index 0000000..8693032
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/tests/02-smoke-test.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+
+# 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.
+
+import amulet
+import re
+import unittest
+
+
+class TestDeploy(unittest.TestCase):
+    """
+    Hadoop/Hive deployment and smoke test for the Apache Bigtop Hive service.
+    """
+    @classmethod
+    def setUpClass(cls):
+        cls.d = amulet.Deployment(series='xenial')
+        cls.d.add('hive')
+        cls.d.add('namenode', 'hadoop-namenode')
+        cls.d.add('plugin', 'hadoop-plugin')
+        cls.d.add('resourcemanager', 'hadoop-resourcemanager')
+        cls.d.add('slave', 'hadoop-slave')
+
+        cls.d.relate('hive:hadoop', 'plugin:hadoop-plugin')
+        cls.d.relate('plugin:namenode', 'namenode:namenode')
+        cls.d.relate('plugin:resourcemanager', 'resourcemanager:resourcemanager')
+        cls.d.relate('resourcemanager:namenode', 'namenode:namenode')
+        cls.d.relate('slave:namenode', 'namenode:datanode')
+        cls.d.relate('slave:resourcemanager', 'resourcemanager:nodemanager')
+
+        cls.d.setup(timeout=3600)
+        cls.d.sentry.wait_for_messages({'hive': re.compile('ready')},
+                                       timeout=3600)
+        cls.hive = cls.d.sentry['hive'][0]
+
+    def test_hive(self):
+        """
+        Validate Hive by running the smoke-test action.
+        """
+        uuid = self.hive.run_action('smoke-test')
+        result = self.d.action_fetch(uuid, full_output=True)
+        # action status=completed on success
+        if (result['status'] != "completed"):
+            self.fail('Hive smoke-test failed: %s' % result)
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/bigtop/blob/2022c147/bigtop-packages/src/charm/hive/layer-hive/tests/tests.yaml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/charm/hive/layer-hive/tests/tests.yaml b/bigtop-packages/src/charm/hive/layer-hive/tests/tests.yaml
new file mode 100644
index 0000000..3b6ce3e
--- /dev/null
+++ b/bigtop-packages/src/charm/hive/layer-hive/tests/tests.yaml
@@ -0,0 +1,3 @@
+reset: false
+packages:
+  - amulet