~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/mon/Elector.cc

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "common/Timer.h"
19
19
#include "MonitorStore.h"
 
20
#include "MonmapMonitor.h"
20
21
#include "messages/MMonElection.h"
21
22
 
22
23
#include "config.h"
26
27
#define dout_prefix _prefix(mon, epoch)
27
28
static ostream& _prefix(Monitor *mon, epoch_t epoch) {
28
29
  return *_dout << dbeginl
29
 
                << "mon" << mon->whoami
 
30
                << "mon." << mon->name << "@" << mon->rank
30
31
                << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)")))
31
32
                << ".elector(" << epoch << ") ";
32
33
}
69
70
    bump_epoch(epoch+1);  // odd == election cycle
70
71
  start_stamp = g_clock.now();
71
72
  electing_me = true;
72
 
  acked_me.insert(whoami);
 
73
  acked_me.insert(mon->rank);
 
74
 
 
75
  mon->starting_election();
73
76
  
74
77
  // bcast to everyone else
75
78
  for (unsigned i=0; i<mon->monmap->size(); ++i) {
76
 
    if ((int)i == whoami) continue;
 
79
    if ((int)i == mon->rank) continue;
77
80
    mon->messenger->send_message(new MMonElection(MMonElection::OP_PROPOSE, epoch, mon->monmap),
78
81
                                 mon->monmap->get_inst(i));
79
82
  }
151
154
  for (set<int>::iterator p = quorum.begin();
152
155
       p != quorum.end();
153
156
       ++p) {
154
 
    if (*p == whoami) continue;
 
157
    if (*p == mon->rank) continue;
155
158
    MMonElection *m = new MMonElection(MMonElection::OP_VICTORY, epoch, mon->monmap);
156
159
    m->quorum = quorum;
157
160
    mon->messenger->send_message(m, mon->monmap->get_inst(*p));
186
189
    }
187
190
  }
188
191
 
189
 
  if (whoami < from) {
 
192
  if (mon->rank < from) {
190
193
    // i would win over them.
191
194
    if (leader_acked >= 0) {        // we already acked someone
192
195
      assert(leader_acked < from);  // and they still win, of course
250
253
  dout(5) << "handle_victory from " << m->get_source() << dendl;
251
254
  int from = m->get_source().num();
252
255
 
253
 
  assert(from < whoami);
 
256
  assert(from < mon->rank);
254
257
  assert(m->epoch % 2 == 0);  
255
258
 
256
259
  // i should have seen this election if i'm getting the victory.
290
293
                << " > my epoch " << mon->monmap->epoch 
291
294
                << ", taking it"
292
295
                << dendl;
293
 
        delete mon->monmap;
294
 
        mon->monmap = peermap;
295
 
        mon->store->put_bl_sn(em->monmap_bl, "monmap", peermap->epoch);
296
 
        mon->store->put_bl_ss(em->monmap_bl, "monmap", "latest");
297
 
      } else {
298
 
        if (peermap->epoch < mon->monmap->epoch) {
299
 
          dout(0) << m->get_source_inst() << " has older monmap epoch " << peermap->epoch
300
 
                  << " < my epoch " << mon->monmap->epoch 
301
 
                  << dendl;
302
 
        }
303
 
        delete peermap;
 
296
        mon->monmap->decode(em->monmap_bl);
 
297
        mon->store->put_bl_sn(em->monmap_bl, "monmap", mon->monmap->epoch);
 
298
        mon->monmon()->paxos->stash_latest(mon->monmap->epoch, em->monmap_bl);
 
299
      } else if (peermap->epoch < mon->monmap->epoch) {
 
300
        dout(0) << m->get_source_inst() << " has older monmap epoch " << peermap->epoch
 
301
                << " < my epoch " << mon->monmap->epoch 
 
302
                << dendl;
304
303
      } 
 
304
      delete peermap;
305
305
 
306
306
      switch (em->op) {
307
307
      case MMonElection::OP_PROPOSE: