/**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * 检查搜索节点状态
  * @param string $host
  * @return int
  */
 public function checkNodeStatus($host)
 {
     $url = $host . '/api.php';
     $data = array('route' => "search/status", 'callback_url' => PluginMiniSearchOption::getInstance()->getMiniyunHost() . "info.htm");
     $http = new HttpClient();
     $http->post($url, $data);
     $result = $http->get_body();
     $result = @json_decode($result, true);
     if ($result["status"] == "1") {
         return 1;
     }
     return -1;
 }
 /**
  * 为searchFile对象生成索引编制对象
  * @param string $nodeIds
  * @param string $signature
  */
 public function createTask($nodeIds, $signature)
 {
     $miniHost = PluginMiniSearchOption::getInstance()->getMiniyunHost();
     $siteId = MiniSiteUtils::getSiteID();
     $ids = explode(",", $nodeIds);
     //为索引服务器生成索引记录记录
     //剔除已生成的索引记录
     $nodes = PluginMiniSearchNode::getInstance()->getValidNodeList();
     $needCreateTaskNodeIds = array();
     foreach ($nodes as $node) {
         $existed = false;
         $nodeId = $node["id"];
         foreach ($ids as $id) {
             if ($id == $nodeId) {
                 $existed = true;
             }
         }
         if (!$existed) {
             array_push($needCreateTaskNodeIds, $node["id"]);
         }
     }
     foreach ($needCreateTaskNodeIds as $nodeId) {
         $task = SearchBuildTask::model()->find("file_signature=:file_signature and node_id=:node_id", array("file_signature" => $signature, "node_id" => $nodeId));
         if (!isset($task)) {
             $task = new SearchBuildTask();
             $task->file_signature = $signature;
             $task->node_id = $nodeId;
             $task->status = 0;
             $task->save();
         }
         //向迷你搜索服务器发送编制索引任务
         $this->buildTask($miniHost, $siteId, $task);
     }
 }