Once the resource is online, the Resource Monitor polls the resource periodically to determine its status. The Resource Monitor uses the LooksAlive and IsAlive entry point functions to accomplish this.
The IsAlive entry point function is used for more thorough resource status evaluation and is regularly polled by the Resource Monitor at a rate governed by the IsAlivePollInterval property. Unlike LooksAlive polling, IsAlive polling cannot be turned off.
To implement IsAlive
Required: Perform a complete check of the resource to see if it is functioning properly. The set of procedures you need to use depends on your resource. For example, a database resource should check to see that the database can write to the disk, perform queries and updates to the disk, and so forth.
Required: If the resource has definitely failed, return FALSE. The Resource Monitor immediately sets the status of the resource to ClusterResourceFailed, an enumerator from the CLUSTER_RESOURCE_STATE enumeration, and calls the Terminate entry point function.
Recommended: Take no more than 300 milliseconds to complete; ideally, it should finish in less than 50 milliseconds. However, if your implementation must take longer than 300 milliseconds, perform the following steps:
- Have a separate thread dedicated to perform the polling operation.
- Return the result of the last poll performed by the separate thread.
When using separate threads to check the health of resources, take steps to ensure synchronization. For example, you might maintain a monitor thread that is independent of the IsAlive thread. The two threads could share a common data block, synchronized through a critical section, that contains the last reported status. If the monitor thread detects a failure, it tries to correct it. If that fails, it updates the status in the block. The next time IsAlive runs, it sees an error status and takes appropriate action.