Sun Cluster 資料服務開發者指南 (適用於 Solaris 作業系統)

Monitor_check 方法如何工作

每當 PROBE 方法嘗試將含有資料服務的資源群組容錯移轉至新節點時,RGM 均會呼叫 Monitor_check 方法。

本小節說明應用程式範例之 Monitor_check 方法的主要部分。本小節並不說明所有回呼方法的共用功能性,例如 parse_args() 函數。本小節也不說明如何使用 syslog() 函數。為所有方法提供共用功能性說明共用功能性。

如需 Monitor_check 方法的完整清單,請參閱Monitor_start 方法程式碼清單

必須實作 Monitor_check 方法,這樣其才不會與同步運作的其他方法發生衝突。

Monitor_check 方法呼叫 Validate 方法以驗證 DNS 配置目錄在新節點上是否可用。Confdir 延伸特性指向 DNS 配置目錄。因此,Monitor_check 獲取 Validate 方法的路徑和名稱以及 Confdir 的值。它將傳送此值至 Validate,如以下清單所示。

# Obtain the full path for the Validate method from
# the RT_basedir property of the resource type.
RT_BASEDIR=`scha_resource_get -O RT_basedir -R $RESOURCE_NAME \
   -G $RESOURCEGROUP_NAM?

# Obtain the name of the Validate method for this resource.
VALIDATE_METHOD=`scha_resource_get -O Validate \
   -R $RESOURCE_NAME -G $RESOURCEGROUP_NAM?

# Obtain the value of the Confdir property in order to start the
# data service. Use the resource name and the resource group entered to
# obtain the Confdir value set at the time of adding the resource.
config_info=`scha_resource_get -O Extension -R $RESOURCE_NAME \
 -G $RESOURCEGROUP_NAME Confdir`

# scha_resource_get returns the type as well as the value for extension
# properties. Use awk to get only the value of the extension property.
CONFIG_DIR=`echo $config_info | awk `{print $2}'`

# Call the validate method so that the dataservice can be failed over
# successfully to the new node.
$RT_BASEDIR/$VALIDATE_METHOD -R $RESOURCE_NAME -G $RESOURCEGROUP_NAME \
   -T $RESOURCETYPE_NAME -x Confdir=$CONFIG_DIR

請參閱Validate 方法如何工作,以瞭解應用程式範例如何驗證節點是否適合於執行資料服務。