Пример #1
0
 function ShowStepNoError()
 {
     $wizard =& $this->GetWizard();
     $strNextStep = "";
     if (count($this->GetErrors()) == 0) {
         $arNode = CClusterDBNode::GetByID($wizard->GetVar('node_id'));
         if (is_array($arNode)) {
             $arModules = array();
             $events = GetModuleEvents("cluster", "OnGetTableList");
             while ($arEvent = $events->Fetch()) {
                 $ar = ExecuteModuleEventEx($arEvent);
                 if (is_array($ar)) {
                     $cur_node_id = intval(COption::GetOptionString($ar["MODULE"]->MODULE_ID, 'dbnode_id'));
                     if ($cur_node_id < 1) {
                         $cur_node_id = 1;
                     }
                     $cur_node_id = CClusterDBNode::GetByID($cur_node_id);
                     $arModules[$ar["MODULE"]->MODULE_ID] = $ar["MODULE"]->MODULE_NAME . " (" . $cur_node_id["NAME"] . ")";
                 }
             }
             $arNodes = array();
             $curNodeName = "";
             $rsDBNodes = CClusterDBNode::GetList(array("ID" => "ASC"), array("=ACTIVE" => "Y", "=ROLE_ID" => array("MODULE", "MAIN"), "=STATUS" => array("READY", "ONLINE")), array("ID", "NAME"));
             while ($arDBNode = $rsDBNodes->Fetch()) {
                 if ($arDBNode["ID"] != $wizard->GetVar('node_id')) {
                     $arNodes[$arDBNode["ID"]] = $arDBNode["NAME"];
                 } else {
                     $curNodeName = $arDBNode["NAME"];
                 }
             }
             $arOtherModules = $arModules;
             $arNodeModules = CClusterDBNode::GetModules($wizard->GetVar('node_id'));
             foreach ($arNodeModules as $key => $value) {
                 $arNodeModules[$key] = $arModules[$key];
                 unset($arOtherModules[$key]);
             }
             if ($arNode["STATUS"] == "READY") {
                 $this->content .= GetMessage("CLUWIZ_STEP1_CONTENT1", array("#database#" => $curNodeName, "#module_select_list#" => $this->ShowSelectField("module", $arOtherModules)));
                 $this->content .= $this->ShowHiddenField("to_node_id", $wizard->GetVar('node_id'));
                 $strNextStep = "step2";
             } elseif ($arNode["STATUS"] == "ONLINE") {
                 $this->content .= GetMessage("CLUWIZ_STEP1_CONTENT2", array("#database_select_list#" => $this->ShowSelectField("to_node_id", $arNodes)));
                 $this->content .= $this->ShowHiddenField("from_node_id", $wizard->GetVar('node_id'));
                 $strNextStep = "step3";
             }
         }
     }
     if ($strNextStep) {
         $this->SetNextStep("step2");
     }
 }
