本文整理汇总了PHP中Scalr_Role_Behavior::handleMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Role_Behavior::handleMessage方法的具体用法?PHP Scalr_Role_Behavior::handleMessage怎么用?PHP Scalr_Role_Behavior::handleMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Role_Behavior
的用法示例。
在下文中一共展示了Scalr_Role_Behavior::handleMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleMessage
public function handleMessage(Scalr_Messaging_Msg $message, DBServer $dbServer)
{
parent::handleMessage($message, $dbServer);
if (!$message->cfCloudController) {
return;
}
switch (get_class($message)) {
case "Scalr_Messaging_Msg_HostUp":
if ($message->cfCloudController->volumeConfig) {
$this->setVolumeConfig($message->cfCloudController->volumeConfig, $dbServer->GetFarmRoleObject(), $dbServer);
$dbServer->GetFarmRoleObject()->SetSetting(self::ROLE_VERSION, $message->cfCloudController->version, DBFarmRole::TYPE_LCL);
} else {
throw new Exception("Received hostUp message from CF Cloud Controller server without volumeConfig");
}
break;
}
}
示例2: handleMessage
public function handleMessage(Scalr_Messaging_Msg $message, DBServer $dbServer)
{
parent::handleMessage($message, $dbServer);
if (!$message->rabbitmq) {
return;
}
switch (get_class($message)) {
case "Scalr_Messaging_Msg_HostUp":
if ($message->rabbitmq->volumeConfig) {
$this->setVolumeConfig($message->rabbitmq->volumeConfig, $dbServer->GetFarmRoleObject(), $dbServer);
} else {
throw new Exception("Received hostUp message from RabbitMQ server without volumeConfig");
}
$dbServer->GetFarmRoleObject()->SetSetting(self::ROLE_PASSWORD, $message->rabbitmq->password, DBFarmRole::TYPE_LCL);
if ($message->rabbitmq->masterPassword) {
$dbServer->GetFarmRoleObject()->SetSetting(self::ROLE_MASTER_PASSWORD, $message->rabbitmq->masterPassword, DBFarmRole::TYPE_LCL);
}
break;
}
}
示例3: handleMessage
public function handleMessage(Scalr_Messaging_Msg $message, DBServer $dbServer)
{
parent::handleMessage($message, $dbServer);
try {
$dbFarmRole = $dbServer->GetFarmRoleObject();
} catch (Exception $e) {
}
switch (get_class($message)) {
case "Scalr_Messaging_Msg_MongoDb_ClusterTerminateStatus":
$this->log($dbFarmRole, "Shutting-down cluster. Progress {$message->progress}%");
//Check instances
$nodes = array();
foreach ($message->nodes as $node) {
$nodes[$node->shardIndex][$node->replicaSetIndex] = $node;
}
foreach ($dbFarmRole->GetServersByFilter() as $server) {
$shardIndex = $server->GetProperty(self::SERVER_SHARD_INDEX);
$replicaSetIndex = $server->GetProperty(self::SERVER_REPLICA_SET_INDEX);
$node = $nodes[$shardIndex][$replicaSetIndex];
switch ($server->status) {
case SERVER_STATUS::PENDING_LAUNCH:
case SERVER_STATUS::PENDING:
case SERVER_STATUS::INIT:
$server->terminate(array('SHUTTING_DOWN_CLUSTER', 'MongoDB'));
break;
case SERVER_STATUS::RUNNING:
if ($node->status == 'pending') {
continue;
}
if ($node->status == 'terminating') {
continue;
}
if ($node->status == 'terminated') {
if ($server->GetProperty(Scalr_Role_Behavior_MongoDB::SERVER_IS_CFG_SERVER)) {
$this->log($dbFarmRole, "Node {$shardIndex}-{$replicaSetIndex} successfully terminated. Config server will be terminated with farm.");
} else {
$this->log($dbFarmRole, "Node {$shardIndex}-{$replicaSetIndex} successfully terminated. Terminating instance.");
$server->terminate(array('SHUTTING_DOWN_CLUSTER', 'MongoDB'));
}
} else {
$this->log($dbFarmRole, "Cannot shutdown {$shardIndex}-{$replicaSetIndex} node. Error: {$node->lastError}", "ERROR");
$server->SetProperty(Scalr_Role_Behavior_MongoDB::SERVER_NODE_STATUS, 'failed');
}
break;
}
}
break;
case "Scalr_Messaging_Msg_MongoDb_ClusterTerminateResult":
if ($message->status == 'ok') {
$dbFarmRole->SetSetting(self::ROLE_CLUSTER_STATUS, self::STATUS_TERMINATED, DBFarmRole::TYPE_LCL);
$this->log($dbFarmRole, "Cluster successfully terminated", "INFO");
} else {
$this->log($dbFarmRole, "Unable to shutdown mongodb cluster. Received TerminateCluster failed message.", "ERROR");
$dbFarmRole->SetSetting(self::ROLE_CLUSTER_STATUS, self::STATUS_ACTIVE, DBFarmRole::TYPE_LCL);
}
break;
case "Scalr_Messaging_Msg_MongoDb_RemoveShardStatus":
$status = "Removing shard #{$message->shardIndex}. Progress: {$message->progress}%";
$this->log($dbFarmRole, $status);
break;
case "Scalr_Messaging_Msg_MongoDb_RemoveShardResult":
$rShard = $dbFarmRole->GetSetting(self::ROLE_CLUSTER_IS_REMOVING_SHARD_INDEX);
if (!$rShard || $rShard != $message->shardIndex) {
return;
}
if ($message->status == 'ok') {
$dbFarmRole->SetSetting(self::ROLE_CLUSTER_IS_REMOVING_SHARD_INDEX, null, DBFarmRole::TYPE_LCL);
$sCount = $dbFarmRole->GetSetting(self::ROLE_SHARDS_COUNT);
$dbFarmRole->SetSetting(self::ROLE_SHARDS_COUNT, $sCount - 1, DBFarmRole::TYPE_CFG);
// Terminate instances
foreach ($dbFarmRole->GetServersByFilter(array('status' => array(SERVER_STATUS::RUNNING, SERVER_STATUS::INIT, SERVER_STATUS::PENDING, SERVER_STATUS::PENDING_LAUNCH))) as $server) {
if ($server->GetProperty(self::SERVER_SHARD_INDEX) == $message->shardIndex) {
$server->terminate(array('SHUTTING_DOWN_CLUSTER', 'MongoDB'), false);
}
}
$this->db->Execute("DELETE FROM services_mongodb_volumes_map WHERE farm_roleid = ? AND shard_index = ?", array($dbFarmRole->ID, $message->shardIndex));
$this->db->Execute("DELETE FROM services_mongodb_snapshots_map WHERE farm_roleid = ? AND shard_index = ?", array($dbFarmRole->ID, $message->shardIndex));
$this->log($dbFarmRole, "Shard #{$message->shardIndex} successfully removed");
} else {
$this > log($dbFarmRole, $message->lastError, "ERROR");
}
break;
//services_mongodb_config_servers
//services_mongodb_config_servers
case "Scalr_Messaging_Msg_HostUpdate":
if (!$message->mongodb) {
return;
}
if ($message->mongodb->volumeConfig) {
$this->setVolumeConfig($message->mongodb->volumeConfig, $dbServer->GetFarmRoleObject(), $dbServer);
}
if ($message->mongodb->configServers) {
$this->setConfigServersConfig($message->mongodb->configServers, $dbServer->GetFarmRoleObject(), $dbServer);
}
break;
case "Scalr_Messaging_Msg_HostUp":
if (!$message->mongodb) {
return;
}
if ($message->mongodb->volumeConfig) {
//.........这里部分代码省略.........
示例4: handleMessage
public function handleMessage(Scalr_Messaging_Msg $message, DBServer $dbServer)
{
parent::handleMessage($message, $dbServer);
try {
$dbFarmRole = $dbServer->GetFarmRoleObject();
$storageType = $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE);
$storageGeneration = $storageType == 'lvm' ? 2 : 1;
} catch (Exception $e) {
}
switch (get_class($message)) {
case "Scalr_Messaging_Msg_HostUp":
if ($message->dbType && in_array($message->dbType, array(ROLE_BEHAVIORS::REDIS, ROLE_BEHAVIORS::POSTGRESQL, ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::PERCONA, ROLE_BEHAVIORS::MARIADB))) {
$dbMsrInfo = Scalr_Db_Msr_Info::init($dbFarmRole, $dbServer, $message->dbType);
$dbMsrInfo->setMsrSettings($message->{$message->dbType});
if ($message->{$message->dbType}->snapshotConfig) {
$dbFarmRole->SetSetting(self::ROLE_NO_DATA_BUNDLE_FOR_SLAVES, 0, DBFarmRole::TYPE_LCL);
}
if ($message->{$message->dbType}->restore) {
$this->db->Execute("INSERT INTO storage_restore_configs SET farm_roleid = ?, dtadded=NOW(), manifest = ?", array($dbFarmRole->ID, $message->{$message->dbType}->restore->cloudfsSource));
$dbFarmRole->SetSetting(self::ROLE_NO_DATA_BUNDLE_FOR_SLAVES, 0, DBFarmRole::TYPE_LCL);
$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_LAST_TS, time(), DBFarmRole::TYPE_LCL);
$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_IS_RUNNING, 0, DBFarmRole::TYPE_LCL);
}
if ($message->{$message->dbType}->masterPassword) {
$dbFarmRole->SetSetting(self::ROLE_MASTER_PASSWORD, $message->{$message->dbType}->masterPassword, DBFarmRole::TYPE_LCL);
}
}
break;
case "Scalr_Messaging_Msg_DbMsr_PromoteToMasterResult":
if ($message->{$message->dbType}->restore) {
$this->db->Execute("INSERT INTO storage_restore_configs SET farm_roleid = ?, dtadded=NOW(), manifest = ?", array($dbFarmRole->ID, $message->{$message->dbType}->restore->cloudfsSource));
$dbFarmRole->SetSetting(self::ROLE_NO_DATA_BUNDLE_FOR_SLAVES, 0, DBFarmRole::TYPE_LCL);
}
if (Scalr_Db_Msr::onPromoteToMasterResult($message, $dbServer)) {
if ($message->{$this->behavior}->snapshotConfig) {
$dbFarmRole->SetSetting(self::ROLE_NO_DATA_BUNDLE_FOR_SLAVES, 0, DBFarmRole::TYPE_LCL);
}
Scalr::FireEvent($dbServer->farmId, new NewDbMsrMasterUpEvent($dbServer));
}
break;
case "Scalr_Messaging_Msg_DbMsr_CreateDataBundleResult":
if ($message->status == "ok") {
if (isset($message->{$message->dbType}->restore) && isset($message->{$message->dbType}->restore->backupType)) {
$t = $message->{$message->dbType}->restore;
if ($t->backupType == 'incremental') {
$parentManifest = $this->db->GetOne("\n SELECT manifest FROM storage_restore_configs WHERE farm_roleid = ? ORDER BY id DESC LIMIT 1\n ", array($dbFarmRole->ID));
}
$this->db->Execute("\n INSERT INTO storage_restore_configs SET farm_roleid = ?, dtadded=NOW(), manifest = ?, type = ?, parent_manifest = ?\n ", array($dbFarmRole->ID, $t->cloudfsSource, $t->backupType, $parentManifest));
unset($t);
}
$dbFarmRole->SetSetting(self::ROLE_NO_DATA_BUNDLE_FOR_SLAVES, 0, DBFarmRole::TYPE_LCL);
Scalr_Db_Msr::onCreateDataBundleResult($message, $dbServer);
} else {
$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_IS_RUNNING, 0, DBFarmRole::TYPE_LCL);
// TODO: store last error
}
$this->updateBackupHistory($dbServer, 'bundle', $message->status, $message->lastError);
break;
case "Scalr_Messaging_Msg_DbMsr_CreateBackupResult":
if ($message->status == "ok") {
Scalr_Db_Msr::onCreateBackupResult($message, $dbServer);
} else {
$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BACKUP_IS_RUNNING, 0, DBFarmRole::TYPE_LCL);
}
$this->updateBackupHistory($dbServer, 'backup', $message->status, $message->lastError);
break;
}
}
示例5: handleMessage
public function handleMessage(Scalr_Messaging_Msg $message, DBServer $dbServer)
{
parent::handleMessage($message, $dbServer);
if (!$message->chef) {
return;
}
switch (get_class($message)) {
case "Scalr_Messaging_Msg_HostUp":
$dbServer->SetProperty(self::SERVER_CHEF_NODENAME, $message->chef->nodeName);
break;
case "Scalr_Messaging_Msg_HostUpdate":
$dbServer->SetProperty(self::SERVER_CHEF_NODENAME, $message->chef->nodeName);
break;
}
}