<s> """<STR_LIT>""" <EOL> import functools <EOL> import os <EOL> import posixpath <EOL> from perfkitbenchmarker import data <EOL> from perfkitbenchmarker import vm_util <EOL> from perfkitbenchmarker . linux_packages import hadoop <EOL> HBASE_VERSION = '<STR_LIT>' <EOL> HBASE_URL = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( HBASE_VERSION ) <EOL> DATA_FILES = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> HBASE_DIR = posixpath . join ( vm_util . VM_TMP_DIR , '<STR_LIT>' ) <EOL> HBASE_BIN = posixpath . join ( HBASE_DIR , '<STR_LIT>' ) <EOL> HBASE_CONF_DIR = posixpath . join ( HBASE_DIR , '<STR_LIT>' ) <EOL> def CheckPrerequisites ( ) : <EOL> """<STR_LIT>""" <EOL> for resource in DATA_FILES : <EOL> data . ResourcePath ( resource ) <EOL> def _Install ( vm ) : <EOL> vm . Install ( '<STR_LIT>' ) <EOL> vm . Install ( '<STR_LIT>' ) <EOL> vm . RemoteCommand ( ( '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> HBASE_DIR , HBASE_URL ) ) <EOL> def YumInstall ( vm ) : <EOL> """<STR_LIT>""" <EOL> _Install ( vm ) <EOL> def AptInstall ( vm ) : <EOL> """<STR_LIT>""" <EOL> _Install ( vm ) <EOL> def _RenderConfig ( vm , master_ip , zk_ips , regionserver_ips ) : <EOL> memory_mb = vm . total_memory_kb // <NUM_LIT> <EOL> hbase_memory_mb = max ( min ( memory_mb // <NUM_LIT:2> , <NUM_LIT> ) , <EOL> min ( memory_mb // <NUM_LIT:4> , <NUM_LIT> ) ) <EOL> context = { <EOL> '<STR_LIT>' : master_ip , <EOL> '<STR_LIT>' : regionserver_ips , <EOL> '<STR_LIT>' : zk_ips , <EOL> '<STR_LIT>' : hadoop . HADOOP_PRIVATE_KEY , <EOL> '<STR_LIT>' : hbase_memory_mb , <EOL> '<STR_LIT>' : vm . GetScratchDir ( ) , <EOL> } <EOL> for file_name in DATA_FILES : <EOL> file_path = data . ResourcePath ( file_name ) <EOL> remote_path = posixpath . join ( HBASE_CONF_DIR , <EOL> os . path . basename ( file_name ) ) <EOL> if file_name . endswith ( '<STR_LIT>' ) : <EOL> vm . RenderTemplate ( file_path , os . path . splitext ( remote_path ) [ <NUM_LIT:0> ] , context ) <EOL> else : <EOL> vm . RemoteCopy ( file_path , remote_path ) <EOL> def ConfigureAndStart ( master , regionservers , zk_nodes ) : <EOL> """<STR_LIT>""" <EOL> vms = [ master ] + regionservers <EOL> def LinkNativeLibraries ( vm ) : <EOL> vm . RemoteCommand ( ( '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> HBASE_DIR , <EOL> posixpath . join ( hadoop . HADOOP_DIR , '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> vm_util . RunThreaded ( LinkNativeLibraries , vms ) <EOL> fn = functools . partial ( _RenderConfig , master_ip = master . internal_ip , <EOL> zk_ips = [ vm . internal_ip for vm in zk_nodes ] , <EOL> regionserver_ips = [ regionserver . internal_ip <EOL> for regionserver in regionservers ] ) <EOL> vm_util . RunThreaded ( fn , vms ) <EOL> master . RemoteCommand ( '<STR_LIT>' . format ( <EOL> posixpath . join ( hadoop . HADOOP_BIN , '<STR_LIT>' ) ) ) <EOL> master . RemoteCommand ( posixpath . join ( HBASE_BIN , '<STR_LIT>' ) ) <EOL> def Stop ( master ) : <EOL> """<STR_LIT>""" <EOL> master . RemoteCommand ( posixpath . join ( HBASE_BIN , '<STR_LIT>' ) ) </s>
