RGM은 노드에서 자원이 시작된 후에 PROBE 메소드를 직접 호출하지 않고 Monitor_start 메소드를 호출하여 모니터를 시작합니다. xfnts_monitor_start 메소드는 PMF의 제어 하에서 오류 모니터를 시작합니다. xfnts_monitor_stop 메소드는 오류 모니터를 중지합니다.
SUNW.xfnts 오류 모니터는 다음 작업을 수행합니다.
xfs와 같은 간단한 TCP 기반 서비스를 검사하도록 특수하게 설계된 유틸리티를 사용하여 xfs 서버 데몬의 상태를 정기적으로 모니터합니다.
Retry_count 및 Retry_interval 등록 정보를 사용하여 시간 창 내에서 응용 프로그램에 발생하는 문제를 추적하고 완전한 응용 프로그램 실패가 발생할 경우 데이터 서비스를 다시 시작할지 아니면 페일오버할지 결정합니다. scds_fm_action() 및 scds_fm_sleep() 함수는 이 추적 및 결정 기법을 기본적으로 지원합니다.
scds_fm_action()을 사용하여 페일오버 또는 재시작 결정을 구현합니다.
자원 상태를 업데이트하여 관리 도구 및 그래픽 사용자 인터페이스에서 사용할 수 있게 만듭니다.
xfonts_probe 메소드는 루프를 구현합니다. 루프를 구현하기 전에 xfonts_probe는 다음 작업을 수행합니다.
다음과 같이 xfnts 자원의 네트워크 주소 자원을 검색합니다.
/* Get the ip addresses available for this resource */
if (scds_get_netaddr_list(scds_handle, &netaddr)) {
scds_syslog(LOG_ERR,
"No network address resource in resource group.");
scds_close(&scds_handle);
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);
}
scds_fm_sleep()을 호출하고 Thorough_probe_interval 값을 시간 초과값으로 전달합니다. 검사는 Thorough_probe_interval 값 동안 검사 작업 사이에 일시 정지합니다.
timeout = scds_get_ext_probe_timeout(scds_handle);
for (;;) {
/*
* sleep for a duration of thorough_probe_interval between
* successive probes.
*/
(void) scds_fm_sleep(scds_handle,
scds_get_rs_thorough_probe_interval(scds_handle));
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() 함수는 검사 논리를 구현합니다. 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()의 논리는 다음과 같습니다.
Retry_interval 등록 정보에 지정된 시간 내에서 누적 실패 기록을 유지 관리합니다.
누적 실패가 100 (완전한 실패)에 도달할 경우 데이터 서비스를 다시 시작합니다. Retry_interval을 초과하면 기록을 재설정합니다.
재시작 횟수가 Retry_interval에 지정된 시간 내에서 Retry_count 등록 정보 값을 초과할 경우 데이터 서비스를 페일오버합니다.
예를 들어, 검사가 xfs 서버에 연결을 설정하지만 연결을 끊는 데 실패한다고 가정합니다. 이는 서버가 실행 중이지만 정지되거나 일시적으로 로드 상태가 될 수 있음을 나타냅니다. 연결을 끊는 데 실패하면 scds_fm_action()에 부분적 실패 값(50)이 보내집니다. 이 값은 데이터 서비스를 재시작하기 위한 임계값보다 작지만 실패 기록에서 유지 관리됩니다.
다음 검사 중에 서버가 연결 끊기에 다시 실패하면 scds_fm_action()에서 유지 관리하는 실패 기록에 값 50이 추가됩니다. 이제 누적 실패 값이 100이므로 scds_fm_action()은 데이터 서비스를 다시 시작합니다.