Solaris OS용 Sun Cluster 데이터 서비스 개발 안내서

8장 샘플 DSDL 자원 유형 구현

이 장에서는 DSDL(Data Service Development Library)을 사용하여 구현되는 샘플 자원 유형 SUNW.xfnts에 대해 설명합니다. 이 데이터 서비스는 C로 작성되며 기본 응용 프로그램은 TCP/IP 기반 서비스인 X Font Server입니다. 부록 C, DSDL 샘플 자원 유형 코드 목록에는 SUNW.xfnts 자원 유형의 각 메소드에 대한 전체 코드가 나와 있습니다.

이 장은 다음 내용으로 구성되어 있습니다.

X Font Server

X Font Server는 클라이언트에 글꼴 파일을 제공하는 TCP/IP 기반 서비스입니다. 클라이언트는 글꼴 집합을 요청하기 위해 서버에 연결하며 서버는 디스크에서 글꼴 파일을 읽어 클라이언트에 제공합니다. X Font Server 데몬은 /usr/openwin/bin/xfs에 있는 서버 이진으로 구성됩니다. 데몬은 대개 inetd에서 시작됩니다. 그러나 현재 샘플의 경우 /etc/inetd.conf 파일에서 해당 항목이 fsadmin -d 명령 등에 의해 비활성화되어 데몬이 Sun Cluster 소프트웨어의 제어만 받는 것으로 가정합니다.

X Font Server 구성 파일

기본적으로 X Font Server는 /usr/openwin/lib/X11/fontserver.cfg 파일에서 구성 정보를 읽습니다. 이 파일의 카탈로그 항목에는 데몬에서 제공할 수 있는 글꼴 디렉토리 목록이 포함되어 있습니다. 클러스터 관리자는 클러스터 파일 시스템에서 글꼴 디렉토리를 찾을 수 있습니다. 이 위치는 시스템에서 글꼴 데이터베이스의 단일 복사본을 유지 관리하여 Sun Cluster에서의 X Font Server 사용을 최적화합니다. 클러스터 관리자가 이 위치를 변경하려면 글꼴 데이터베이스의 새 경로에 따라 fontserver.cfg를 편집해야 합니다.

클러스터 관리자는 또한 구성이 용이하도록 구성 파일 자체를 클러스터 파일 시스템에 저장할 수 있습니다. xfs 데몬은 이 파일의 기본 제공 위치를 무시하는 명령줄 인자를 제공합니다. SUNW.xfnts 자원 유형은 다음 명령을 사용하여 Sun Cluster 소프트웨어의 제어 하에서 데몬을 시작합니다.

/usr/openwin/bin/xfs -config location-of-configuration-file/fontserver.cfg \
-port port-number

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_listxfs 명령줄의 -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 = ANYTIME;
}

이 등록 정보에서 기본값을 선언하므로 클러스터 관리자는 자원을 만들 때 새 값을 지정할지 아니면 기본값을 그대로 사용할지 선택할 수 있습니다. 조정 기능이 AT_CREATION으로 제한되므로 이 값은 나중에 변경할 수 없습니다.

함수 및 콜백 메소드의 이름 지정 규칙

다음 규칙을 알면 다양한 샘플 코드를 식별할 수 있습니다.

scds_initialize() 함수

DSDL은 각 콜백 메소드가 메소드의 시작 부분에서 scds_initialize() 함수를 호출할 것을 요구합니다. 이 함수는 다음 작업을 수행합니다.

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 Font Server 시작 전 서비스 검증

xfnts_start 메소드는 X Font Server를 시작하기 전에 다음과 같이 svc_validate()를 호출하여 xfs 데몬을 지원하기 위한 적절한 구성이 있는지 확인합니다.

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

자세한 내용은 xfnts_validate 메소드를 참조하십시오.

svc_start()를 사용하여 서비스 시작

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() 메소드는 다음과 같이 xfnts.c 파일에 정의된 svc_wait()를 호출하여 응용 프로그램이 실행 중인지 확인합니다.

/* 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()를 호출하여 응용 프로그램을 검사하는 데 필요한 네트워크 주소 자원을 얻습니다.

/* 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() 메소드는 검사 빈도를 5초 간격으로 제한합니다. 또한 이 메소드는 서비스 시작을 시도한 횟수를 계산합니다. 시도 횟수가 자원의 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_stopscds_pmf_stop()을 사용하여 서비스를 중지합니다.


주 –

xfnts_stop에서 첫 번째 호출은 몇 가지 필수 관리 작업 기능을 수행하는 scds_initialize()입니다. 자세한 내용은 scds_initialize() 함수scds_initialize(3HA) 설명서 페이지를 참조하십시오.


xfnts_stop 메소드는 다음과 같이 xfnts.c 파일에 정의된 svc_stop() 메소드를 호출합니다.

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 메소드는 다음과 같이 xfnts.c 파일에 정의된 mon_start 메소드를 호출합니다.

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_stopscds_pmf_stop()을 사용하여 모니터 데몬을 중지합니다.


주 –

xfnts_monitor_stop에서 첫 번째 호출은 몇 가지 필수 관리 작업 기능을 수행하는 scds_initialize()입니다. 자세한 내용은 scds_initialize() 함수scds_initialize(3HA) 설명서 페이지를 참조하십시오.


xfnts_monitor_stop 메소드는 다음과 같이 xfnts.c 파일에 정의된 mon_stop() 메소드를 호출합니다.

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 서버에 연결을 설정하지만 연결을 끊는 데 실패한다고 가정합니다. 이는 서버가 실행 중이지만 정지되거나 일시적으로 로드 상태가 될 수 있음을 나타냅니다. 연결을 끊는 데 실패하면 scds_fm_action()으로 부분적 실패 값( 50)을 보냅니다. 이 값은 데이터 서비스를 재시작하기 위한 임계값보다 작지만 실패 기록에서 유지 관리됩니다.

다음 검사 중에 서버가 연결 끊기에 다시 실패하면 scds_fm_action()에서 유지 관리하는 실패 기록에 값 50이 추가됩니다. 이제 누적 실패 값이 100이므로 scds_fm_action()이 데이터 서비스를 재시작합니다.

xfnts_validate 메소드

자원을 만들 때 및 클러스터 관리자가 자원이나 자원을 포함한 그룹의 등록 정보를 업데이트할 때 RGM은 Validate 메소드를 호출합니다. RGM은 만들기나 업데이트가 적용되기 전에 Validate를 호출하며 임의의 노드에서 이 메소드가 실패 종료 코드를 반환할 경우 만들기 또는 업데이트가 취소됩니다.

RGM은 클러스터 관리자가 자원 또는 자원 그룹 등록 정보를 변경하거나 모니터가 StatusStatus_msg 자원 등록 정보를 설정하는 경우에만 Validate를 호출합니다. RGM에서 등록 정보를 설정하는 경우에는 Validate를 호출하지 않습니다.


주 –

Monitor_check 메소드는 PROBE 메소드가 데이터 서비스를 새 노드로 페일오버할 때마다 Validate 메소드를 명시적으로 호출합니다.


RGM은 업데이트 중인 등록 정보와 값을 포함하여 다른 메소드로 전달되는 항목에 대한 추가 인자와 함께 Validate를 호출합니다. xfnts_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은 오류 모니터의 인스턴스가 한 개밖에 없음을 나타냅니다.