<s> from oslo_log import log as logging <EOL> import sahara . plugins . mapr . domain . configuration_file as bcf <EOL> import sahara . plugins . mapr . domain . node_process as np <EOL> import sahara . plugins . mapr . domain . service as s <EOL> import sahara . plugins . mapr . util . validation_utils as vu <EOL> import sahara . utils . files as files <EOL> LOG = logging . getLogger ( __name__ ) <EOL> HIVE_METASTORE = np . NodeProcess ( <EOL> name = '<STR_LIT>' , <EOL> ui_name = '<STR_LIT>' , <EOL> package = '<STR_LIT>' , <EOL> open_ports = [ <NUM_LIT> ] <EOL> ) <EOL> HIVE_SERVER_2 = np . NodeProcess ( <EOL> name = '<STR_LIT>' , <EOL> ui_name = '<STR_LIT>' , <EOL> package = '<STR_LIT>' , <EOL> open_ports = [ <NUM_LIT> ] <EOL> ) <EOL> class Hive ( s . Service ) : <EOL> def __init__ ( self ) : <EOL> super ( Hive , self ) . __init__ ( ) <EOL> self . _name = '<STR_LIT>' <EOL> self . _ui_name = '<STR_LIT>' <EOL> self . _node_processes = [ HIVE_METASTORE , HIVE_SERVER_2 ] <EOL> self . _validation_rules = [ <EOL> vu . exactly ( <NUM_LIT:1> , HIVE_METASTORE ) , <EOL> vu . exactly ( <NUM_LIT:1> , HIVE_SERVER_2 ) , <EOL> ] <EOL> def get_config_files ( self , cluster_context , configs , instance = None ) : <EOL> hive_default = '<STR_LIT>' <EOL> hive_site = bcf . HadoopXML ( "<STR_LIT>" ) <EOL> hive_site . remote_path = self . conf_dir ( cluster_context ) <EOL> if instance : <EOL> hive_site . fetch ( instance ) <EOL> hive_site . parse ( files . get_file_text ( hive_default ) ) <EOL> hive_site . add_properties ( self . _get_hive_site_props ( cluster_context ) ) <EOL> hue_version = cluster_context . get_chosen_service_version ( '<STR_LIT>' ) <EOL> if self . require_no_sasl ( hue_version ) : <EOL> hive_site . add_property ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return [ hive_site ] <EOL> def require_no_sasl ( self , version ) : <EOL> return version not in [ '<STR_LIT>' ] <EOL> def _get_hive_site_props ( self , context ) : <EOL> from sahara . plugins . mapr . services . mysql import mysql <EOL> zookeepers = context . get_zookeeper_nodes_ip ( ) <EOL> metastore_specs = mysql . MySQL . METASTORE_SPECS <EOL> return { <EOL> '<STR_LIT>' : mysql . MySQL . DRIVER_CLASS , <EOL> '<STR_LIT>' : self . _get_jdbc_uri ( context ) , <EOL> '<STR_LIT>' : metastore_specs . user , <EOL> '<STR_LIT>' : metastore_specs . password , <EOL> '<STR_LIT>' : self . _get_metastore_uri ( context ) , <EOL> '<STR_LIT>' : zookeepers , <EOL> '<STR_LIT>' : zookeepers , <EOL> } <EOL> def _get_jdbc_uri ( self , context ) : <EOL> from sahara . plugins . mapr . services . mysql import mysql <EOL> jdbc_uri = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> jdbc_args = { <EOL> '<STR_LIT>' : mysql . MySQL . get_db_instance ( context ) . internal_ip , <EOL> '<STR_LIT>' : mysql . MySQL . MYSQL_SERVER_PORT , <EOL> '<STR_LIT>' : mysql . MySQL . METASTORE_SPECS . db_name , <EOL> } <EOL> return jdbc_uri % jdbc_args <EOL> def _get_metastore_uri ( self , context ) : <EOL> return '<STR_LIT>' % context . get_instance_ip ( HIVE_METASTORE ) <EOL> def post_start ( self , cluster_context , instances ) : <EOL> import sahara . plugins . mapr . services . maprfs . maprfs as mfs <EOL> create_path = lambda p : '<STR_LIT>' % p <EOL> check_path = '<STR_LIT>' <EOL> cmd = "<STR_LIT>" <EOL> args = { <EOL> '<STR_LIT>' : check_path % '<STR_LIT>' , <EOL> '<STR_LIT>' : create_path ( '<STR_LIT>' ) , <EOL> '<STR_LIT:target>' : create_path ( '<STR_LIT>' ) <EOL> } <EOL> cldb_node = cluster_context . get_instance ( mfs . CLDB ) <EOL> with cldb_node . remote ( ) as r : <EOL> LOG . debug ( "<STR_LIT>" ) <EOL> r . execute_command ( cmd % args , raise_when_error = False ) <EOL> class HiveV013 ( Hive ) : <EOL> def __init__ ( self ) : <EOL> super ( HiveV013 , self ) . __init__ ( ) <EOL> self . _version = '<STR_LIT>' <EOL> self . _dependencies = [ ( '<STR_LIT>' , self . version ) ] <EOL> class HiveV10 ( Hive ) : <EOL> def __init__ ( self ) : <EOL> super ( HiveV10 , self ) . __init__ ( ) <EOL> self . _version = "<STR_LIT:1.0>" <EOL> self . _dependencies = [ ( "<STR_LIT>" , self . version ) ] <EOL> class HiveV12 ( Hive ) : <EOL> def __init__ ( self ) : <EOL> super ( HiveV12 , self ) . __init__ ( ) <EOL> self . _version = "<STR_LIT>" <EOL> self . _dependencies = [ ( "<STR_LIT>" , self . version ) ] </s>
