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

第 8 章 DSDL 資源類型實施範例

本章說明了藉由 DSDL 實施的資源類型範例 SUNW.xfnts。此資料服務寫入 C 。基礎應用程式為 X 字型伺服器 (基於 TCP/IP 的服務)。

本章包含以下資訊:

X 字型伺服器

X 字型伺服器是一種基於 TCP/IP 的簡單服務,可為用戶端提供字型檔案。用戶端連接至伺服器要求字型集,伺服器便從磁碟中讀取字型檔案,然後將其提供給用戶端。X 字型伺服器常駐程式包含伺服器二進位檔 /usr/openwin/bin/xfs。常駐程式一般從 inetd 啟動,但對於目前的範例,假定了 /etc/inetd.conf 檔案中的相應項目已被停用 (例如,透過 fsadmin -d 指令),因此常駐程式僅受 Sun Cluster 控制。

X 字型伺服器配置檔案

依預設,X 字型伺服器從檔案 /usr/openwin/lib/X11/fontserver.cfg 中讀取它的配置資訊。此檔案中的目錄項目包含可用於該常駐程式提供服務的字型目錄清單。叢集管理員可以在全域檔案系統上找到字型目錄 (以透過維護該系統上字型資料庫的單一複本,來最佳化 X 字型伺服器在 Sun Cluster 上的使用)。如果如此,管理員必須編輯 fontserver.cfg,才能反映字型目錄的新路徑。

為便於配置,管理員也可以將配置檔案本身放置在全域檔案系統上。xfs 常駐程式提供指令行引數來置換此檔案的預設內建位置。SUNW.xfnts 資源類型使用以下指令來啟動 Sun Cluster 所控制的常駐程式。


/usr/openwin/bin/xfs -config <location_of_cfg_file>/fontserver.cfg \
-port <portnumber>

SUNW.xfnts 資源類型實作中,您可以使用 Confdir_list 特性來管理 fontserver.cfg 配置檔案的位置。

TCP 通訊埠編號

xfs 伺服器常駐程式偵聽的 TCP 通訊埠編號一般為「fs」通訊埠 (在 /etc/services 檔案中通常被定義為 7100)。不過,xfs 指令行上的 -port 選項可讓系統管理員置換預設設定值。您可以使用 SUNW.xfnts 資源類型中的 Port_list 特性來設定預設值和支援在 xfs 指令行上使用 -port 選項。在 RTR 檔案中,此特性的預設值定義為 7100/tcp。在 SUNW.xfnts Start 方法中,您會將 Port_list 傳送至 xfs 指令行上的 -port 選項。因此,不需要此資源類型的使用者指定埠號碼 — 埠預設為 7100/tcp — 但如果使用者願意,在配置資源類型時,他們完全可以透過為 Port_list 特性指定其他值來指定其他埠。

命名慣例

記住下列慣例,便可以識別各種範例程式碼片段。

SUNW.xfnts RTR 檔案

本節說明了 SUNW.xfnts RTR 檔案中的幾個主要特性。此節未說明該檔案中每個特性的用途。如需此類說明,請參閱設定資源特性和資源類型特性

Confdir_list 延伸特性識別配置目錄 (或目錄清單),如下所示。


{
        PROPERTY = Confdir_list;
        EXTENSION;
        STRINGARRAY;
        TUNABLE = AT_CREATION;
        DESCRIPTION = "The Configuration Directory Path(s)";
}

Confdir_list 特性不指定預設值。叢集管理員必須在建立資源時指定目錄。由於可調性受限於 AT_CREATION,因此以後無法變更該值。

Port_list 特性識別伺服器常駐程式偵聽的通訊埠,如下所示。


{
        PROPERTY = Port_list;
        DEFAULT = 7100/tcp;
        TUNABLE = AT_CREATION;
}

由於該特性宣告了預設值,因此,叢集管理員可以在建立資源時指定新值或接受此預設值。由於可調性受限於 AT_CREATION,因此以後無法變更該值。

scds_initialize() 函式

