function Run() { global $DB; $rs = $DB->Query("\n\t\t\tSELECT *\n\t\t\tFROM b_cluster_queue\n\t\t\tWHERE GROUP_ID = " . BX_CLUSTER_GROUP . "\n\t\t\tORDER BY ID\n\t\t"); while ($ar = $rs->Fetch()) { $class_name = $ar["COMMAND"]; if (class_exists($class_name)) { $object = new $class_name(); $object->QueueRun(CClusterQueue::UnQuoteParam($ar["PARAM1"]), CClusterQueue::UnQuoteParam($ar["PARAM2"]), CClusterQueue::UnQuoteParam($ar["PARAM3"])); } $DB->Query("DELETE FROM b_cluster_queue WHERE ID = " . intval($ar["ID"])); } }
function clean($basedir, $initdir = false, $filename = false) { global $DB; if (is_object(self::$obMemcache)) { if ($this->bQueue && class_exists('CModule') && CModule::IncludeModule('cluster')) { foreach (self::$arOtherGroups as $group_id => $tmp) { CClusterQueue::Add($group_id, 'CPHPCacheMemcacheCluster', $basedir, $initdir, $filename); } } if (strlen($filename)) { $basedir_version = self::$obMemcache->get($this->sid . $basedir); if ($basedir_version === false || $basedir_version === '') { return true; } if ($initdir !== false) { $initdir_version = self::$obMemcache->get($basedir_version . "|" . $initdir); if ($initdir_version === false || $initdir_version === '') { return true; } } else { $initdir_version = ""; } self::$obMemcache->replace($basedir_version . "|" . $initdir_version . "|" . $filename, "", 0, 1); } else { if (strlen($initdir)) { $basedir_version = self::$obMemcache->get($this->sid . $basedir); if ($basedir_version === false || $basedir_version === '') { return true; } self::$obMemcache->replace($basedir_version . "|" . $initdir, "", 0, 1); } else { self::$obMemcache->replace($this->sid . $basedir, "", 0, 1); } } return true; } return false; }
<?php IncludeModuleLangFile(__FILE__); //Never increase caching time here. There were cache clenup problems noticed. if (!defined("CACHED_b_cluster_dbnode")) { define("CACHED_b_cluster_dbnode", 3600); } global $DB; $db_type = strtolower($DB->type); CModule::AddAutoloadClasses("cluster", array("CClusterGroup" => "classes/general/group.php", "CClusterQueue" => "classes/general/queue.php", "CAllClusterDBNode" => "classes/general/dbnode.php", "CClusterDBNode" => "classes/" . $db_type . "/dbnode.php", "CAllClusterDBNodeCheck" => "classes/general/dbnode_check.php", "CClusterDBNodeCheck" => "classes/" . $db_type . "/dbnode_check.php", "CClusterSlave" => "classes/" . $db_type . "/slave.php", "CClusterMemcache" => "classes/general/memcache.php", "CClusterWebnode" => "classes/general/webnode.php")); if (defined("BX_CLUSTER_GROUP")) { CClusterQueue::Run(); } class CCluster { public static function checkForServers($toBeAddedCount = 0) { $countLimit = intval(COption::GetOptionString('main', '~PARAM_MAX_SERVERS', 0)); if ($countLimit > 0) { return self::getServersCount() + $toBeAddedCount <= $countLimit; } else { return true; } } public static function getServersCount() { static $cache = null; if ($cache === null) { $hosts = array(); foreach (self::getServerList() as $server) { if ($server["DEDICATED"] == "Y") {