<commit_before>from charms.reactive import when, when_not, set_state, is_state, remove_state
from charms.hadoop import get_hadoop_base
from jujubigdata.handlers import YARN
from jujubigdata import utils
from charmhelpers.core import hookenv


@when('hadoop.installed')
@when_not('resourcemanager.related')
def blocked():
    hookenv.status_set('blocked', 'Waiting for relation to ResourceManager')


@when('hadoop.installed', 'resourcemanager.related')
def set_spec(resourcemanager):
    hadoop = get_hadoop_base()
    resourcemanager.set_nodemanager_spec(hadoop.spec())


@when('resourcemanager.spec.mismatch')
def spec_mismatch(resourcemanager):
    hookenv.status_set('blocked',
                       'Spec mismatch with ResourceManager: {} != {}'.format(
                           resourcemanager.nodemanager_spec(), resourcemanager.resourcemanager_spec()))


@when('hadoop.installed', 'resourcemanager.related')
@when_not('resourcemanager.spec.mismatch', 'resourcemanager.ready', 'nodemanager.started')
def waiting(resourcemanager):
    hookenv.status_set('waiting', 'Waiting for ResourceManager')


@when('resourcemanager.ready')
@when_not('nodemanager.started')
def start_nodemanager(resourcemanager):
    hadoop = get_hadoop_base()
    yarn = YARN(hadoop)
    yarn.configure_nodemanager(resourcemanager.host(), resourcemanager.port(), resourcemanager.hs_http(), resourcemanager.hs_ipc())
    #yarn.configure_nodemanager()
    utils.install_ssh_key('ubuntu', resourcemanager.ssh_key())
    utils.update_kv_hosts(resourcemanager.hosts_map())
    utils.manage_etc_hosts()
    yarn.start_nodemanager()<commit_msg>Move spec matching logic to base layer<commit_after>from charms.reactive import when, when_not, set_state, is_state, remove_state
from charms.hadoop import get_hadoop_base
from jujubigdata.handlers import YARN
from jujubigdata import utils
from charmhelpers.core import hookenv


@when('hadoop.installed')
@when_not('resourcemanager.related')
def blocked():
    hookenv.status_set('blocked', 'Waiting for relation to ResourceManager')


@when('hadoop.installed', 'resourcemanager.related')
@when_not('resourcemanager.spec.mismatch', 'resourcemanager.ready', 'nodemanager.started')
def waiting(resourcemanager):
    hookenv.status_set('waiting', 'Waiting for ResourceManager')


@when('resourcemanager.ready')
@when_not('nodemanager.started')
def start_nodemanager(resourcemanager):
    hadoop = get_hadoop_base()
    yarn = YARN(hadoop)
    yarn.configure_nodemanager(resourcemanager.host(), resourcemanager.port(), resourcemanager.hs_http(), resourcemanager.hs_ipc())
    #yarn.configure_nodemanager()
    utils.install_ssh_key('ubuntu', resourcemanager.ssh_key())
    utils.update_kv_hosts(resourcemanager.hosts_map())
    utils.manage_etc_hosts()
    yarn.start_nodemanager()
{'fraction_non_alphanumeric': 0.11619592420450482, 'fraction_numerical': 0.0, 'mean_word_length': 6.363157894736842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6402469', 'n_tokens_mistral': 866, 'n_tokens_neox': 825, 'n_words': 149}