def change_reverse(_c): logger.debug("in change reverse") sql1="update master_relation set canshift=0 where cluster_name_qq='%s'" %(_c) logger.debug(sql1) dbtools.mysave(sql1,"dbproxy") sql="update master_relation set canreverse=0 where cluster_name_qq='%s'" %(_c) logger.debug(sql) dbtools.mysave(sql,"dbproxy")
def modify_dbproxyconf(*tup1): logger.debug("in modify_dbproxyconf") tup=tup1[0] print tup if len(tup)==8: cluster_name_qq=tup[0] tablet_name_qq=tup[1] master_ip_qq=tup[2] master_port_qq=tup[3] cluster_name_gz=tup[4] tablet_name_gz=tup[5] master_ip_gz=tup[6] master_port_gz=tup[7] #update old cluster is_master=1 weight=1 is_online=1 sql="update db_account set is_online=0 where tablet='%s' and ip='%s' and port=%s" %(tablet_name_qq,master_ip_qq,master_port_qq) logger.debug(sql) dbtools.mysave(sql,"dbproxy") sql1="update db_account set is_online=0 where tablet='%s' and ip='%s' and port=%s" %(tablet_name_gz,master_ip_qq,master_port_qq) logger.debug(sql1) dbtools.mysave(sql1,"dbproxy") sql2="insert into db_account (tablet, ip, port, is_master, is_online, weight) \ values ('%s','%s',%s,%s,%s,%s) on duplicate key update is_master = 1, is_online = 1, weight = 1" %(tablet_name_qq,master_ip_gz,master_port_gz,is_master,is_online,weight) logger.debug(sql2) dbtools.mysave(sql2,"dbproxy") sql3="insert into db_account (tablet, ip, port, is_master, is_online, weight) \ values ('%s','%s',%s,%s,%s,%s) on duplicate key update is_master = 1, is_online = 1, weight = 1" %(tablet_name_gz,master_ip_gz,master_port_gz,is_master,is_online,weight) logger.debug(sql3) dbtools.mysave(sql3,"dbproxy")
def reload_dbproxy(_c,_master,_proxy): ISOTIMEFORMAT='%Y-%m-%d %X' createtime=time.strftime(ISOTIMEFORMAT,time.localtime()) sql="insert into mhaqueue(master,cluster,proxy,status,createtime) values('%s','%s','%s',%s,'%s')" %(_master,_c,_proxy,0,createtime) dbtools.mysave(sql,"dbproxy") logger.debug(sql)