DSDL 要求每種回呼方法在其開始時均呼叫 scds_initialize(3HA) 函式。此函式執行下列作業︰

使用 scds_close() 函式,可回收 scds_initialize() 分配的資源。

xfnts_start 方法

當包含資料服務資源的資源群組在叢集節點上處於線上運作狀態或當啟用該資源時,RGM 將在該節點上呼叫 Start 方法。在 SUNW.xfnts 範例資源類型中,xfnts_start 方法可在該節點上啟動 xfs 常駐程式。

xfnts_start 方法呼叫 scds_pmf_start(),以在 PMF 下啟動此常駐程式。PMF 提供了自動故障通知與重新啟動功能,以及與故障監視器的整合。


注意 –

xfnts_start 的第一次呼叫是呼叫 scds_initialize(),它執行某些必需的事務性工作功能 (scds_initialize() 函式scds_initialize(3HA) 線上援助頁包含更多詳細資訊)。


啟動前驗證服務

在嘗試啟動 X 字型伺服器之前,xfnts_start 方法將呼叫 svc_validate(),以確認正確的配置已就緒來支援 xfs 常駐程式 (請參閱xfnts_validate 方法以取得詳細資訊),如下所示。


rc = svc_validate(scds_handle);
   if (rc != 0) {
      scds_syslog(LOG_ERR,
          "Failed to validate configuration.");
      return (rc);
   }

啟動服務

xfnts_start 方法呼叫在 xfnts.c 中定義的 svc_start() 方法來啟動 xfs 常駐程式。本節說明了 svc_start ()

用來啟動 xfs 常駐程式的指令如下所述。


xfs -config config_directory/fontserver.cfg -port port_number

Confdir_list 延伸特性識別 config_directory,而 Port_list 系統特性識別 port_number。當叢集管理員配置資料服務時,他會為這些特性提供特定值。

xfnts_start 方法將這些特性宣告為字串陣列,並使用 scds_get_ext_confdir_list()scds_get_port_list() 函式 (在 scds_property_functions(3HA) 中有說明) 取得管理員設定的值,如下所示。


scha_str_array_t *confdirs;
scds_port_list_t    *portlist;
scha_err_t   err;

   /* get the configuration directory from the confdir_list property */
   confdirs = scds_get_ext_confdir_list(scds_handle);

   (void) sprintf(xfnts_conf, "%s/fontserver.cfg", confdirs->str_array[0]);

   /* obtain the port to be used by XFS from the Port_list property */
   err = scds_get_port_list(scds_handle, &portlist);
   if (err != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Could not access property Port_list.");
      return (1);
   }

請注意,confdirs 變數指陣列的第一個元素 (0)。

xfnts_start 方法使用 sprintf 來產生 xfs 的指令行,如下所示。


/* Construct the command to start the xfs daemon. */
   (void) sprintf(cmd,
       "/usr/openwin/bin/xfs -config %s -port %d 2>/dev/null",
       xfnts_conf, portlist->ports[0].port);

請注意,他的輸出將重新導向至 dev/null,來抑制此常駐程式產生的訊息。

xfnts_start 方法將 xfs 指令行傳送至 scds_pmf_start(),以啟動 PMF 控制下的資料服務,如下所示。


scds_syslog(LOG_INFO, "Issuing a start request.");
   err = scds_pmf_start(scds_handle, SCDS_PMF_TYPE_SVC,
      SCDS_PMF_SINGLE_INSTANCE, cmd, -1);

   if (err == SCHA_ERR_NOERR) {
      scds_syslog(LOG_INFO,
          "Start command completed successfully.");
   } else {
      scds_syslog(LOG_ERR,
          "Failed to start HA-XFS ");
   }

請注意關於 scds_pmf_start() 呼叫的以下內容。

在傳回前,svc_pmf_start() 將釋放為 portlist 結構分配的記憶體空間,如下所示。


scds_free_port_list(portlist);
return (err);

svc_start() 傳回

