本文整理汇总了PHP中DBFarmRole::GetRunningInstancesCount方法的典型用法代码示例。如果您正苦于以下问题:PHP DBFarmRole::GetRunningInstancesCount方法的具体用法?PHP DBFarmRole::GetRunningInstancesCount怎么用?PHP DBFarmRole::GetRunningInstancesCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBFarmRole
的用法示例。
在下文中一共展示了DBFarmRole::GetRunningInstancesCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeDecision
public function makeDecision(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric, $isInvert = false)
{
if ($farmRoleMetric->lastValue > $farmRoleMetric->getSetting('max')) {
$retval = Scalr_Scaling_Decision::UPSCALE;
} elseif ($farmRoleMetric->lastValue < $farmRoleMetric->getSetting('min')) {
$retval = Scalr_Scaling_Decision::DOWNSCALE;
}
if (!$retval) {
return Scalr_Scaling_Decision::NOOP;
} else {
if ($isInvert) {
if ($retval == Scalr_Scaling_Decision::UPSCALE) {
$retval = Scalr_Scaling_Decision::DOWNSCALE;
} else {
$retval = Scalr_Scaling_Decision::UPSCALE;
}
}
if ($retval == Scalr_Scaling_Decision::UPSCALE) {
if ($dbFarmRole->GetRunningInstancesCount() + $dbFarmRole->GetPendingInstancesCount() >= $dbFarmRole->GetSetting(Entity\FarmRoleSetting::SCALING_MAX_INSTANCES)) {
$retval = Scalr_Scaling_Decision::NOOP;
}
}
if ($retval == Scalr_Scaling_Decision::DOWNSCALE) {
if ($dbFarmRole->GetRunningInstancesCount() <= $dbFarmRole->GetSetting(Entity\FarmRoleSetting::SCALING_MIN_INSTANCES)) {
$retval = Scalr_Scaling_Decision::NOOP;
}
}
$isSzr = true;
if ($retval == Scalr_Scaling_Decision::UPSCALE && ($dbFarmRole->GetPendingInstancesCount() > 5 && !$isSzr)) {
return Scalr_Scaling_Decision::NOOP;
} else {
return $retval;
}
}
}
示例2: makeDecision
public function makeDecision(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric, $isInvert = false)
{
// Get data from BW sensor
$dbFarm = $dbFarmRole->GetFarmObject();
$tz = $dbFarm->GetSetting(Entity\FarmSetting::TIMEZONE);
$date = new DateTime();
if ($tz) {
$date->setTimezone(new DateTimeZone($tz));
}
$currentDate = array((int) $date->format("Hi"), $date->format("D"));
$scaling_period = $this->db->GetRow("\n SELECT * FROM farm_role_scaling_times\n WHERE '{$currentDate[0]}' >= start_time\n AND '{$currentDate[0]}' <= end_time\n AND INSTR(days_of_week, '{$currentDate[1]}') != 0\n AND farm_roleid = '{$dbFarmRole->ID}'\n LIMIT 1\n ");
if ($scaling_period) {
$this->logger->info("TimeScalingAlgo({$dbFarmRole->FarmID}, {$dbFarmRole->ID}) Found scaling period. Total {$scaling_period['instances_count']} instances should be running.");
$this->instancesNumber = $scaling_period['instances_count'];
$this->lastValue = "(" . implode(' / ', $currentDate) . ") {$scaling_period['start_time']} - {$scaling_period['end_time']} = {$scaling_period['instances_count']}";
if ($dbFarmRole->GetRunningInstancesCount() + $dbFarmRole->GetPendingInstancesCount() < $this->instancesNumber) {
return Scalr_Scaling_Decision::UPSCALE;
} elseif ($dbFarmRole->GetRunningInstancesCount() + $dbFarmRole->GetPendingInstancesCount() > $this->instancesNumber) {
return Scalr_Scaling_Decision::DOWNSCALE;
} else {
return Scalr_Scaling_Decision::NOOP;
}
} else {
if ($dbFarmRole->GetRunningInstancesCount() > $dbFarmRole->GetSetting(Entity\FarmRoleSetting::SCALING_MIN_INSTANCES)) {
$this->lastValue = "No period defined. Using Min instances setting.";
return Scalr_Scaling_Decision::DOWNSCALE;
} else {
return Scalr_Scaling_Decision::NOOP;
}
}
}
示例3: makeDecision
public function makeDecision(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric, $isInvert = false)
{
//
// Get data from BW sensor
//
$dbFarm = $dbFarmRole->GetFarmObject();
$env = $dbFarm->GetEnvironmentObject();
$tz = $env->getPlatformConfigValue(ENVIRONMENT_SETTINGS::TIMEZONE);
if ($tz) {
$default_tz = @date_default_timezone_get();
@date_default_timezone_set($tz);
}
$currentDate = array((int) date("Hi"), date("D"));
if ($default_tz) {
@date_default_timezone_set($default_tz);
}
$scaling_period = $this->db->GetRow("SELECT * FROM farm_role_scaling_times WHERE\r\n\t\t\t\t'{$currentDate[0]}' >= start_time AND\r\n\t\t\t\t'{$currentDate[0]}' <= end_time-10 AND\r\n\t\t\t\tINSTR(days_of_week, '{$currentDate[1]}') != 0 AND\r\n\t\t\t\tfarm_roleid = '{$dbFarmRole->ID}'\r\n\t\t\t");
if ($scaling_period) {
$this->logger->info("TimeScalingAlgo({$dbFarmRole->FarmID}, {$dbFarmRole->AMIID}) Found scaling period. Total {$scaling_period['instances_count']} instances should be running.");
$num_instances = $scaling_period['instances_count'];
//$dbFarmRole->SetSetting(self::PROPERTY_NEED_INSTANCES_IN_CURRENT_PERIOD, $num_instances);
if ($dbFarmRole->GetRunningInstancesCount() + $dbFarmRole->GetPendingInstancesCount() < $num_instances) {
return Scalr_Scaling_Decision::UPSCALE;
} else {
return Scalr_Scaling_Decision::NOOP;
}
} else {
//$dbFarmRole->SetSetting(self::PROPERTY_NEED_INSTANCES_IN_CURRENT_PERIOD, "");
if ($dbFarmRole->GetRunningInstancesCount() > $dbFarmRole->GetSetting(DBFarmRole::SETTING_SCALING_MIN_INSTANCES)) {
return Scalr_Scaling_Decision::DOWNSCALE;
} else {
return Scalr_Scaling_Decision::NOOP;
}
}
}
示例4: makeDecision
public function makeDecision(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric, $isInvert = false)
{
if ($farmRoleMetric->lastValue > $farmRoleMetric->getSetting('max')) {
$retval = Scalr_Scaling_Decision::UPSCALE;
} elseif ($farmRoleMetric->lastValue < $farmRoleMetric->getSetting('min')) {
$retval = Scalr_Scaling_Decision::DOWNSCALE;
}
if (!$retval) {
return Scalr_Scaling_Decision::NOOP;
} else {
if ($isInvert) {
if ($retval == Scalr_Scaling_Decision::UPSCALE) {
$retval = Scalr_Scaling_Decision::DOWNSCALE;
} else {
$retval = Scalr_Scaling_Decision::UPSCALE;
}
}
if ($retval == Scalr_Scaling_Decision::UPSCALE) {
if ($dbFarmRole->GetRunningInstancesCount() + $dbFarmRole->GetPendingInstancesCount() >= $dbFarmRole->GetSetting(DBFarmRole::SETTING_SCALING_MAX_INSTANCES)) {
$retval = Scalr_Scaling_Decision::NOOP;
}
}
if ($retval == Scalr_Scaling_Decision::DOWNSCALE) {
if ($dbFarmRole->GetRunningInstancesCount() <= $dbFarmRole->GetSetting(DBFarmRole::SETTING_SCALING_MIN_INSTANCES)) {
$retval = Scalr_Scaling_Decision::NOOP;
}
}
$isSzr = $dbFarmRole->GetRoleObject()->isSupported("0.5");
if ($retval == Scalr_Scaling_Decision::UPSCALE && ($dbFarmRole->GetPendingInstancesCount() > 5 && !$isSzr)) {
return Scalr_Scaling_Decision::NOOP;
} else {
//if ($isSzr && $dbFarmRole->GetPendingInstancesCount() > 10)
//return Scalr_Scaling_Decision::NOOP;
//else
return $retval;
}
}
}
示例5: makeDecision
public function makeDecision(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric, $isInvert = false)
{
// Get data from BW sensor
$dbFarm = $dbFarmRole->GetFarmObject();
$tz = $dbFarm->GetSetting(Entity\FarmSetting::TIMEZONE);
$date = new DateTime();
if ($tz) {
$date->setTimezone(new DateTimeZone($tz));
}
$currentDate = array((int) $date->format("Hi"), $date->format("D"), $date->format("H"), $date->format("i"));
$scalingPeriod = $this->db->GetRow("\n SELECT * FROM farm_role_scaling_times \n WHERE ? BETWEEN start_time AND end_time\n AND INSTR(days_of_week, ?) != 0 \n AND farm_roleid = ? \n LIMIT 1\n ", [$currentDate[0], $currentDate[1], $dbFarmRole->ID]);
$minInstances = $dbFarmRole->GetSetting(Entity\FarmRoleSetting::SCALING_MIN_INSTANCES);
if ($scalingPeriod) {
$this->logger->info("TimeScalingAlgo({$dbFarmRole->FarmID}, {$dbFarmRole->ID}) Found scaling period. Total {$scalingPeriod['instances_count']} instances should be running.");
$this->instancesNumber = $scalingPeriod['instances_count'];
$farmRoleRunningInstances = $dbFarmRole->GetRunningInstancesCount();
$farmRolePendingInstances = $dbFarmRole->GetPendingInstancesCount();
$roleTotalInstances = $farmRoleRunningInstances + $farmRolePendingInstances;
if ($roleTotalInstances == $this->instancesNumber) {
return Scalr_Scaling_Decision::NOOP;
} else {
$this->lastValue = sprintf("Current time '%s' matching rule '%s'. %s out of %s servers is currently running (pending)", "{$currentDate[1]}, {$currentDate[2]}:{$currentDate[3]}", "{$scalingPeriod['days_of_week']}: {$scalingPeriod['start_time']} - {$scalingPeriod['end_time']}", $roleTotalInstances, $this->instancesNumber);
if ($roleTotalInstances < $this->instancesNumber) {
return Scalr_Scaling_Decision::UPSCALE;
} elseif ($roleTotalInstances > $this->instancesNumber) {
return Scalr_Scaling_Decision::DOWNSCALE;
}
}
} else {
$this->instancesNumber = $minInstances;
if ($roleTotalInstances > $minInstances) {
$this->lastValue = sprintf("Current time '%s' has no matching rule. Maintaining minimum servers count (%s). %s out of %s servers is currently running (pending)", "{$currentDate[1]}, {$currentDate[2]} {$currentDate[3]}", $minInstances, $roleTotalInstances, $minInstances);
return Scalr_Scaling_Decision::DOWNSCALE;
} else {
return Scalr_Scaling_Decision::NOOP;
}
}
}