Here is my review/modifications to sam_overview.8.

Can you make these into a proper patch?

Regards
-steve

On Wed, 2009-11-25 at 17:45 +0100, Jan Friesse wrote:
> Attached are man pages for SAM. Are written in Czechlish, so any native
> English speaker review/correction (basically englishification) is highly
> welcomed.
> 
> Regards,
>   Honza
> 
> plain text document attachment (sam_finalize.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_finalize \- Terminate SAM service
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_finalize (void);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_finalize\fR function is used to terminate SAM API. Once the 
> connection is finalized,
> the SAM may not be used again by application. Whole functionality (health 
> checking) will be
> stopped and after application fail, recovery action will not be taken.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> library was not initialized by \fBsam_init(3)\fR function or was finished 
> already.
> 
> .SH "SEE ALSO"
> .BR sam_initialize (3)
> plain text document attachment (sam_hc_callback_register.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_hc_callback_register \- Register health check callback
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_hc_callback_register (sam_hc_callback_t cb);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_hc_callback_register\fR function is used to register health 
> checking callback.
> After call of this function with cb set something else then NULL, SAM is 
> switched from application
> driven health checking to event driven health checking. So it's not longer 
> needed to call
> \fBsam_hc_send(3)\fR function.
> 
> .P
> Argument \fIcb\fR is callback function of type \fIsam_hc_callback_t\fR 
> defined as:
> 
> .nf
>   typedef int (*sam_hc_callback_t)(void);
> .fi
> 
> .P
> This function will be regulargly called and must return 0, if health of your 
> application is
> correct, or different value, in case you want take recovery action. Actually, 
> function must end
> it's processing before \fItime_interval\fR otherwise recovery action will be 
> taken. If health checking
> need more time, it is possible to send health checking confirmation by 
> calling \fBsam_hc_send(3)\fR function.
> 
> .P
> If it is needed to switch back to application driven health checking, it's 
> possible to set
> \fIcb\fR to NULL.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> SAM was not initialized and registered or health checking is in running state
> .TP
> CS_ERR_LIBRARY
> internal library call failed. This can be one of pipe creation or fork. It's 
> possible to get more information
> (system) from errno.
> 
> .SH "SEE ALSO"
> .BR sam_start (3),
> .BR sam_stop (3),
> .BR sam_hc_send (3),
> .BR sam_register (3),
> plain text document attachment (sam_hc_send.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_hc_send \- Send health check confirmation
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_hc_send (void);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_hc_send\fR function is used to send health check confirmation of 
> application.
> This function should be called regularly in application driven health 
> checking, otherwise
> recovery action will be taken. There is no need to call this in case of event 
> driven
> health checking.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> health checking is not in running state (no call of \fBsam_start(3)\fR) or 
> function is called after
> stop/finalization of health checking/service.
> 
> .SH "SEE ALSO"
> .BR sam_start (3),
> .BR sam_stop (3),
> .BR sam_hc_callback_register (3)
> plain text document attachment (sam_initialize.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_initialize \- Initialize health checking
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_initialize (uint64_t\fR \fItime_interval\fR\fB, 
> sam_recovery_policy_t \fIrecovery_policy\fR);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_initialize\fR function is used to initialize health checking of 
> application.
> 
> .P
> Application can have only one instance of SAM. This function must be called 
> before any other
> of SAM functions. It's recommended to call it as one of first in whole 
> application.
> 
> .P
> The \fItime_interval\fR parameter is number of microseconds, in which health 
> check must be send, otherwise
> recovery action will be taken. Value can be zero, and then there is no time 
> limit (you don't need to
> send any health check), but end of application is monitored and recovery 
> action is taken then.
> 
> .P
> The \fIrecovery_policy\fR is defined as type:
> 
> .nf
>   typedef enum {
>       SAM_RECOVERY_POLICY_QUIT = 1,
>       SAM_RECOVERY_POLICY_RESTART = 2,
>   } sam_recovery_policy_t;
> .fi
> 
> .P
> where
> 
> .TP
> SAM_RECOVERY_POLICY_QUIT
> means, that application will be just killed on fail.
> .TP
> SAM_RECOVERY_POLICY_RESTART
> application will be restarted on fail.
> 
> .P
> To perform real health checking \fBsam_register(3)\fR and \fBsam_start(3)\fR 
> function must called.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> can happened in case of double initialization
> .TP
> CS_ERR_INVALID_PARAM
> \fIrecovery_policy\fR has bad value
> 
> .SH "SEE ALSO"
> .BR sam_register (3),
> .BR sam_start (3),
> .BR sam_hc_callback_register (3)
> plain text document attachment (sam_overview.8)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 8 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_overview finalize \- Terminate SAM service
> 
> .SH OVERVIEW
> .P
> The SAM library provide a generic tool for local health checking of 
> application.
> It support many features, including:
> 
> .RS
> .IP \(bu 3
> Adjustable recovery policy
> .IP \(bu 3
> Adjusteble time interval of health checking
> .IP \(bu 3
> Warning before actual recovery action will taken
> .IP \(bu 3
> Ability to get currect id of running instance (\fIreincarnation_id\fR)
> .IP \(bu 3
> Both application driven health checking and event driven health checking
> .RE
> 
> .SH Initializing SAM
> .P
> Before use of SAM, library needs to be initialized by calling 
> \fBsam_initialize(3)\fR function. Please note, that
> this function can be called only once per process. In other words, if you 
> plan to make forks, do it before
> initialization.
> 
> .SH Setting warning callback
> .P
> Warning callback is send when recovery action will be taken. Actually, is 
> nothing more then sending
> \fISIGTERM\fR signal to your current process. You can handle this signal by 
> calling \fBsignal(3)\fR function.
> In your callback function, it is possible to do every thing as in normal code 
> (like send health checking
> confirmations or even stop/finalize SAM). After \fItime_interval\fR will be 
> reached again, SIGKILL will
> be sent to your application.
> 
> .SH Registering application
> .P
> Every application needs to be registered to SAM, by calling 
> \fBsam_register(3)\fR function. You can call
> this function only once and when recovery action is taken, application will 
> start again right after
> calling this function. Internally, this function will call \fBfork(3)\fR 
> call. Parent will be used
> as health checker and child will return back to your application. In the 
> other words, after calling
> \fBsam_register(3)\fR function, PID will be different.
> 
> .SH Choosing between application and event driven health checking
> .P
> It is possible to choose between application and event driven health 
> checking. This choice can be done
> by call \fBsam_hc_callback_register(3)\fR function.
> 
> .SH BUGS
> .P
> Currently not known
> 
> .SH "SEE ALSO"
> .BR sam_initialize (3),
> .BR sam_finalize (3),
> .BR sam_start (3),
> .BR sam_stop (3),
> .BR sam_register (3),
> .BR sam_hc_send (3),
> .BR sam_hc_callback_register (3)
> plain text document attachment (sam_register.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_rehister \- Register component for health checking
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_register (unsigned int *\fIreincarnation_id\fR);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_register\fR function is used to register component for health 
> checking.
> This is one of most crucial function. If recovery policy is set to 
> \fISAM_RECOVERY_POLICY_RESTART\fR
> and recovery action will be taken, new reincarnation will always start from 
> point right after
> this function. Every reincarnation is created as a new process. 
> 
> .P
> This function can be called only once and SAM must be initialized by 
> \fBsam_initialize(3)\fR function.
> 
> .P
> The \fIreincarnation_id\fR argument is used for storing current id. This can 
> be NULL and then,
> no \fIreincarnation_id\fR will be returned. It's always safe to suppose, that 
> first reincarnation
> (this means, no recovery action was taken yet) will be always 1 and 
> \fIreincarnation_id\fR will be
> raising up to MAX_INT (after this, it will fall to 0).
> 
> .P
> It's good idea to choose carefully place of putting this function. It's 
> recommended to put
> this call after some general commands (command line parsing, ...) but before 
> anything dependent on PID.
> 
> .P
> After registration, health checking is not running.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> health checking was not started by calling \fBsam_start(3)\fR function.
> .TP
> CS_ERR_LIBRARY
> internal library call failed. This can be one of pipe creation or fork. It's 
> possible to get more information
> (system) from errno.
> 
> .SH "SEE ALSO"
> .BR sam_start (3),
> .BR sam_initialize (3),
> .BR sam_hc_callback_register (3)
> plain text document attachment (sam_start.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_start \- Start health checking
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_start (void);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_start\fR function is used to start health checking of application.
> After calling this function, application needs to regularly send confirmation 
> by
> calling of \fBsam_hc_send(3)\fR function in case of application driven health 
> checking, otherwise
> recovery action will be taken. In case of event driven health checking, 
> internally created
> thread will start and send confirmation four times every \fItime_interval\fR 
> (set in \fBsam_initialize(3)\fR
> function), and every \fItime_interval\fR will call function registered by 
> \fBsam_hc_callback_register(3)\fR.
> 
> .P
> Application must be registered by calling \fBsam_register(3)\fR before this 
> function can be called.
> 
> .P
> You can always stop health checking by calling \fBsam_stop(3)\fR function.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> component was not registered by calling \fBsam_register(3)\fR function.
> 
> .SH "SEE ALSO"
> .BR sam_hc_send (3),
> .BR sam_stop (3),
> .BR sam_register (3),
> .BR sam_hc_callback_register (3)
> plain text document attachment (sam_stop.3)
> .\"/*
> .\" * Copyright (c) 2009 Red Hat, Inc.
> .\" *
> .\" * All rights reserved.
> .\" *
> .\" * Author: Jan Friesse ([email protected])
> .\" *
> .\" * This software licensed under BSD license, the text of which follows:
> .\" *
> .\" * Redistribution and use in source and binary forms, with or without
> .\" * modification, are permitted provided that the following conditions are 
> met:
> .\" *
> .\" * - Redistributions of source code must retain the above copyright notice,
> .\" *   this list of conditions and the following disclaimer.
> .\" * - Redistributions in binary form must reproduce the above copyright 
> notice,
> .\" *   this list of conditions and the following disclaimer in the 
> documentation
> .\" *   and/or other materials provided with the distribution.
> .\" * - Neither the name of the Red Hat, Inc. nor the names of its
> .\" *   contributors may be used to endorse or promote products derived from 
> this
> .\" *   software without specific prior written permission.
> .\" *
> .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> THE
> .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> .\" * THE POSSIBILITY OF SUCH DAMAGE.
> .\" */
> .TH "CPG_CONTEXT_SET" 3 "11/25/2009" "corosync Man Page" "Corosync Cluster 
> Engine Programmer's Manual"
> 
> .SH NAME
> .P
> sam_stop \- Stop health checking
> 
> .SH SYNOPSIS
> .P
> \fB#include <corosync/sam.h>\fR
> 
> .P
> \fBcs_error_t sam_stop (void);\fR
> 
> .SH DESCRIPTION
> .P
> The \fBsam_stop\fR function is used to stop health checking of application.
> After calling this function, application no longer needs to regularly send 
> confirmation in case of 
> application driven health checking. In case of event driven health checking, 
> internally created
> thread will be stopped.
> 
> .P
> You can always start health checking again by calling \fBsam_start(3)\fR 
> function.
> 
> .SH RETURN VALUE
> .P
> This call return CS_OK value if successful, otherwise and error is returned.
> 
> .SH ERRORS
> .TP
> CS_ERR_BAD_HANDLE
> health checking was not started by calling \fBsam_start(3)\fR function.
> 
> .SH "SEE ALSO"
> .BR sam_start (3)
> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais
.\"/*
.\" * Copyright (c) 2009 Red Hat, Inc.
.\" *
.\" * All rights reserved.
.\" *
.\" * Author: Jan Friesse ([email protected])
.\" * Author: Steven Dake ([email protected])
.\" *
.\" * This software licensed under BSD license, the text of which follows:
.\" *
.\" * Redistribution and use in source and binary forms, with or without
.\" * modification, are permitted provided that the following conditions are met:
.\" *
.\" * - Redistributions of source code must retain the above copyright notice,
.\" *   this list of conditions and the following disclaimer.
.\" * - Redistributions in binary form must reproduce the above copyright notice,
.\" *   this list of conditions and the following disclaimer in the documentation
.\" *   and/or other materials provided with the distribution.
.\" * - Neither the name of the Red Hat, Inc. nor the names of its
.\" *   contributors may be used to endorse or promote products derived from this
.\" *   software without specific prior written permission.
.\" *
.\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
.\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
.\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" * THE POSSIBILITY OF SUCH DAMAGE.
.\" */
.TH "SAM_OVERVIEW" 8 "11/25/2009" "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"

.SH NAME
.P
sam_overview \- Overview of the Simple Availability Manager

.SH OVERVIEW
.P
The SAM library provide a tool to check the health of an application.
The main purpose of SAM is to restart a local process when it fails to respond
to a healthcheck request in a configured time interval.

During \fBsam_initialize(3)\fR, a duplicate copy of the process is created using
the \fBfork(3)\fR system call.  This duplicate process copy contains the logic
for executing the SAM server.  The SAM server is responsible for requesting
healthchecks from the active process, and controlling the lifecycle of the
active process when it fails.  If the active process fails to respond to the
healthcheck request sent by the SAM server, it will be sent a SIGTERM signal
to request shutdown of the application.  After a configured time interval, the
process will be forcibly killed by being sent a SIGKILL signal.  Once the
active process terminates, the SAM server will create a new active process.

The Simple Availability Manager is meant to be used in conjunction with the 
cpg service.  Used together, it is possible to restart a cpg process that fails
healthchecking during operation.

The main features of SAM include:
.RS
.IP \(bu 3
A configurable recovery policy.
.IP \(bu 3
A configurable time interval for health check operations.
.IP \(bu 3
A notification via signal before recovery action is taken.
.IP \(bu 3
A mechanism to indicate to the application the number of times an active
process has been created by the SAM server.
.IP \(bu 3
Both application driven health checking and event driven health checking.
.RE

.SH Initializing SAM
.P
The SAM library is initialized by \fBsam_initialize(3)\fR.
\fBsam_initalize(3)\fR may only be called once per process.  Calling it more 
then once has undefined results and is not recommended or tested.

.SH Setting warning callback
.P
A \fISIGTERM\fR signal is sent to the application when a recovery action is
planned.  The application can use the \fBsignal(3)\fR system call to monitor
for this signal.

There are no special constraints on what SAM apis may be called in a warning
callback.  After \fItime_interval\fR expires, a SIGKILL signal is sent to the
active process to force its termination.

.SH Registering the active process
.P
The active process is registered with SAM by calling \fBsam_register(3)\fR.
This function should only be called one time in a process.  After a recovery
action is taken, the new active process will begin execution at the next line 
of code in a user process after \fBsam_register(3)\fR.

.SH Enabling event driven healthchecking
.P
Two types of healthchecking are available to the user.  The first model is one
where the user application healthchecks during its normal operation.  It is
never requested to healtcheck, and if the active process doesn't respond within
the time interval, the process will be restarted.

A more useful mechanism for healthchecking is event driven healthchecking.
Because this model is directed by the SAM server, It isn't necessary to guess
or add timers to the active process to signal a healthcheck operation is
successful.  To use event driven healthchecking,
the \fBsam_hc_callback_register(3)\fR function should be executed.

.SH BUGS
.P

.SH "SEE ALSO"
.BR sam_initialize (3),
.BR sam_finalize (3),
.BR sam_start (3),
.BR sam_stop (3),
.BR sam_register (3),
.BR sam_hc_send (3),
.BR sam_hc_callback_register (3)
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to