blob: fc0db46004adf4f604ad3b245fcb3439fd9cf44a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_LOGMONITOR_H
#define CEPH_LOGMONITOR_H
#include "mon_types.h"
#include <map>
#include <set>
#include "common/LogEntry.h"
#include "msg/Messenger.h"
#include "messages/MLog.h"
#include "PaxosService.h"
using namespace std;
class MMonCommand;
class LogMonitor : public PaxosService {
private:
multimap<utime_t,LogEntry> pending_log;
LogSummary pending_summary, summary;
void create_initial();
void update_from_paxos();
void create_pending(); // prepare a new pending
void encode_pending(bufferlist &bl); // propose pending update to peers
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
bool prepare_update(PaxosServiceMessage *m);
bool preprocess_log(MLog *m);
bool prepare_log(MLog *m);
void _updated_log(MLog *m);
bool should_propose(double& delay);
struct C_Log : public Context {
LogMonitor *logmon;
MLog *ack;
C_Log(LogMonitor *p, MLog *a) : logmon(p), ack(a) {}
void finish(int r) {
if (r == -ECANCELED) {
if (ack)
ack->put();
return;
}
logmon->_updated_log(ack);
}
};
bool preprocess_command(MMonCommand *m);
bool prepare_command(MMonCommand *m);
bool _create_sub_summary(MLog *mlog, int level);
void _create_sub_incremental(MLog *mlog, int level, version_t sv);
public:
LogMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p) { }
void tick(); // check state, take actions
void check_subs();
void check_sub(Subscription *s);
/**
* translate log sub name ('log-info') to integer id
*
* @param n name
* @return id, or -1 if unrecognized
*/
int sub_name_to_id(const string& n);
};
#endif
|