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

« back to all changes in this revision

Viewing changes to src/mon/Paxos.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:
23
23
 
24
24
#define DOUT_SUBSYS paxos
25
25
#undef dout_prefix
26
 
#define dout_prefix _prefix(mon, whoami, machine_name, state, last_committed)
27
 
static ostream& _prefix(Monitor *mon, int whoami, const char *machine_name, int state, version_t last_committed) {
 
26
#define dout_prefix _prefix(mon, mon->name, mon->rank, machine_name, state, last_committed)
 
27
static ostream& _prefix(Monitor *mon, const string& name, int rank, const char *machine_name, int state, version_t last_committed) {
28
28
  return *_dout << dbeginl
29
 
                << "mon" << whoami
 
29
                << "mon." << name << "@" << rank
30
30
                << (mon->is_starting() ?
31
31
                    (const char*)"(starting)" :
32
32
                    (mon->is_leader() ?
87
87
  for (set<int>::const_iterator p = mon->get_quorum().begin();
88
88
       p != mon->get_quorum().end();
89
89
       ++p) {
90
 
    if (*p == whoami) continue;
 
90
    if (*p == mon->rank) continue;
91
91
    
92
92
    MMonPaxos *collect = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_COLLECT, machine_id);
93
93
    collect->last_committed = last_committed;
336
336
  
337
337
  // accept it ourselves
338
338
  accepted.clear();
339
 
  accepted.insert(whoami);
 
339
  accepted.insert(mon->rank);
340
340
  new_value = v;
341
341
  mon->store->put_bl_sn(new_value, machine_name, last_committed+1);
342
342
 
356
356
  for (set<int>::const_iterator p = mon->get_quorum().begin();
357
357
       p != mon->get_quorum().end();
358
358
       ++p) {
359
 
    if (*p == whoami) continue;
 
359
    if (*p == mon->rank) continue;
360
360
    
361
361
    dout(10) << " sending begin to mon" << *p << dendl;
362
362
    MMonPaxos *begin = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_BEGIN, machine_id);
478
478
 
479
479
  // commit locally
480
480
  last_committed++;
 
481
  last_commit_time = g_clock.now();
481
482
  mon->store->put_int(last_committed, machine_name, "last_committed");
482
483
 
483
484
  // tell everyone
484
485
  for (set<int>::const_iterator p = mon->get_quorum().begin();
485
486
       p != mon->get_quorum().end();
486
487
       ++p) {
487
 
    if (*p == whoami) continue;
 
488
    if (*p == mon->rank) continue;
488
489
 
489
490
    dout(10) << " sending commit to mon" << *p << dendl;
490
491
    MMonPaxos *commit = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_COMMIT, machine_id);
528
529
  lease_expire = g_clock.now();
529
530
  lease_expire += g_conf.mon_lease;
530
531
  acked_lease.clear();
531
 
  acked_lease.insert(whoami);
 
532
  acked_lease.insert(mon->rank);
532
533
 
533
534
  dout(7) << "extend_lease now+" << g_conf.mon_lease << " (" << lease_expire << ")" << dendl;
534
535
 
536
537
  for (set<int>::const_iterator p = mon->get_quorum().begin();
537
538
       p != mon->get_quorum().end();
538
539
       ++p) {
539
 
    if (*p == whoami) continue;
 
540
    if (*p == mon->rank) continue;
540
541
    MMonPaxos *lease = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LEASE, machine_id);
541
542
    lease->last_committed = last_committed;
542
543
    lease->lease_timestamp = lease_expire;
556
557
  utime_t at = lease_expire;
557
558
  at -= g_conf.mon_lease;
558
559
  at += g_conf.mon_lease_renew_interval;
559
 
  mon->timer.add_event_at(at, lease_renew_event);       
560
 
}
561
 
 
 
560
  mon->timer.add_event_at(at, lease_renew_event);
 
561
}
 
562
 
 
563
void Paxos::warn_on_future_time(utime_t t, entity_name_t from)
 
564
{
 
565
  utime_t now = g_clock.now();
 
566
  if (t > now) {
 
567
    utime_t diff = t - now;
 
568
    if (diff > g_conf.mon_clock_drift_allowed) {
 
569
      utime_t warn_diff = now - last_clock_drift_warn;
 
570
      if (warn_diff >
 
571
          pow(g_conf.mon_clock_drift_warn_backoff, clock_drift_warned)) {
 
572
        stringstream ss;
 
573
        ss << "message from " << from << " was stamped " << diff
 
574
           << "s in the future, clocks not synchronized";
 
575
        mon->get_logclient()->log(LOG_WARN, ss);
 
576
        last_clock_drift_warn = g_clock.now();
 
577
        ++clock_drift_warned;
 
578
      }
 
579
    }
 
580
  }
 
581
 
 
582
}
562
583
 
563
584
// peon
564
585
void Paxos::handle_lease(MMonPaxos *lease)
571
592
    return;
572
593
  }
573
594
 
574
 
  if (lease->sent_timestamp > g_clock.now() + g_conf.mon_lease_wiggle_room) {
575
 
    stringstream ss;
576
 
    ss << "lease_expire from mon" << lease->get_source().num()
577
 
       << " was sent from future time " << lease->sent_timestamp
578
 
       << ", clocks not synchronized"
579
 
       << std::endl;
580
 
    mon->get_logclient()->log(LOG_WARN, ss);
581
 
  }
 
595
  warn_on_future_time(lease->sent_timestamp, lease->get_source());
582
596
 
583
597
  // extend lease
584
598
  if (lease_expire < lease->lease_timestamp) {
641
655
             << " dup (lagging!), ignoring" << dendl;
642
656
  }
643
657
 
644
 
  if (ack->sent_timestamp > g_clock.now() + g_conf.mon_lease_wiggle_room) {
645
 
    stringstream ss;
646
 
    ss << "lease_ack from mon" << from
647
 
       << " was sent from future time " << ack->sent_timestamp
648
 
       << ", clocks not synchronized." << std::endl;
649
 
    mon->get_logclient()->log(LOG_WARN, ss);
650
 
  }
 
658
  warn_on_future_time(ack->sent_timestamp, ack->get_source());
 
659
 
651
660
  ack->put();
652
661
}
653
662
 
714
723
  last_pn /= 100;
715
724
  last_pn++;
716
725
  last_pn *= 100;
717
 
  last_pn += (version_t)whoami;
 
726
  last_pn += (version_t)mon->rank;
718
727
  
719
728
  // write
720
729
  mon->store->put_int(last_pn, machine_name, "last_pn");