root/include/crm/cluster/election.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (C) 2009 Andrew Beekhof <andrew@beekhof.net>
   3  *
   4  * This program is free software; you can redistribute it and/or
   5  * modify it under the terms of the GNU Lesser General Public
   6  * License as published by the Free Software Foundation; either
   7  * version 2 of the License, or (at your option) any later version.
   8  *
   9  * This software is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12  * General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU Lesser General Public
  15  * License along with this library; if not, write to the Free Software
  16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17  */
  18 #ifndef CRM_COMMON_ElECTION__H
  19 #  define CRM_COMMON_ElECTION__H
  20 
  21 /**
  22  * \file
  23  * \brief Functions for conducting elections
  24  * \ingroup core
  25  */
  26 
  27 typedef struct election_s election_t;
  28 
  29 enum election_result
  30 {
  31     election_start = 0,
  32     election_in_progress,
  33     election_lost,
  34     election_won,
  35     election_error,
  36 };
  37 
  38 void election_fini(election_t *e);
  39 void election_reset(election_t *e);
  40 election_t *election_init(const char *name, const char *uname, guint period_ms, GSourceFunc cb);
  41 
  42 void election_timeout_set_period(election_t *e, guint period_ms);
  43 void election_timeout_stop(election_t *e);
  44 
  45 void election_vote(election_t *e);
  46 bool election_check(election_t *e);
  47 void election_remove(election_t *e, const char *uname);
  48 enum election_result election_state(election_t *e);
  49 enum election_result election_count_vote(election_t *e, xmlNode *vote, bool can_win);
  50 
  51 #endif

/* [previous][next][first][last][top][bottom][index][help] */