Permalink
Browse files

Merge pull request #8 from juju-solutions/java

Refactors to support dynamic Java charm binding
  • Loading branch information...
2 parents a940800 + f5bd02e commit 995a21f5149a36182dfb6eec59dfd4b52abfef38 @kwmonroe kwmonroe committed May 18, 2016
Showing with 19 additions and 4 deletions.
  1. +1 −1 layer.yaml
  2. +4 −0 metadata.yaml
  3. +14 −3 reactive/hadoop_client.py
View
@@ -1,5 +1,5 @@
repo: git@github.com:juju-solutions/layer-hadoop-client.git
-includes: ['layer:basic', 'interface:hadoop-plugin']
+includes: ['layer:basic', 'interface:hadoop-plugin', 'interface:java']
defines:
packages:
description: >
View
@@ -12,3 +12,7 @@ tags: ["bigdata", "hadoop"]
provides:
hadoop:
interface: hadoop-plugin
+ scope: container
+ java:
+ interface: java
+ scope: container
View
@@ -1,5 +1,5 @@
# pylint: disable=unused-argument
-from charms.reactive import when, when_not
+from charms.reactive import when, when_not, when_not_all, is_state
from charmhelpers.core import hookenv
from charms import layer
@@ -12,11 +12,22 @@ def report_ready(hadoop):
hookenv.status_set('active', 'Ready')
-@when_not('hadoop.joined')
+@when_not_all('hadoop.joined', 'java.ready')
def report_blocked():
cfg = layer.options('hadoop-client')
if not cfg.get('silent'):
- hookenv.status_set('blocked', 'Waiting for relation to Hadoop Plugin')
+ missing = []
+ if not is_state('hadoop.joined'):
+ missing.append('relation to Hadoop Plugin')
+ if not is_state('java.ready'):
+ missing.append('Java')
+ missing = ' & '.join(missing)
+ hookenv.status_set('blocked', 'Waiting for {}'.format(missing))
+
+
+@when('hadoop.joined', 'java.ready')
+def proxy_java(hadoop, java):
+ hadoop.set_java_info(java.java_home(), java.java_version())
@when('hadoop.joined')

0 comments on commit 995a21f

Please sign in to comment.