即使 svc_start() 成功傳回,基礎應用程式也可能無法啟動。因此,svc_start() 必須探測應用程式,以驗證該應用程式在傳回成功訊息之前已在執行。此探測也必須考慮此應用程式可能不會立即可用,因為它要花些時間來啟動。svc_start() 方法將呼叫 svc_wait() (在 xfnts.c 中定義),以確認此應用程式正在執行,如下所示。


/* Wait for the service to start up fully */
   scds_syslog_debug(DBG_LEVEL_HIGH,
       "Calling svc_wait to verify that service has started.");

   rc = svc_wait(scds_handle);

   scds_syslog_debug(DBG_LEVEL_HIGH,
       "Returned from svc_wait");

   if (rc == 0) {
      scds_syslog(LOG_INFO, "Successfully started the service.");
   } else {
      scds_syslog(LOG_ERR, "Failed to start the service.");
   }

svc_wait() 函式呼叫 scds_get_netaddr_list(3HA),來取得探測此應用程式所需的網路位址資源,如下所示。


/* obtain the network resource to use for probing */
   if (scds_get_netaddr_list(scds_handle, &netaddr)) {
      scds_syslog(LOG_ERR,
          "No network address resources found in resource group.");
      return (1);
   }

   /* Return an error if there are no network resources */
   if (netaddr == NULL || netaddr->num_netaddrs == 0) {
      scds_syslog(LOG_ERR,
          "No network address resource in resource group.");
      return (1);
   }

然後,svc_wait() 便可取得 start_timeoutstop_timeout 值,如下所示。


svc_start_timeout = scds_get_rs_start_timeout(scds_handle)
   probe_timeout = scds_get_ext_probe_timeout(scds_handle)

若要說明伺服器可能需要的啟動時間,svc_wait() 將呼叫 scds_svc_wait(),並傳送相當於 start_timeout 值 3% 的逾時值。然後,svc_wait() 將呼叫 svc_probe(),以確認此應用程式已經啟動。svc_probe() 方法在指定通訊埠上建立與伺服器的簡單套接字連接。如果無法連接至該通訊埠,svc_probe() 將傳回值 100,指示發生完全故障。如果連接成功,但與該通訊埠斷開連接失敗,則 svc_probe() 將傳回值 50。

svc_probe() 失敗或部分失敗時,svc_wait() 將以逾時值 5 呼叫 scds_svc_wait()scds_svc_wait() 方法會將探測頻率限定為每五秒一次。此方法也將計算嘗試啟動服務的次數。如果嘗試次數在資源的 Retry_interval 特性所指定的時間內,超出該資源 Retry_count 特性的值,則 scds_svc_wait() 函式將傳回故障。在此情況下,svc_start() 函式也將傳回故障。


#define    SVC_CONNECT_TIMEOUT_PCT    95
#define    SVC_WAIT_PCT       3
   if (scds_svc_wait(scds_handle, (svc_start_timeout * SVC_WAIT_PCT)/100)
      != SCHA_ERR_NOERR) {

      scds_syslog(LOG_ERR, "Service failed to start.");
      return (1);
   }

   do {
      /*
       * probe the data service on the IP address of the
       * network resource and the portname
       */
      rc = svc_probe(scds_handle,
          netaddr->netaddrs[0].hostname,
          netaddr->netaddrs[0].port_proto.port, probe_timeout);
      if (rc == SCHA_ERR_NOERR) {
         /* Success. Free up resources and return */
         scds_free_netaddr_list(netaddr);
         return (0);
      }

       /* Call scds_svc_wait() so that if service fails too
      if (scds_svc_wait(scds_handle, SVC_WAIT_TIME)
         != SCHA_ERR_NOERR) {
         scds_syslog(LOG_ERR, "Service failed to start.");
         return (1);
      }

   /* Rely on RGM to timeout and terminate the program */
   } while (1);


注意 –

在結束之前,xfnts_start 方法將呼叫 scds_close() 以回收 scds_initialize() 分配的資源。請參閱scds_initialize() 函式scds_close(3HA) 線上援助頁,以取得詳細資訊。


