switchover API 関数を使用すると、スイッチオーバー操作を実行できます。
フル システムのハイ アベイラビリティ シナリオで、任意のレプリカ サーバへのスイッチオーバー操作を実行できます。 非フェールオーバー レプリカ サーバにスイッチオーバーする場合、スイッチオーバー API を呼び出す前に、execute_action API を呼び出します。
注: execute_action API は、例で記述されています。
引数
switchover API 関数には、以下のテーブルに記述されている引数が含まれています。
名前 |
タイプ |
説明 |
---|---|---|
session_id |
uint |
create_session API をコールすることで返されたセッション ID。 |
scenario_id |
uint |
スイッチオーバー操作を実行するシナリオ ID。 |
execute_sync |
bool |
この API を同期または非同期でコールするかどうかを指定します。 |
run_reverse_scenario |
bool |
スイッチオーバー操作が発生した後に、バックワード シナリオを実行または実行しません。 |
err_message |
out string |
この API が失敗する時に、その失敗の理由が含まれます。 |
戻り値
戻り値のタイプはブールです。 戻り値が true の場合、API は正常に完了しています。 戻り値が false の場合、API は正常に完了しませんでした。 戻り値が false の場合は、メッセージを確認して API が失敗した理由を特定してください。
例
例 1
public bool switchover_example() { try { uint scenario_id = _ha_scenario_id; string err_messages = ""; bool execute_sync = true; bool run_reverse_scenario = false; return get_mng().switchover(_session_id, scenario_id, execute_sync, run_reverse_scenario, out err_messages); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } return false; }
例 2
public bool switchover_2nd_example() { try { set_xcmd_data("switchover", "switchover_index","3" ); uint scenario_id = _ha_scenario_id; string err_messages = ""; bool execute_sync = true; bool run_reverse_scenario = false; return get_mng().switchover(_session_id, scenario_id, execute_sync, run_reverse_scenario, out err_messages); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } return false; }
例 3
デフォルトでは、Replication and High Availability は、事前定義済みのフェールオーバ、レプリカ サーバへのスイッチオーバー操作を実行します。 フル システムのハイ アベイラビリティ シナリオで、非フェールオーバ レプリカ サーバへのスイッチオーバーを実行できます。 ただし、スイッチオーバー API を使用して、非フェールオーバ サーバにスイッチオーバーする場合は、以下の例に示すように、スイッチオーバー API を呼び出す前に、execute_action API を呼び出します。
set_xcmd_data("switchover", "switchover_index","3" ); public bool set_xcmd_data(string cmd_name_str,string cmd_data_str,string cmd_value_str) { try { string result_data = ""; string action_data; XmlDocument doc = new XmlDocument(); XmlNode actions = doc.CreateNode(XmlNodeType.Element, xomngapi.WANSync_c.xo_actions, ""); XmlNode commonNode = doc.CreateNode(XmlNodeType.Element, xomngapi.WANSync_c.action_common_lab, ""); XmlAttribute attrSession = doc.CreateAttribute(xomngapi.WANSync_c.action_com_session_id); XmlAttribute attrScenario = doc.CreateAttribute(xomngapi.WANSync_c.action_com_scenario_id); XmlAttribute attrHostindex = doc.CreateAttribute(xomngapi.WANSync_c.action_com_host_index); XmlAttribute attrUsedfor = doc.CreateAttribute(xomngapi.WANSync_c.action_used_for); attrSession.Value = xomngapi.WANSync_c.WANSync.session_id.ToString(); attrScenario.Value = this.id.ToString(); attrUsedfor.Value = xomngapi.WANSync_c.action_x_command_data; commonNode.Attributes.Append(attrSession); commonNode.Attributes.Append(attrScenario); commonNode.Attributes.Append(attrHostindex); commonNode.Attributes.Append(attrUsedfor); XmlNode xo_cmd = doc.CreateNode(XmlNodeType.Element, xomngapi.WANSync_c.xo_cmd, ""); XmlAttribute cmd_name = doc.CreateAttribute(xomngapi.WANSync_c.action_cmd_name); XmlAttribute cmd_data = doc.CreateAttribute(xomngapi.WANSync_c.action_cmd_data); XmlAttribute cmd_value = doc.CreateAttribute(xomngapi.WANSync_c.action_cmd_value); cmd_name.Value = cmd_name_str; cmd_data.Value = cmd_data_str; cmd_value.Value = cmd_value_str; xo_cmd.Attributes.Append(cmd_name); xo_cmd.Attributes.Append(cmd_data); xo_cmd.Attributes.Append(cmd_value); actions.AppendChild(commonNode); commonNode.AppendChild(xo_cmd); doc.AppendChild(actions); action_data = doc.OuterXml; string error; return get_mng().execute_action(action_data, true, out result_data, out error); } catch (System.Exception) { return false; }
Copyright © 2015 Arcserve.
All rights reserved.
|
|