49 'id' => $oServer->getId(),
50 'timestamp' => $oServer->getTimestamp(),
51 'ip' => $oServer->getIp(),
52 'lastFrontendUsage' => $oServer->getLastFrontendUsage(),
53 'lastAdminUsage' => $oServer->getLastAdminUsage(),
54 'isValid' => $oServer->isValid()
56 $this->
saveToDb($oServer->getId(), $aServerData);
70 $oAppServer =
oxNew(
'oxApplicationServer');
72 $oAppServer->setId($sServerId);
75 $oAppServer->setLastFrontendUsage($this->
getServerParameter($aData,
'lastFrontendUsage'));
92 return array_key_exists($sName, $aData) ? $aData[$sName] : null;
106 $aValidServers = array();
108 foreach ($aServersData as $aServer) {
109 if ($aServer[
'isValid']) {
110 unset($aServer[
'isValid']);
111 unset($aServer[
'timestamp']);
112 $aValidServers[] = $aServer;
116 return $aValidServers;
127 $sShopId = $oConfig->getBaseShopId();
128 $sVarName = self::CONFIG_NAME_FOR_SERVER_INFO.$sServerId;
130 $sQ =
"DELETE FROM oxconfig WHERE oxvarname = ? and oxshopid = ?";
131 $oDb->execute($sQ, array($sVarName, $sShopId));
143 foreach ($aServersData as $sServerId => $aServerData) {
144 if ($aServerData[
'timestamp'] <
oxRegistry::get(
"oxUtilsDate")->getTime() - self::NODE_AVAILABILITY_CHECK_PERIOD) {
146 $oServer->setIsValid(
false);
148 $aServersData[$sServerId][
'isValid'] =
false;
151 return $aServersData;
163 foreach ($aServersData as $sServerId => $aServerData) {
164 if ($aServerData[
'timestamp'] <
oxRegistry::get(
"oxUtilsDate")->getTime() - self::INACTIVE_NODE_STORAGE_PERIOD) {
166 unset($aServersData[$sServerId]);
169 return $aServersData;
179 $aServersData = array();
181 if ($result !=
false && $result->recordCount() > 0) {
182 while (!$result->EOF) {
184 $aServersData[$sServerId] = (array)unserialize($result->fields[
'oxvarvalue']);
188 return $aServersData;
200 $iConstNameLength = strlen(self::CONFIG_NAME_FOR_SERVER_INFO);
201 $sId = substr($sVarName, $iConstNameLength);
215 $sConfigsQuery =
"SELECT oxvarname, " . $oConfig->getDecodeValueQuery() .
216 " as oxvarvalue FROM oxconfig WHERE oxvarname like ? AND oxshopid = ?";
218 return $oDb->select($sConfigsQuery, array(self::CONFIG_NAME_FOR_SERVER_INFO.
"%", $oConfig->getBaseShopId()));
230 $aServerData = array();
233 if ($sData !=
false ) {
234 $aServerData = (array)unserialize($sData);
251 $sConfigsQuery =
"SELECT " . $oConfig->getDecodeValueQuery() .
252 " as oxvarvalue FROM oxconfig WHERE oxvarname = ? AND oxshopid = ?";
254 $sResult = $oDb->getOne($sConfigsQuery, array($sVarName, $oConfig->getBaseShopId()),
false);
265 protected function saveToDb($sServerId, $aServerData)
268 $sVarName = self::CONFIG_NAME_FOR_SERVER_INFO.$sServerId;
269 $sConfigKey = $oConfig->getConfigParam(
'sConfigKey');
270 $sValue = serialize($aServerData);
272 $sShopId = $oConfig->getBaseShopId();
275 $sQ =
"UPDATE oxconfig SET oxvarvalue=ENCODE( ?, ?) WHERE oxvarname = ? and oxshopid = ?";
276 $oDb->execute($sQ, array($sValue, $sConfigKey, $sVarName, $sShopId));
280 $sQ =
"insert into oxconfig (oxid, oxshopid, oxmodule, oxvarname, oxvartype, oxvarvalue)
281 values(?, ?, '', ?, ?, ENCODE( ?, ?) )";
282 $oDb->execute($sQ, array($sOxid, $sShopId, $sVarName, $sVarType, $sValue, $sConfigKey));