xfnts_stop 方法

由於 xfnts_start 方法使用 scds_pmf_start() 來啟動 PMF 下的服務,因此 xfnts_stop 使用 scds_pmf_stop() 來停止此服務。


注意 –

xfnts_stop 的第一次呼叫是呼叫 scds_initialize(),它執行某些必需的事務性工作功能 (scds_initialize() 函式scds_initialize(3HA) 線上援助頁包含更多詳細資訊)。


xfnts_stop 方法呼叫 svc_stop() 方法 (在 xfnts.c 中定義),如下所示。


scds_syslog(LOG_ERR, "Issuing a stop request.");
   err = scds_pmf_stop(scds_handle,
       SCDS_PMF_TYPE_SVC, SCDS_PMF_SINGLE_INSTANCE, SIGTERM,
       scds_get_rs_stop_timeout(scds_handle));

   if (err != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to stop HA-XFS.");
      return (1);
   }

   scds_syslog(LOG_INFO,
       "Successfully stopped HA-XFS.");
   return (SCHA_ERR_NOERR); /* Successfully stopped */

請注意下列關於 svc_stop() 呼叫 scds_pmf_stop() 函式的內容。


注意 –

在結束之前,xfnts_stop 方法將呼叫 scds_close() 以回收 scds_initialize() 分配的資源。請參閱scds_initialize() 函式scds_close(3HA) 線上援助頁,以取得詳細資訊。


xfnts_monitor_start 方法

在一個節點上啟動資源後,RGM 將在該節點上呼叫 Monitor_start 方法以啟動故障監視器。xfnts_monitor_start 方法使用 scds_pmf_start() 來啟動 PMF 下的監視器常駐程式。


注意 –

xfnts_monitor_start 的第一次呼叫是呼叫 scds_initialize(),它執行某些必需的事務性工作功能 (scds_initialize() 函式scds_initialize(3HA) 線上援助頁包含更多詳細資訊)。


xfnts_monitor_start 方法呼叫 mon_start 方法 (在 xfnts.c 中定義),如下所示。


scds_syslog_debug(DBG_LEVEL_HIGH,
      "Calling Monitor_start method for resource <%s>.",
      scds_get_resource_name(scds_handle));

    /* Call scds_pmf_start and pass the name of the probe. */
   err = scds_pmf_start(scds_handle, SCDS_PMF_TYPE_MON,
       SCDS_PMF_SINGLE_INSTANCE, "xfnts_probe", 0);

   if (err != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to start fault monitor.");
      return (1);
   }

   scds_syslog(LOG_INFO,
       "Started the fault monitor.");

   return (SCHA_ERR_NOERR); /* Successfully started Monitor */
}

請注意下列關於 svc_mon_start() 呼叫 scds_pmf_start() 函式的內容。


注意 –

在結束之前,xfnts_monitor_start 方法將呼叫 scds_close() 以回收 scds_initialize() 分配的資源。請參閱scds_initialize() 函式scds_close(3HA) 線上說明手冊,以取得詳細資訊。


xfnts_monitor_stop 方法

由於 xfnts_monitor_start 方法使用 scds_pmf_start() 來啟動 PMF 下的監視器常駐程式,因此 xfnts_monitor_stop 使用 scds_pmf_stop() 來停止此監視器常駐程式。


注意 –

xfnts_monitor_stop 的第一次呼叫是呼叫 scds_initialize(),它執行某些必需的事務性工作功能 (scds_initialize() 函式scds_initialize(3HA) 線上援助頁包含更多詳細資訊)。


xfnts_monitor_stop() 方法呼叫 mon_stop 方法 (在 xfnts.c 中定義),如下所示。


scds_syslog_debug(DBG_LEVEL_HIGH,
      "Calling scds_pmf_stop method");

   err = scds_pmf_stop(scds_handle, SCDS_PMF_TYPE_MON,
       SCDS_PMF_SINGLE_INSTANCE, SIGKILL,
       scds_get_rs_monitor_stop_timeout(scds_handle));

   if (err != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to stop fault monitor.");
      return (1);
   }

   scds_syslog(LOG_INFO,
       "Stopped the fault monitor.");

   return (SCHA_ERR_NOERR); /* Successfully stopped monitor */
}

