/** * Return information about memcached from cluster module * @return array */ protected static function getMemCacheInfoFromCluster() { $result = array(); if (CModule::IncludeModule("cluster")) { $clusterMemcaches = CClusterMemcache::GetList(); while ($clusterMemcacheServer = $clusterMemcaches->Fetch()) { // if($clusterMemcacheServer["STATUS"] == "ONLINE"){ $result[] = array("host" => $clusterMemcacheServer["HOST"], "port" => $clusterMemcacheServer["PORT"]); // } } } return $result; }
case "pause": CClusterMemcache::Pause($ID); break; case "resume": CClusterMemcache::Resume($ID); break; } } } $arHeaders = array(array("id" => "ID", "content" => GetMessage("CLU_MEMCACHE_LIST_ID"), "align" => "right", "default" => true), array("id" => "FLAG", "content" => GetMessage("CLU_MEMCACHE_LIST_FLAG"), "align" => "center", "default" => true), array("id" => "STATUS", "content" => GetMessage("CLU_MEMCACHE_LIST_STATUS"), "align" => "center", "default" => true), array("id" => "WEIGHT", "content" => GetMessage("CLU_MEMCACHE_LIST_WEIGHT"), "align" => "right", "default" => true), array("id" => "HOST", "content" => GetMessage("CLU_MEMCACHE_LIST_HOST"), "align" => "left", "default" => true)); $lAdmin->AddHeaders($arHeaders); if (!isset($_SESSION["MEMCACHE_LIST"])) { $_SESSION["MEMCACHE_LIST"] = array(); } $cData = new CClusterMemcache(); $rsData = $cData->GetList(); $uptime = false; $rsData = new CAdminResult($rsData, $sTableID); while ($arRes = $rsData->Fetch()) { if (!$arRes["GROUP_ID"]) { $arRes = CClusterMemcache::GetByID($arRes["ID"]); $cData->Update($arRes["ID"], $arRes); $arRes = CClusterMemcache::GetByID($arRes["ID"]); } if ($arRes["GROUP_ID"] != $group_id) { continue; } $row =& $lAdmin->AddRow($arRes["ID"], $arRes); $row->AddViewField("ID", '<a href="cluster_memcache_edit.php?lang=' . LANGUAGE_ID . '&group_id=' . $group_id . '&ID=' . $arRes["ID"] . '">' . $arRes["ID"] . '</a>'); $html = ''; if (true) {
/** * Installation config to module "cluster". * * @param InputInterface $input * @param OutputInterface $output * @param array $cluster * * @throws \Bitrix\Main\LoaderException * @throws \Exception */ protected function configureCluster(InputInterface $input, OutputInterface $output, array $cluster) { global $APPLICATION; if (!Loader::includeModule('cluster')) { throw new \Exception('Failed to load module "cluster"'); } $memcache = new \CClusterMemcache(); if (isset($cluster['memcache'])) { $output->writeln(' <comment>memcache</comment>'); if (!is_array($cluster['memcache'])) { throw new \Exception('Server info must be an array'); } $rsServers = $memcache->GetList(); while ($server = $rsServers->Fetch()) { $memcache->Delete($server['ID']); } foreach ($cluster['memcache'] as $index => $server) { $serverId = $memcache->Add($server); if ($serverId && !$input->getOption('memcache-cold-start')) { $memcache->Resume($serverId); } else { $exception = $APPLICATION->GetException(); $message = 'Invalid memcache config with index ' . $index; if ($exception->GetString()) { $message = str_replace('<br>', "\n", $exception->GetString()); } $output->writeln('<error>' . $message . '</error>'); } } } }