Пример #2
0
 function Delete($ID)
 {
     global $DB, $APPLICATION;
     $aMsg = array();
     $ID = intval($ID);
     $rsWebNodes = CClusterWebnode::GetList(array(), array("=GROUP_ID" => $ID));
     if ($rsWebNodes->Fetch()) {
         $aMsg[] = array("text" => GetMessage("CLU_GROUP_HAS_WEBNODE"));
     }
     $rsDBNodes = CClusterDBNode::GetList(array(), array("=GROUP_ID" => $group_id));
     if ($rsWebNodes->Fetch()) {
         $aMsg[] = array("text" => GetMessage("CLU_GROUP_HAS_DBNODE"));
     }
     /*TODO: memcache check*/
     if (empty($aMsg)) {
         $res = $DB->Query("DELETE FROM b_cluster_group WHERE ID = " . $ID, false, '', array('fixed_connection' => true));
     } else {
         $e = new CAdminException($aMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     return $res;
 }
Пример #3
0
 function InitStep()
 {
     global $DB;
     $wizard = $this->GetWizard();
     if (!CModule::IncludeModule('cluster')) {
         $this->SetError(GetMessage('CLUWIZ_NO_MODULE_ERROR'));
     } elseif ($DB->type != "MYSQL") {
         $this->SetError(GetMessage('CLUWIZ_DATABASE_NOT_SUPPORTED'));
     } else {
         $arGroup = CClusterGroup::GetArrayByID(intval($wizard->GetVar("group_id")));
         if (!$arGroup) {
             $this->SetError(GetMessage('CLUWIZ_NO_GROUP_ERROR'));
         } else {
             $cData = new CClusterDBNode();
             $rsData = $cData->GetList(array(), array("=ROLE_ID" => array("MAIN", "MASTER"), "=GROUP_ID" => $arGroup["ID"], "=STATUS" => "ONLINE"));
             $this->arMaster = $rsData->Fetch();
             if (!$this->arMaster) {
                 $this->SetError(GetMessage('CLUWIZ_NO_MASTER_ERROR'));
             }
         }
     }
     $wizard->SetDefaultVar("master_host", '');
     $wizard->SetDefaultVar("master_port", '');
     if ($this->arMaster) {
         if ($this->arMaster["ID"] == 1) {
             if (preg_match("/^(.+):(\\d+)\$/", $GLOBALS["DB"]->DBHost, $match)) {
                 $wizard->SetDefaultVar("master_host", $match[1]);
                 $wizard->SetDefaultVar("master_port", $match[2]);
             }
         } else {
             if (preg_match("/^(.+):(\\d+)\$/", $this->arMaster["DB_HOST"], $match)) {
                 $wizard->SetDefaultVar("master_host", $match[1]);
                 $wizard->SetDefaultVar("master_port", $match[2]);
             }
         }
     }
 }
Пример #4
0
 function InitStep()
 {
     global $DB;
     $wizard =& $this->GetWizard();
     $node_id = intval($wizard->GetVar('node_id'));
     if (!CModule::IncludeModule('cluster')) {
         $this->SetError(GetMessage('CLUWIZ_NO_MODULE_ERROR'));
     } elseif ($DB->type != "MYSQL") {
         $this->SetError(GetMessage('CLUWIZ_DATABASE_NOT_SUPPORTED'));
     } elseif ($node_id <= 1) {
         $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
     } else {
         $this->arNode = CClusterDBNode::GetByID($node_id);
         if (!is_array($this->arNode)) {
             $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
         } else {
             // $arNode["ROLE_ID"] == "SLAVE"
             // $arNode["STATUS"] == "READY"
             $this->nodeDB = CDatabase::GetDBNodeConnection($this->arNode["ID"], true, false);
             if (!is_object($this->nodeDB)) {
                 $this->SetError(GetMessage('CLUWIZ_NO_CONN_ERROR'));
             } else {
                 $arGroup = CClusterGroup::GetArrayByID(intval($wizard->GetVar("group_id")));
                 if (!$arGroup) {
                     $this->SetError(GetMessage('CLUWIZ_NO_GROUP_ERROR'));
                 } else {
                     $cData = new CClusterDBNode();
                     $rsData = $cData->GetList(array(), array("=ROLE_ID" => array("MAIN", "MASTER"), "=GROUP_ID" => $arGroup["ID"], "=STATUS" => "ONLINE"));
                     $this->arMaster = $rsData->Fetch();
                     if (!$this->arMaster) {
                         $this->SetError(GetMessage('CLUWIZ_NO_MASTER_ERROR'));
                     }
                 }
             }
         }
     }
 }
Пример #5
0
 function GetStatus($node_id, $bSlaveStatus = true, $bGlobalStatus = true, $bVariables = true)
 {
     global $DB;
     $arNode = CClusterDBNode::GetByID($node_id);
     if (!is_array($arNode)) {
         return false;
     }
     if ($node_id == 1) {
         $nodeDB = $DB;
     } else {
         ob_start();
         $nodeDB = CDatabase::GetDBNodeConnection($node_id, true, false);
         $error = ob_get_contents();
         ob_end_clean();
     }
     if (!is_object($nodeDB)) {
         return false;
     }
     $arStatus = array('server_id' => null);
     if ($bVariables) {
         $rs = $nodeDB->Query("show variables like 'server_id'", false, "", array("fixed_connection" => true));
         if ($ar = $rs->Fetch()) {
             $arStatus['server_id'] = $ar["Value"];
         }
     }
     $rsSlaves = CClusterDBNode::GetList(array(), array("=MASTER_ID" => $node_id));
     if ($rsSlaves->Fetch()) {
         $arStatus = array_merge($arStatus, array('File' => null, 'Position' => null));
         if ($bSlaveStatus) {
             $rs = $nodeDB->Query("SHOW MASTER STATUS", true, "", array("fixed_connection" => true));
             if (!$rs) {
                 return GetMessage("CLU_NO_PRIVILEGES", array("#sql#" => "GRANT REPLICATION CLIENT on *.* to '" . $nodeDB->DBLogin . "'@'%';"));
             }
             $ar = $rs->Fetch();
             if (is_array($ar)) {
                 foreach ($ar as $key => $value) {
                     if ($key == 'Last_Error') {
                         $key = 'Last_SQL_Error';
                     }
                     if (array_key_exists($key, $arStatus)) {
                         $arStatus[$key] = $value;
                     }
                 }
             }
         }
     }
     if (strlen($arNode["MASTER_ID"])) {
         $arStatus = array_merge($arStatus, array('Slave_IO_State' => null, 'Slave_IO_Running' => null, 'Read_Master_Log_Pos' => null, 'Slave_SQL_Running' => null, 'Exec_Master_Log_Pos' => null, 'Seconds_Behind_Master' => null, 'Last_IO_Error' => null, 'Last_SQL_Error' => null, 'Com_select' => null));
         if ($bSlaveStatus) {
             $rs = $nodeDB->Query("SHOW SLAVE STATUS", true, "", array("fixed_connection" => true));
             if (!$rs) {
                 return GetMessage("CLU_NO_PRIVILEGES", array("#sql#" => "GRANT REPLICATION CLIENT on *.* to '" . $nodeDB->DBLogin . "'@'%';"));
             }
             $ar = $rs->Fetch();
             if (is_array($ar)) {
                 foreach ($ar as $key => $value) {
                     if ($key == 'Last_Error') {
                         $key = 'Last_SQL_Error';
                     }
                     if (array_key_exists($key, $arStatus)) {
                         $arStatus[$key] = $value;
                     }
                 }
             }
         }
         if ($bGlobalStatus) {
             $rs = $nodeDB->Query("show global status where Variable_name in ('Com_select', 'Com_do')", true, "", array("fixed_connection" => true));
             if (is_object($rs)) {
                 while ($ar = $rs->Fetch()) {
                     if ($ar['Variable_name'] == 'Com_do') {
                         $arStatus['Com_select'] -= $ar['Value'] * 2;
                     } else {
                         $arStatus['Com_select'] += $ar['Value'];
                     }
                 }
             } else {
                 $rs = $nodeDB->Query("show status like 'Com_select'", false, "", array("fixed_connection" => true));
                 $ar = $rs->Fetch();
                 if ($ar) {
                     $arStatus['Com_select'] += $ar['Value'];
                 }
                 $rs = $nodeDB->Query("show status like 'Com_do'", false, "", array("fixed_connection" => true));
                 $ar = $rs->Fetch();
                 if ($ar) {
                     $arStatus['Com_select'] -= $ar['Value'] * 2;
                 }
             }
         }
     }
     return $arStatus;
 }
Пример #6
0
 /**
  * Return information about DB from cluster module
  *
  * @return array
  */
 protected static function getDBHostsFromCluster()
 {
     $result = array();
     if (CModule::IncludeModule("cluster")) {
         $clusterDBs = CClusterDBNode::GetList(array("ID" => "ASC"), array("=ROLE_ID" => array("SLAVE", "MASTER")), array("DB_HOST"));
         while ($clusterDBServer = $clusterDBs->Fetch()) {
             $result[] = array("host" => $clusterDBServer["DB_HOST"]);
         }
     }
     return $result;
 }
        } else {
            $bVarsFromForm = true;
        }
    }
}
ClearVars("str_");
$str_ACTIVE = "Y";
$str_SORT = "10";
$str_NAME = "";
$str_DESCRIPTION = "";
$str_DB_HOST = "";
$str_DB_NAME = "";
$str_DB_LOGIN = "";
$str_DB_PASSWORD = "";
if ($ID > 0) {
    $rs = CClusterDBNode::GetList(array(), array("=ID" => $ID), array());
    if (!$rs->ExtractFields("str_")) {
        $ID = 0;
    }
}
if ($bVarsFromForm) {
    $DB->InitTableVarsForEdit("b_cluster_dbnode", "", "str_");
}
$APPLICATION->SetTitle($ID > 0 ? GetMessage("CLU_DBNODE_EDIT_EDIT_TITLE") : GetMessage("CLU_DBNODE_EDIT_ADD_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("CLU_DBNODE_EDIT_MENU_LIST"), "TITLE" => GetMessage("CLU_DBNODE_EDIT_MENU_LIST_TITLE"), "LINK" => "cluster_dbnode_list.php?lang=" . LANGUAGE_ID . '&group_id=' . $group_id, "ICON" => "btn_list"));
if ($ID > 0) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("CLU_DBNODE_EDIT_MENU_ADD"), "TITLE" => GetMessage("CLU_DBNODE_EDIT_MENU_ADD_TITLE"), "LINK" => "cluster_dbnode_edit.php?lang=" . LANGUAGE_ID . '&group_id=' . $group_id, "ICON" => "btn_new");
    if ($str_STATUS != "ONLINE") {
        $aMenu[] = array("TEXT" => GetMessage("CLU_DBNODE_EDIT_MENU_DELETE"), "TITLE" => GetMessage("CLU_DBNODE_EDIT_MENU_DELETE_TITLE"), "LINK" => "javascript:jsDelete('editform', '" . GetMessage("CLU_DBNODE_EDIT_MENU_DELETE_CONF") . "')", "ICON" => "btn_delete");
Пример #8
0
 public static function GetListForModuleInstall()
 {
     return CClusterDBNode::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("=ACTIVE" => "Y", "=ROLE_ID" => "MODULE", "=STATUS" => "READY"), array("ID", "NAME"));
 }
Пример #9
0
/** @global CDatabase $DB */
/** @global CUser $USER */
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/perfmon/include.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/perfmon/prolog.php";
IncludeModuleLangFile(__FILE__);
$RIGHT = $APPLICATION->GetGroupRight("perfmon");
if ($RIGHT == "D") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$bCluster = CModule::IncludeModule('cluster');
$node_id = 0;
$statDB = $DB;
$queryOptions = array("fixed_connection" => true);
$arClusterNodes = array();
if ($bCluster) {
    $rsNodes = CClusterDBNode::GetList();
    while ($node = $rsNodes->fetch()) {
        $arClusterNodes[$node["ID"]] = htmlspecialcharsex($node["NAME"]);
    }
    if (!empty($arClusterNodes)) {
        $node_id = intval($_REQUEST["node_id"]);
        if ($node_id > 1) {
            $statDB = $DB->GetDBNodeConnection($node_id);
            $queryOptions = array();
        } else {
            $node_id = 1;
        }
    }
}
$message = null;
$data = array();
Пример #10
0
 public function SlaveNodeForMaster($nodeDB)
 {
     global $DB;
     $result = array();
     $arMasters = array();
     $cData = new CClusterDBNode();
     $rsData = $cData->GetList(array("ID" => "ASC"), array("=ROLE_ID" => array("MAIN", "MASTER")));
     while ($arData = $rsData->Fetch()) {
         $arMasters[$arData["ID"]] = $arData;
     }
     $arMasters["v99"] = array();
     //virtual connection must be alredy setup
     foreach ($arMasters as $node_id => $arNode) {
         if ($node_id == 1) {
             $nodeDB = $DB;
         } else {
             $nodeDB = CDatabase::GetDBNodeConnection($node_id, true);
         }
         $arMasters[$node_id]["DB"] = $nodeDB;
     }
     $auto_increment_increment = count($arMasters);
     $bIncIsOK = true;
     foreach ($arMasters as $node_id => $arNode) {
         $inc = $this->GetServerVariable($arNode["DB"], "auto_increment_increment");
         if ($inc != $auto_increment_increment) {
             $bIncIsOK = false;
             if ($node_id == "v99") {
                 $result[$node_id . "_auto_increment_increment"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_INCREMENT_NODE_ERR_MSG", array("#value#" => $auto_increment_increment, "#current#" => $inc)), "WIZ_REC" => GetMessage("CLU_AUTO_INCREMENT_INCREMENT_WIZREC", array("#value#" => $auto_increment_increment)));
             } else {
                 $result[$node_id . "_auto_increment_increment"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_INCREMENT_ERR_MSG", array("#node_id#" => $node_id, "#value#" => $auto_increment_increment, "#current#" => $inc)), "WIZ_REC" => GetMessage("CLU_AUTO_INCREMENT_INCREMENT_WIZREC", array("#value#" => $auto_increment_increment)));
             }
         }
     }
     if ($bIncIsOK) {
         $result["_auto_increment_increment"] = array("IS_OK" => CClusterDBNodeCheck::OK, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_INCREMENT_OK_MSG", array("#value#" => $auto_increment_increment)), "WIZ_REC" => "");
     }
     $auto_increment_offset = array();
     $bIncIsOK = true;
     foreach ($arMasters as $node_id => $arNode) {
         $offset = $this->GetServerVariable($arNode["DB"], "auto_increment_offset");
         $mod = $offset % $auto_increment_increment;
         if (array_key_exists($mod, $auto_increment_offset)) {
             $bIncIsOK = false;
             if ($node_id == "v99") {
                 $result[$node_id . "_auto_increment_offset"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_OFFSET_NODE_ERR_MSG", array("#current#" => $offset)), "WIZ_REC" => GetMessage("CLU_AUTO_INCREMENT_OFFSET_WIZREC", array("#current#" => $offset)));
             } else {
                 $result[$node_id . "_auto_increment_offset"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_OFFSET_ERR_MSG", array("#node_id#" => $node_id, "#current#" => $offset)), "WIZ_REC" => GetMessage("CLU_AUTO_INCREMENT_OFFSET_WIZREC", array("#current#" => $offset)));
             }
         } else {
             $auto_increment_offset[$mod] = $node_id;
         }
     }
     if ($bIncIsOK) {
         $result["_auto_increment_offset"] = array("IS_OK" => CClusterDBNodeCheck::OK, "MESSAGE" => GetMessage("CLU_AUTO_INCREMENT_OFFSET_OK_MSG", array("#value#" => $auto_increment_increment)), "WIZ_REC" => "");
     }
     $bRelayIsOK = true;
     foreach ($arMasters as $node_id => $arNode) {
         $relay_log = $this->GetServerVariable($arNode["DB"], "relay_log");
         if (strlen($relay_log) <= 0) {
             $bIncIsOK = false;
             $result[$node_id . "_relay_log"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_RELAY_LOG_ERR_MSG", array("#node_id#" => $node_id, "#relay-log#" => $relay_log)), "WIZ_REC" => GetMessage("CLU_RELAY_LOG_WIZREC"));
         }
     }
     if ($bRelayIsOK) {
         $result["_relay_log"] = array("IS_OK" => CClusterDBNodeCheck::OK, "MESSAGE" => GetMessage("CLU_RELAY_LOG_OK_MSG", array("#value#" => $auto_increment_increment)), "WIZ_REC" => "");
     }
     $log_bin = $this->GetServerVariable($nodeDB, "log_bin");
     $is_ok = $log_bin === "ON";
     $result["log_bin"] = array("IS_OK" => $is_ok ? CClusterDBNodeCheck::OK : CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_LOG_BIN_NODE_MSG", array("#log-bin#" => $log_bin)), "WIZ_REC" => GetMessage("CLU_LOG_BIN_WIZREC"));
     $skip_networking = $this->GetServerVariable($nodeDB, "skip_networking");
     $is_ok = $skip_networking === "OFF";
     $result["skip_networking"] = array("IS_OK" => $is_ok ? CClusterDBNodeCheck::OK : CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_SKIP_NETWORKING_NODE_MSG", array("#skip-networking#" => $skip_networking)), "WIZ_REC" => GetMessage("CLU_SKIP_NETWORKING_WIZREC"));
     $innodb_flush_log_at_trx_commit = $this->GetServerVariable($nodeDB, "innodb_flush_log_at_trx_commit");
     $is_ok = $innodb_flush_log_at_trx_commit === '1';
     $result["innodb_flush_log_at_trx_commit"] = array("IS_OK" => $is_ok ? CClusterDBNodeCheck::OK : CClusterDBNodeCheck::WARNING, "MESSAGE" => GetMessage("CLU_FLUSH_ON_COMMIT_MSG", array("#innodb_flush_log_at_trx_commit#" => $innodb_flush_log_at_trx_commit)), "WIZ_REC" => "");
     $sync_binlog = $this->GetServerVariable($nodeDB, "sync_binlog");
     $is_ok = $sync_binlog === '1';
     $result["sync_binlog"] = array("IS_OK" => $is_ok ? CClusterDBNodeCheck::OK : CClusterDBNodeCheck::WARNING, "MESSAGE" => GetMessage("CLU_SYNC_BINLOG_MSG", array("#sync_binlog#" => $sync_binlog)), "WIZ_REC" => "");
     $DatabaseName = $DB->DBName;
     $is_ok = false;
     $rsBinLogs = $nodeDB->Query("show master status", true, '', array("fixed_connection" => true));
     if (!$rsBinLogs) {
         $result["master_status"] = array("IS_OK" => CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_MASTER_STATUS_MSG"), "WIZ_REC" => GetMessage("CLU_MASTER_STATUS_WIZREC", array("#sql#" => "GRANT REPLICATION CLIENT on *.* to 'user name'@'%';")));
     } else {
         if ($ar = $rsBinLogs->Fetch()) {
             if ($ar["Binlog_Do_DB"] === $DatabaseName) {
                 $is_ok = true;
             }
         }
         while ($ar = $rsBinLogs->Fetch()) {
             $is_ok = false;
         }
         $result["binlog_do_db"] = array("IS_OK" => $is_ok ? CClusterDBNodeCheck::OK : CClusterDBNodeCheck::ERROR, "MESSAGE" => GetMessage("CLU_SYNC_BINLOGDODB_MSG"), "WIZ_REC" => GetMessage("CLU_SYNC_BINLOGDODB_WIZREC", array("#database#" => $DatabaseName)));
     }
     return $result;
 }
Пример #11
0
                CClusterSlave::Stop($ID);
                break;
            case "skip_sql_error":
                CClusterSlave::SkipSQLError($ID);
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => GetMessage("CLU_SLAVE_LIST_ID"), "align" => "right", "default" => true), array("id" => "FLAG", "content" => GetMessage("CLU_SLAVE_LIST_FLAG"), "align" => "center", "default" => true), array("id" => "NAME", "content" => GetMessage("CLU_SLAVE_LIST_NAME"), "align" => "left", "default" => true), array("id" => "BEHIND", "content" => GetMessage("CLU_SLAVE_LIST_BEHIND"), "align" => "right", "default" => true), array("id" => "STATUS", "content" => GetMessage("CLU_SLAVE_LIST_STATUS"), "align" => "center", "default" => true), array("id" => "WEIGHT", "content" => GetMessage("CLU_SLAVE_LIST_WEIGHT"), "align" => "right", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("CLU_SLAVE_LIST_DESCRIPTION"), "align" => "left", "default" => false), array("id" => "DB_HOST", "content" => GetMessage("CLU_SLAVE_LIST_DB_HOST"), "align" => "left", "default" => false), array("id" => "DB_NAME", "content" => GetMessage("CLU_SLAVE_LIST_DB_NAME"), "align" => "left", "default" => false), array("id" => "DB_LOGIN", "content" => GetMessage("CLU_SLAVE_LIST_DB_LOGIN"), "align" => "left", "default" => false));
$lAdmin->AddHeaders($arHeaders);
$arFilter = array("=ROLE_ID" => array("MAIN", "SLAVE", "MASTER"));
if ($group_id > 0) {
    $arFilter["=GROUP_ID"] = $group_id;
}
$cData = new CClusterDBNode();
$rsData = $cData->GetList(array("ID" => "ASC"), $arFilter);
if (!isset($_SESSION["SLAVE_LIST"])) {
    $_SESSION["SLAVE_LIST"] = array();
}
$rsData = new CAdminResult($rsData, $sTableID);
$Position = 0;
$bNote1Show = false;
$bHasMaster = false;
while ($arRes = $rsData->Fetch()) {
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    if ($arRes["ROLE_ID"] == "MASTER" || $arRes["ROLE_ID"] == "MAIN") {
        $bHasMaster = true;
    }
    $arSlaveStatus = CClusterSlave::GetStatus($arRes["ID"]);
    if (is_array($arSlaveStatus) && $arRes["STATUS"] == "OFFLINE") {
        CClusterDBNode::SetOnline($arRes["ID"]);
Пример #12
0
        $ID = IntVal($ID);
        switch ($_REQUEST['action']) {
            case "delete":
                $arNode = CClusterDBNode::GetByID($ID);
                if (is_array($arNode) && $arNode["ROLE_ID"] == "MODULE" && $arNode["STATUS"] == "READY") {
                    CClusterDBNode::Delete($arNode["ID"]);
                }
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => GetMessage("CLU_DBNODE_LIST_ID"), "align" => "right", "default" => true), array("id" => "FLAG", "content" => GetMessage("CLU_DBNODE_LIST_FLAG"), "align" => "center", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("CLU_DBNODE_LIST_ACTIVE"), "align" => "center", "default" => true), array("id" => "STATUS", "content" => GetMessage("CLU_DBNODE_LIST_STATUS"), "align" => "center", "default" => true), array("id" => "NAME", "content" => GetMessage("CLU_DBNODE_LIST_NAME"), "align" => "left", "default" => true), array("id" => "MODULES", "content" => GetMessage("CLU_DBNODE_LIST_MODULES"), "align" => "left", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("CLU_DBNODE_LIST_DESCRIPTION"), "align" => "left", "default" => false), array("id" => "DB_HOST", "content" => GetMessage("CLU_DBNODE_LIST_DB_HOST"), "align" => "left", "default" => false), array("id" => "DB_NAME", "content" => GetMessage("CLU_DBNODE_LIST_DB_NAME"), "align" => "left", "default" => false), array("id" => "DB_LOGIN", "content" => GetMessage("CLU_DBNODE_LIST_DB_LOGIN"), "align" => "left", "default" => false));
$lAdmin->AddHeaders($arHeaders);
$strUptimeError = "";
$cData = new CClusterDBNode();
$rsData = $cData->GetList(array("ID" => "ASC"), array("=ROLE_ID" => array("MAIN", "MODULE"), "=MASTER_ID" => false));
$rsData = new CAdminResult($rsData, $sTableID);
while ($arRes = $rsData->Fetch()) {
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    $uptime = CClusterDBNode::GetUpTime($arRes["ID"]);
    $arModules = CClusterDBNode::GetModules($arRes["ID"]);
    if ($arRes["ACTIVE"] == "Y") {
        if ($arRes["STATUS"] == "OFFLINE" && $uptime !== false) {
            CClusterDBNode::SetOnline($arRes["ID"]);
            $arRes["STATUS"] = "ONLINE";
        } elseif ($arRes["STATUS"] == "ONLINE" && count($arModules) <= 0 && $arRes["ROLE_ID"] == "MODULE") {
            $ob = new CClusterDBNode();
            $ob->Update($arRes["ID"], array("STATUS" => "READY"));
            $arRes["STATUS"] = "READY";
        } elseif ($arRes["STATUS"] == "READY" && count($arModules) > 0) {
            $ob = new CClusterDBNode();
            case "resume":
                CClusterSlave::Resume($ID);
                break;
            case "stop":
                CClusterSlave::Stop($ID);
                break;
            case "skip_sql_error":
                CClusterSlave::SkipSQLError($ID);
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => GetMessage("CLU_SLAVE_LIST_ID"), "align" => "right", "default" => true), array("id" => "FLAG", "content" => GetMessage("CLU_SLAVE_LIST_FLAG"), "align" => "center", "default" => true), array("id" => "NAME", "content" => GetMessage("CLU_SLAVE_LIST_NAME"), "align" => "left", "default" => true), array("id" => "BEHIND", "content" => GetMessage("CLU_SLAVE_LIST_BEHIND"), "align" => "right", "default" => true), array("id" => "STATUS", "content" => GetMessage("CLU_SLAVE_LIST_STATUS"), "align" => "center", "default" => true), array("id" => "WEIGHT", "content" => GetMessage("CLU_SLAVE_LIST_WEIGHT"), "align" => "right", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("CLU_SLAVE_LIST_DESCRIPTION"), "align" => "left", "default" => false), array("id" => "DB_HOST", "content" => GetMessage("CLU_SLAVE_LIST_DB_HOST"), "align" => "left", "default" => false), array("id" => "DB_NAME", "content" => GetMessage("CLU_SLAVE_LIST_DB_NAME"), "align" => "left", "default" => false), array("id" => "DB_LOGIN", "content" => GetMessage("CLU_SLAVE_LIST_DB_LOGIN"), "align" => "left", "default" => false));
$lAdmin->AddHeaders($arHeaders);
$cData = new CClusterDBNode();
$rsData = $cData->GetList(array("ID" => "ASC"), array("=ROLE_ID" => array("MAIN", "SLAVE", "MASTER"), "=GROUP_ID" => $group_id));
if (!isset($_SESSION["SLAVE_LIST"])) {
    $_SESSION["SLAVE_LIST"] = array();
}
$rsData = new CAdminResult($rsData, $sTableID);
$Position = 0;
$bNote1Show = false;
$bHasMaster = false;
while ($arRes = $rsData->Fetch()) {
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    if ($arRes["ROLE_ID"] == "MASTER" || $arRes["ROLE_ID"] == "MAIN") {
        $bHasMaster = true;
    }
    $arSlaveStatus = CClusterSlave::GetStatus($arRes["ID"]);
    if (is_array($arSlaveStatus) && $arRes["STATUS"] == "OFFLINE") {
        CClusterDBNode::SetOnline($arRes["ID"]);