Exemple #1
0
 public function getRecode($strUname, $strUrlKeyWord, $intOffset, $intLimit)
 {
     $field = array("uname", "url_host", "app_name", "action_info", "call_type", "param", "url", "op_time");
     $conds = array("uname = " => $strUname, "url like" => "%{$strUrlKeyWord}%");
     $appends = array("order by op_time desc limit {$intOffset}, {$intLimit}");
     $ret = $this->proxy->select(self::TABLE_TESTMAN_RECODE, $field, $conds, $option, $appends);
     if (false === $ret) {
         Bd_Log::fatal("Mysql query failed in " . __FUNCTION__);
         return Navilib_Utils::result(Navilib_CommonError::MYSQL_QUERY_FAILED);
     }
     return Navilib_Utils::result(Navilib_CommonError::SUCCESS, $ret);
 }
Exemple #2
0
 /**
  * @brief  致命错误处理
  * @param $msg   错误消息    
  */
 private static function _fatalErr($msg)
 {
     Bd_Log::fatal($msg);
     throw new Exception($msg);
 }
     Bd_Log::trace("[UPDATE] pipelet_id:{$pipelet} partition:{$event_day}{$event_hour}{$event_minute} upload_end:" . date("h:m:s", time()) . " {$ret}");
     //上传成功
     if ($ret == 0) {
         //对上传成功文件打上done标记
         $strCmdMd5 = "cd {$dataPath} && touch {$key}.done";
         exec($strCmdMd5);
         //更新该pipelet状态
         $db = new mysqli($arrAppConf['mysql_host'], $arrAppConf['mysql_user'], $arrAppConf['mysql_pwd'], $arrAppConf['mysql_db'], $arrAppConf['mysql_port']);
         $sql = sprintf("INSERT INTO %s_%s VALUES(%s%s%s, %s) ON DUPLICATE KEY UPDATE pipelet_id=pipelet_id | %d", $arrAppConf['mysql_table'], $app, $event_day, $event_hour, $event_minute, 1 << $pipelet, 1 << $pipelet);
         $db->query($sql);
         //检查所有pipelet上传完成状态
         $sql = sprintf("SELECT pipelet_id FROM %s_%s WHERE partition=%s%s%s FOR UPDATE", $arrAppConf['mysql_table'], $app, $event_day, $event_hour, $event_minute);
         $ret = $db->query($sql);
         if ($ret === false) {
             echo "query faild!\n";
             Bd_Log::fatal("[UPDATE] pipelet_id:{$pipelet} partition:{$event_day}{$event_hour}{$event_minute} query_failed");
         }
         $tmp = $ret->fetch_row();
         $pipeletFull = intval($arrAppConf['pipelet_full']);
         Bd_Log::trace("[UPDATE] pipelet_id:{$pipelet} partition:{$event_day}{$event_hour}{$event_minute} [{$tmp[0]}/{$pipeletFull}]");
         if ($tmp[0] == $pipeletFull) {
             //创建新PARTITION
             $hql = "ALTER TABLE iknowetl_{$app} ADD PARTITION (event_day='{$event_day}', event_hour='{$event_hour}', event_minute='{$event_minute}') LOCATION '{$hdfsPath}'";
             $strCmdPartition = "source ~/.bashrc && sh hive_tool.sh hql \"{$hql}\"";
             Bd_Log::trace("[UPDATE] pipelet_id:{$pipelet} partition:{$event_day}{$event_hour}{$event_minute} add_partition_start:{$strCmdPartition}");
             exec($strCmdPartition, $out, $ret);
             Bd_Log::trace("[UPDATE] pipelet_id:{$pipelet} partition:{$event_day}{$event_hour}{$event_minute} add_partition_res:{$ret}");
         }
     }
 }
 sleep($arrAppConf['update_sleep_s']);