Best Python code snippet using autotest_python
druid_node.py
Source:druid_node.py  
...44        import params45        env.set_params(params)46        install_druid()47        self.configure(env, upgrade_type=upgrade_type)48        daemon_cmd = get_daemon_cmd(params, self.nodeType, "start")49        # Verify Database connection on Druid start50        if params.metadata_storage_type == 'mysql':51            if not params.jdbc_driver_jar or not os.path.isfile(52                    params.connector_download_dir + os.path.sep +53                    params.jdbc_driver_jar):54                path_to_jdbc = params.connector_download_dir + os.path.sep + "*"55                error_message = "Error! Sorry, but we can't find jdbc driver for mysql.So, db connection check can fail." + \56                                "Please run 'ambari-server setup --jdbc-db=mysql --jdbc-driver={path_to_jdbc} on server host.'"57                Logger.error(error_message)58            else:59                path_to_jdbc = params.connector_download_dir + os.path.sep + params.jdbc_driver_jar60            db_connection_check_command = format(61                "{params.java8_home}/bin/java -cp {params.check_db_connection_jar}:{path_to_jdbc} org.apache.ambari.server.DBConnectionVerification '{params.metadata_storage_url}' {params.metadata_storage_user} {params.metadata_storage_password!p} com.mysql.jdbc.Driver"62            )63        else:64            db_connection_check_command = None65        if db_connection_check_command:66            sudo.chmod(params.check_db_connection_jar, 0755)67            Execute(68                db_connection_check_command,69                tries=5,70                try_sleep=10,71                user=params.druid_user)72        pid_file = getPid(params, self.nodeType)73        process_id_exists_command = as_sudo([74            "test", "-f", pid_file75        ]) + " && " + as_sudo(["pgrep", "-F", pid_file])76        try:77            Execute(78                daemon_cmd,79                user=params.druid_user,80                not_if=process_id_exists_command,81            )82        except:83            show_logs(params.druid_log_dir, params.druid_user)84            raise85    def stop(self, env, upgrade_type=None):86        import params87        env.set_params(params)88        pid_file = getPid(params, self.nodeType)89        process_id_exists_command = as_sudo([90            "test", "-f", pid_file91        ]) + " && " + as_sudo(["pgrep", "-F", pid_file])92        daemon_cmd = get_daemon_cmd(params, self.nodeType, "stop")93        try:94            Execute(95                daemon_cmd,96                user=params.druid_user,97                only_if=process_id_exists_command,98            )99        except:100            show_logs(params.druid_log_dir, params.druid_user)101            raise102    def get_pid_files(self):103        import status_params104        return [getPid(status_params, self.nodeType)]105    def status(self, env):106        import status_params...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
