encoding: fix [encode|decode]_array_nohead

We want to actually encode each element and keep it, rather than
writing each one at the position after the array end!

Signed-off-by: Greg Farnum <greg@inktank.com>
MonCommand: support encode/decode

Signed-off-by: Greg Farnum <greg@inktank.com>
MonCommand: add operator== and operator!=

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: expose local monitor commands to other compilation units

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: add a separate leader_supported_commands

This isn't used yet, but will be shortly.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: pull command mapping out of _allowed_command()

We want to be able to validate commands against both the leader and
local command sets, so make that functionality generic.

Signed-off-by: Greg Farnum <greg@inktank.com>
messages: make room for passing supported monitor commands in MMonElection

We're going to use this space to let leader tell everybody what
commands it supports.

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: transmit local api on election win, accept leader's on loss

If we're the leader, just point to our local set. Disseminating these
will let peons advertise the full command set supported by the leader.
INCOMPLETE: does not yet handle winning Electors who do not send a command set.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: disseminate leader's command set instead of our own

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: validate incoming commands against the leader's set too

Then check against our own, and forward if we don't recognize it
or for some reason don't match.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: import MonCommands.h from original Dumpling and expose it

If the Elector doesn't receive a set of commands from the elected leader, it
assumes the monitor is "classic" and uses the Dumpling command set as
the leader set.

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: share local command set when deferring

We're about to use this at a basic level, to identify when we have
"classic" monitors in-quorum, but could also do something more
sophisticated like a set intersection on the commands.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: Elector: share the classic command set if we have a classic mon

The leader now checks to see if any monitors did not provide their
command set, and if so, shares the list of "classic" commands instead
of his own set. This will prevent users from seeing different commands
(depending on whether they connect to an old or new mon) while
performing upgrades, and will make it really obvious if they forgot
to upgrade one of the monitors!

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: keep a list of classic mons instead of each mon's commands

We aren't actually using the sets, so don't bother keeping them.

Signed-off-by: Greg Farnum <greg@inktank.com>
Monitor: encode and expose mon command sets

Signed-off-by: Greg Farnum <greg@inktank.com>
Elector: use monitor's encoded command sets instead of our own

Signed-off-by: Greg Farnum <greg@inktank.com>
mon: by default, warn if some members of the quorum are "classic"

Signed-off-by: Greg Farnum <greg@inktank.com>
mon: if we're the leader, don't validate command matching

Classic-format commands never match our leader command set!

Signed-off-by: Greg Farnum <greg@inktank.com>
Merge pull request #925 from ceph/wip-mon-api

Merge in changes to unify the API presented by the monitors and handle changes gracefully.

(Upgrade tests) Tested-by: Tamil Muthamizhan <tamil.muthamizhan@inktank.com>

Reviewed-by: Sage Weil <sage@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>