本文整理汇总了PHP中DBServer::IsSupported方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::IsSupported方法的具体用法?PHP DBServer::IsSupported怎么用?PHP DBServer::IsSupported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBServer
的用法示例。
在下文中一共展示了DBServer::IsSupported方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getServerStatus
/**
* @param DBServer $dbServer
* @param bool $cached check only cached information
* @param int $timeout
* @return array|null
*/
public function getServerStatus(DBServer $dbServer, $cached = true, $timeout = 0)
{
if ($dbServer->status == SERVER_STATUS::RUNNING && ($dbServer->IsSupported('0.8') && $dbServer->osType == 'linux' || $dbServer->IsSupported('0.19') && $dbServer->osType == 'windows')) {
if ($cached && !$dbServer->IsSupported('2.7.7')) {
return ['status' => 'statusNoCache', 'error' => "<span style='color:gray;'>Scalarizr is checking actual status</span>"];
}
try {
$scalarizr = $dbServer->scalarizrUpdateClient->getStatus($cached);
try {
if ($dbServer->farmRoleId != 0) {
$scheduledOn = $dbServer->GetFarmRoleObject()->GetSetting('scheduled_on');
}
} catch (Exception $e) {
}
$nextUpdate = null;
if ($scalarizr->candidate && $scalarizr->installed != $scalarizr->candidate) {
$nextUpdate = ['candidate' => htmlspecialchars($scalarizr->candidate), 'scheduledOn' => $scheduledOn ? Scalr_Util_DateTime::convertTzFromUTC($scheduledOn) : null];
}
return ['status' => htmlspecialchars($scalarizr->service_status), 'version' => htmlspecialchars($scalarizr->installed), 'candidate' => htmlspecialchars($scalarizr->candidate), 'repository' => Scalr::isHostedScalr() ? Utils::getScalarizrUpdateRepoTitle($scalarizr->repository) : ucfirst(htmlspecialchars($scalarizr->repository)), 'lastUpdate' => ['date' => $scalarizr->executed_at ? Scalr_Util_DateTime::convertTzFromUTC($scalarizr->executed_at) : "", 'error' => nl2br(htmlspecialchars($scalarizr->error))], 'nextUpdate' => $nextUpdate, 'fullInfo' => $scalarizr];
} catch (Exception $e) {
if (stristr($e->getMessage(), "Method not found")) {
return ['status' => 'statusNotAvailable', 'error' => "<span style='color:red;'>Scalarizr status is not available, because scalr-upd-client installed on this server is too old.</span>"];
} else {
return ['status' => 'statusNotAvailable', 'error' => "<span style='color:red;'>Scalarizr status is not available: {$e->getMessage()}</span>"];
}
}
}
}
示例2: onMysql_PromoteToMasterResult
/**
* @param Scalr_Messaging_Msg_Mysql_PromoteToMasterResult $message
* @param DBServer $dbserver
*/
private function onMysql_PromoteToMasterResult($message, DBServer $dbserver)
{
$dbserver->GetFarmRoleObject()->SetSetting(DBFarmRole::SETTING_MYSQL_SLAVE_TO_MASTER, 0);
if ($message->status == Scalr_Messaging_Msg_Mysql_PromoteToMasterResult::STATUS_OK) {
$dbFarm = $dbserver->GetFarmObject();
$dbFarmRole = $dbserver->GetFarmRoleObject();
$oldMaster = $dbFarm->GetMySQLInstances(true);
if ($dbserver->IsSupported("0.7")) {
if ($message->volumeConfig) {
try {
$storageVolume = Scalr_Storage_Volume::init();
try {
$storageVolume->loadById($message->volumeConfig->id);
$storageVolume->setConfig($message->volumeConfig);
$storageVolume->save();
} catch (Exception $e) {
if (strpos($e->getMessage(), 'not found')) {
$storageVolume->loadBy(array('id' => $message->volumeConfig->id, 'client_id' => $dbserver->clientId, 'env_id' => $dbserver->envId, 'name' => "MySQL data volume", 'type' => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $dbserver->platform, 'size' => $message->volumeConfig->size, 'fstype' => $message->volumeConfig->fstype, 'purpose' => ROLE_BEHAVIORS::MYSQL, 'farm_roleid' => $dbserver->farmRoleId, 'server_index' => $dbserver->index));
$storageVolume->setConfig($message->volumeConfig);
$storageVolume->save(true);
} else {
throw $e;
}
}
} catch (Exception $e) {
$this->logger->error(new FarmLogMessage($dbserver->farmId, "Cannot save storage volume: {$e->getMessage()}"));
}
}
if ($message->snapshotConfig) {
try {
$snapshot = Scalr_Model::init(Scalr_Model::STORAGE_SNAPSHOT);
$snapshot->loadBy(array('id' => $message->snapshotConfig->id, 'client_id' => $dbserver->clientId, 'env_id' => $dbserver->envId, 'name' => "Automatical MySQL data bundle", 'type' => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $dbserver->platform, 'description' => "MySQL data bundle created automatically by Scalr", 'ismysql' => true));
$snapshot->setConfig($message->snapshotConfig);
$snapshot->save(true);
$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID, $snapshot->id);
$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_FILE, $message->logFile);
$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_POS, $message->logPos);
} catch (Exception $e) {
$this->logger->error(new FarmLogMessage($dbserver->farmId, "Cannot save storage snapshot: {$e->getMessage()}"));
}
}
} else {
// TODO: delete old slave volume if new one was created
$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID, $message->volumeId);
}
return new NewMysqlMasterUpEvent($dbserver, "", $oldMaster[0]);
} elseif ($message->status == Scalr_Messaging_Msg_Mysql_PromoteToMasterResult::STATUS_FAILED) {
$dbserver->SetProperty(SERVER_PROPERTIES::DB_MYSQL_MASTER, 0);
$dbserver->SetProperty(Scalr_Db_Msr::REPLICATION_MASTER, 0);
// XXX: Need to do smth
$this->logger->error(sprintf("Promote to Master failed for server %s. Last error: %s", $dbserver->serverId, $message->lastError));
}
}
示例3: getServerStatus
/**
* @param DBServer $dbServer
* @param bool $cached check only cached information
* @param int $timeout
* @return array|NULL
*/
public function getServerStatus(DBServer $dbServer, $cached = true, $timeout = 0)
{
if ($dbServer->status == SERVER_STATUS::RUNNING && $dbServer->GetProperty(SERVER_PROPERTIES::SUB_STATUS) != 'stopped' && ($dbServer->IsSupported('0.8') && $dbServer->osType == 'linux' || $dbServer->IsSupported('0.19') && $dbServer->osType == 'windows')) {
if ($cached && !$dbServer->IsSupported('2.7.7')) {
return ['status' => 'statusNoCache', 'error' => "<span style='color:gray;'>Scalarizr is checking actual status</span>"];
}
try {
$port = $dbServer->GetProperty(SERVER_PROPERTIES::SZR_UPDC_PORT);
if (!$port) {
$port = 8008;
}
if (!$timeout) {
$timeout = \Scalr::config('scalr.system.instances_connection_timeout');
}
$updateClient = new Scalr_Net_Scalarizr_UpdateClient($dbServer, $port, $timeout);
$scalarizr = $updateClient->getStatus($cached);
try {
if ($dbServer->farmRoleId != 0) {
$scheduledOn = $dbServer->GetFarmRoleObject()->GetSetting('scheduled_on');
}
} catch (Exception $e) {
}
$nextUpdate = null;
if ($scalarizr->candidate && $scalarizr->installed != $scalarizr->candidate) {
$nextUpdate = ['candidate' => htmlspecialchars($scalarizr->candidate), 'scheduledOn' => $scheduledOn ? Scalr_Util_DateTime::convertTz($scheduledOn) : null];
}
return ['status' => htmlspecialchars($scalarizr->service_status), 'version' => htmlspecialchars($scalarizr->installed), 'candidate' => htmlspecialchars($scalarizr->candidate), 'repository' => ucfirst(htmlspecialchars($scalarizr->repository)), 'lastUpdate' => ['date' => $scalarizr->executed_at ? Scalr_Util_DateTime::convertTz($scalarizr->executed_at) : "", 'error' => nl2br(htmlspecialchars($scalarizr->error))], 'nextUpdate' => $nextUpdate, 'fullInfo' => $scalarizr];
} catch (Exception $e) {
if (stristr($e->getMessage(), "Method not found")) {
return ['status' => 'upgradeUpdClient'];
} else {
return ['status' => 'statusNotAvailable', 'error' => "<span style='color:red;'>Scalarizr status is not available: {$e->getMessage()}</span>"];
}
}
}
}