請注意下列關於 svc_mon_stop() 呼叫 scds_pmf_stop() 函式的內容。


注意 –

在結束之前,xfnts_monitor_stop 方法將呼叫scds_close() 以回收 scds_initialize() 分配的資源。請參閱scds_initialize() 函式scds_close(3HA) 線上說明手冊,以取得詳細資訊。


xfnts_monitor_check 方法

每當故障監視器嘗試將包含資源的資源群組之故障轉移至其他節點時,RGM 均將呼叫 Monitor_check 方法。xfnts_monitor_check 方法呼叫 svc_validate() 方法,以確認正確配置已就緒可支援 xfs 常駐程式 (請參閱xfnts_validate 方法以取得詳細資訊)。xfnts_monitor_check 的程式碼如下所示。


   /* Process the arguments passed by RGM and initialize syslog */
   if (scds_initialize(&scds_handle, argc, argv) != SCHA_ERR_NOERR)
{
      scds_syslog(LOG_ERR, "Failed to initialize the handle.");
      return (1);
   }

   rc =  svc_validate(scds_handle);
   scds_syslog_debug(DBG_LEVEL_HIGH,
       "monitor_check method "
       "was called and returned <%d>.", rc);

   /* Free up all the memory allocated by scds_initialize */
   scds_close(&scds_handle);

   /* Return the result of validate method run as part of monitor check */
   return (rc);
}

SUNW.xfnts 故障監視器

在一個節點上啟動資源後,RGM 將不直接呼叫 PROBE 方法,而是呼叫 Monitor_start 方法來啟動監視器。xfnts_monitor_start 方法啟動 PMF 控制下的故障監視器。xfnts_monitor_stop 方法停止該故障監視器。

SUNW.xfnts 故障監視器執行下列作業︰

xfonts_probe 主迴圈

xfonts_probe 方法實施迴圈。在實施迴圈之前,xfonts_probe

xfnts_probe 方法實施迴圈,如下所示。


for (ip = 0; ip < netaddr->num_netaddrs; ip++) {
         /*
          * Grab the hostname and port on which the
          * health has to be monitored.
          */
         hostname = netaddr->netaddrs[ip].hostname;
         port = netaddr->netaddrs[ip].port_proto.port;
         /*
          * HA-XFS supports only one port and
          * hence obtain the port value from the
          * first entry in the array of ports.
          */
         ht1 = gethrtime(); /* Latch probe start time */
         scds_syslog(LOG_INFO, "Probing the service on port: %d.", port);

         probe_result =
         svc_probe(scds_handle, hostname, port, timeout);

         /*
          * Update service probe history,
          * take action if necessary.
          * Latch probe end time.
          */
         ht2 = gethrtime();

         /* Convert to milliseconds */
         dt = (ulong_t)((ht2 - ht1) / 1e6);

         /*
          * Compute failure history and take
          * action if needed
          */
         (void) scds_fm_action(scds_handle,
             probe_result, (long)dt);
      }   /* Each net resource */
   }    /* Keep probing forever */

svc_probe() 函式實施探測邏輯。來自 svc_probe() 的傳回值被傳送至 scds_fm_action(),該值將決定是否重新啟動應用程式,對資源群組進行故障轉移,或者不執行任何作業。

svc_probe() 函式

svc_probe() 函式透過呼叫scds_fm_tcp_connect(),建立與指定通訊埠的簡單套接字連接。如果連接失敗,svc_probe() 將傳回值 100,指示發生完全故障。如果連接成功但斷開連接失敗,svc_probe() 將傳回值 50,指示發生部分故障。如果連接與斷開連接均成功,svc_probe() 將傳回值 0,指示成功。

svc_probe() 的程式碼如下所示。


