예제 #1
0
 public static function modifyConfAfterParamValidation($user, $path, $idc, $main_buss_id, $sub_buss_id, $desc, $node_val)
 {
     // 1.check whether node already exist
     $cur_node = NodeServ::getNodeByNodeWhole($path, $main_buss_id);
     if ($cur_node === FALSE) {
         //$res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_NODE_NOT_EXIST);
         QconfMgrLog::err(__FILE__, __LINE__, "node:{$path} didn't exist in database");
         $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_NODE_NOT_EXIST);
         return $res;
     }
     // 2.modify on zookeeper
     $idc_failed = "";
     $idc_list = preg_split("/[,]+/", $idc);
     foreach ($idc_list as $idc_each) {
         $idc_host = ZkConf::getZkHost($idc_each);
         $zk_web = new QconfZkWebBase(Log::INFO);
         $zk_web->connect($idc_host);
         $retry_time = 0;
         while ($retry_time++ < 3 && $zk_web->set_conf(PathUtil::getQconfPath($path), $node_val) === -1) {
             QconfMgrLog::err(__FILE__, __LINE__, "fail to modify conf into zookeeper! retry time {$retry_time}");
         }
         if ($retry_time >= 3) {
             QconfMgrLog::err(__FILE__, __LINE__, "zookeeper failed when modify node value for :{$path}, on idc: {$idc_each}");
             $idc_failed = $idc_each;
         }
     }
     if ($idc_failed != "") {
         $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_ZOOKEEPER_FAIL);
         $res["data"] .= $idc_failed;
         OpServ::insert(InfoDescUtil::OP_TYPE_MOD, $path, $idc, InfoDescUtil::OP_STATUS_ZOO_FAILED, $main_buss_id, $sub_buss_id, $user, "");
         return $res;
     }
     // 3.modify on mysql
     if ($desc != NULL && $desc != "") {
         $node_id = $cur_node["node_id"];
         $ret = NodeServ::modNote($node_id, $desc);
         if ($ret == FALSE) {
             QconfMgrLog::err(__FILE__, __LINE__, "failed to modify note for :{$path}");
         }
     }
     OpServ::insert(InfoDescUtil::OP_TYPE_MOD, $path, $idc, InfoDescUtil::OP_STATUS_SUCCESS, $main_buss_id, $sub_buss_id, $user, $node_val);
     $res = array("errno" => "0", "errmsg" => "", "data" => "modify node({$path}) value to be {$node_val} success!");
     return $res;
 }
예제 #2
0
 public function modNodeValue($node_id, $idc, $node_whole, $main_buss_id, $sub_buss_id, $node_val, $note, $op_user)
 {
     //echo "$idc, $node_whole, $main_buss_id, $sub_buss_id, $node_val, $note, $op_user". PHP_EOL;
     $idc_list = preg_split("/[,]+/", $idc);
     // split by ,
     $idc_host = ZkConf::getZkHost($idc_list[0]);
     // 1. idc zookeeper server not exist
     if ($idc_host === NULL) {
         return InfoDescUtil::ERR_IDC_NOT_EXIST;
     }
     $zk_web = new QconfZkWebBase(Log::INFO);
     $zk_web->connect($idc_host);
     $set_ret = self::setConfWithLink($zk_web, $node_whole, $idc_list[0], $node_val);
     // 3. modify the zookeeper failed
     if ($set_ret === -1) {
         OpServ::insert(InfoDescUtil::OP_TYPE_MOD, $node_whole, $idc, InfoDescUtil::OP_STATUS_ZOO_FAILED, $main_buss_id, $sub_buss_id, $op_user, "");
         return $set_ret;
     }
     $ret = NodeServ::modNote($node_id, $note);
     // 4. modify the database failed
     if ($ret === FALSE) {
         //    echo "modify note : $ret<br>";
         OpServ::insert(InfoDescUtil::OP_TYPE_MOD, $node_whole, $idc, InfoDescUtil::OP_STATUS_MYSQL_FAILED, $main_buss_id, $sub_buss_id, $op_user, "");
         return InfoDescUtil::ERR_MYSQL_FAIL;
     }
     OpServ::insert(InfoDescUtil::OP_TYPE_MOD, $node_whole, $idc, InfoDescUtil::OP_STATUS_SUCCESS, $main_buss_id, $sub_buss_id, $op_user, $node_val);
     return 0;
 }