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

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) 설명서 페이지를 참조하십시오.