int svc_probe(scds_handle_t scds_handle,
char *hostname, int port, int timeout)
{
   int  rc;
   hrtime_t   t1, t2;
   int    sock;
   char   testcmd[2048];
   int    time_used, time_remaining;
   time_t      connect_timeout;


   /*
    * probe the data service by doing a socket connection to the port */
    * specified in the port_list property to the host that is
    * serving the XFS data service. If the XFS service which is configured
    * to listen on the specified port, replies to the connection, then
    * the probe is successful. Else we will wait for a time period set
    * in probe_timeout property before concluding that the probe failed.
    */

   /*
    * Use the SVC_CONNECT_TIMEOUT_PCT percentage of timeout
    * to connect to the port
    */
   connect_timeout = (SVC_CONNECT_TIMEOUT_PCT * timeout)/100;
   t1 = (hrtime_t)(gethrtime()/1E9);

   /*
    * the probe makes a connection to the specified hostname and port.
    * The connection is timed for 95% of the actual probe_timeout.
    */
   rc = scds_fm_tcp_connect(scds_handle, &sock, hostname, port,
       connect_timeout);
   if (rc) {
      scds_syslog(LOG_ERR,
          "Failed to connect to port <%d> of resource <%s>.",
          port, scds_get_resource_name(scds_handle));
      /* this is a complete failure */
      return (SCDS_PROBE_COMPLETE_FAILURE);
   }

   t2 = (hrtime_t)(gethrtime()/1E9);

   /*
    * Compute the actual time it took to connect. This should be less than
    * or equal to connect_timeout, the time allocated to connect.
    * If the connect uses all the time that is allocated for it,
    * then the remaining value from the probe_timeout that is passed to
    * this function will be used as disconnect timeout. Otherwise, the
    * the remaining time from the connect call will also be added to
    * the disconnect timeout.
    *
    */

   time_used = (int)(t2 - t1);

   /*
    * Use the remaining time(timeout - time_took_to_connect) to disconnect
    */

   time_remaining = timeout - (int)time_used;

   /*
    * If all the time is used up, use a small hardcoded timeout
    * to still try to disconnect. This will avoid the fd leak.
    */
   if (time_remaining <= 0) {
      scds_syslog_debug(DBG_LEVEL_LOW,
          "svc_probe used entire timeout of "
          "%d seconds during connect operation and exceeded the "
          "timeout by %d seconds. Attempting disconnect with timeout"
          " %d ",
          connect_timeout,
          abs(time_used),
          SVC_DISCONNECT_TIMEOUT_SECONDS);

      time_remaining = SVC_DISCONNECT_TIMEOUT_SECONDS;
   }

   /*
    * Return partial failure in case of disconnection failure.
    * Reason: The connect call is successful, which means
    * the application is alive. A disconnection failure
    * could happen due to a hung application or heavy load.
    * If it is the later case, don't declare the application
    * as dead by returning complete failure. Instead, declare
    * it as partial failure. If this situation persists, the
    * disconnect call will fail again and the application will be
    * restarted.
    */
   rc = scds_fm_tcp_disconnect(scds_handle, sock, time_remaining);
   if (rc != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to disconnect to port %d of resource %s.",
          port, scds_get_resource_name(scds_handle));
      /* this is a partial failure */
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }

   t2 = (hrtime_t)(gethrtime()/1E9);
   time_used = (int)(t2 - t1);
   time_remaining = timeout - time_used;

   /*
    * If there is no time left, don't do the full test with
    * fsinfo. Return SCDS_PROBE_COMPLETE_FAILURE/2
    * instead. This will make sure that if this timeout
    * persists, server will be restarted.
    */
   if (time_remaining <= 0) {
      scds_syslog(LOG_ERR, "Probe timed out.");
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }

   /*
    * The connection and disconnection to port is successful,
    * Run the fsinfo command to perform a full check of
    * server health.
    * Redirect stdout, otherwise the output from fsinfo
    * ends up on the console.
    */
   (void) sprintf(testcmd,
       "/usr/openwin/bin/fsinfo -server %s:%d > /dev/null",
       hostname, port);
   scds_syslog_debug(DBG_LEVEL_HIGH,
       "Checking the server status with %s.", testcmd);
   if (scds_timerun(scds_handle, testcmd, time_remaining,
      SIGKILL, &rc) != SCHA_ERR_NOERR || rc != 0) {

      scds_syslog(LOG_ERR,
         "Failed to check server status with command <%s>",
         testcmd);
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }
   return (0);
}

完成後,svc_probe() 將傳回成功值 (0)、部分故障值 (50) 或完全故障值 (100)。xfnts_probe 方法將此值傳送至 scds_fm_action()

決定故障監視器的動作

xfnts_probe 方法呼叫 scds_fm_action() 來決定要執行的動作。scds_fm_action() 的邏輯如下所示︰

例如,假定探測連接至 xfs 伺服器,但無法斷開連接。這指示該伺服器正在執行,但可能掛起或恰好在進行暫時載入。斷開連接的故障將部分 (50) 故障發送至 scds_fm_action()。此值低於重新啟動資料服務的臨界值,但該值保留在故障歷史中。

如果在下一次探測期間,伺服器仍無法結束連線,則值 50 將被新增至 scds_fm_action() 維護的故障歷史中。累計故障值現在為 100,因此 scds_fm_action() 將重新啟動資料服務。

xfnts_validate 方法

當建立資源時,以及當管理動作更新該資源或其包含群組的特性時,RGM 將呼叫 Validate 方法。在套用建立或更新之前,RGM 將呼叫 Validate,並且在任何節點上此方法的故障退出碼將導致取消建立或更新。

僅當透過管理動作變更資源或群組特性時,RGM 才會呼叫 Validate,而在 RGM 設定特性或監視器設定資源特性 StatusStatus_msg 時,RGM 不會呼叫該方法。


注意 –

每當 PROBE 方法嘗試將資料服務之故障轉移至新節點時,Monitor_check 方法都將明確地呼叫 Validate 方法。


RGM 藉由傳送至其他方法的引數以及其他引數 (包括正在更新的特性與值),來呼叫 Validatexfnts_validate 開始時呼叫 scds_initialize() 會剖析 RGM 傳送至 xfnts_validate 的所有引數,並在 scds_handle 參數中儲存資訊。xfnts_validate 呼叫的子常式將利用此資訊。

xfnts_validate 方法呼叫可確認下列內容的 svc_validate()

在傳回之前,svc_validate() 將釋放所有分配的資源。


finished:
   scds_free_net_list(snrlp);
   scds_free_port_list(portlist);

   return (rc); /* return result of validation */


注意 –

在結束之前,xfnts_validate 方法將呼叫 scds_close() 以回收 scds_initialize() 分配的資源。請參閱scds_initialize() 函式scds_close(3HA) 線上說明手冊,以取得詳細資訊。


xfnts_update 方法

RGM 呼叫 Update 方法來通知執行中資源其特性已經變更。可以為 xfnts 資料服務變更的唯一特性關係到故障監視器。因此,每當變更特性時,xfnts_update 方法都將呼叫 scds_pmf_restart_fm() 來重新啟動故障監視器。


* check if the Fault monitor is already running and if so stop
   * and restart it. The second parameter to scds_pmf_restart_fm()
   * uniquely identifies the instance of the fault monitor that needs
   * to be restarted.
   */

   scds_syslog(LOG_INFO, "Restarting the fault monitor.");
   result = scds_pmf_restart_fm(scds_handle, 0);
   if (result != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to restart fault monitor.");
      /* Free up all the memory allocated by scds_initialize */
      scds_close(&scds_handle);
      return (1);
   }

   scds_syslog(LOG_INFO,
   "Completed successfully.");


注意 –

scds_pmf_restart_fm() 的第二個參數唯一識別要重新啟動的故障監視器實例 (如果有多個實例)。範例中的值 0 指示僅有一個故障監視器實例。