]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mon/MDSMonitor.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 /* Metadata Server Monitor
18 #ifndef CEPH_MDSMONITOR_H
19 #define CEPH_MDSMONITOR_H
24 #include "include/types.h"
25 #include "PaxosFSMap.h"
26 #include "PaxosService.h"
27 #include "msg/Messenger.h"
28 #include "messages/MMDSBeacon.h"
29 #include "CommandHandler.h"
31 class FileSystemCommandHandler
;
33 class MDSMonitor
: public PaxosService
, public PaxosFSMap
, protected CommandHandler
{
35 MDSMonitor(Monitor
*mn
, Paxos
*p
, string service_name
);
38 void create_initial() override
;
39 void get_store_prefixes(std::set
<string
>& s
) const override
;
40 void update_from_paxos(bool *need_bootstrap
) override
;
42 void create_pending() override
;
43 void encode_pending(MonitorDBStore::TransactionRef t
) override
;
44 // we don't require full versions; don't encode any.
45 void encode_full(MonitorDBStore::TransactionRef t
) override
{ }
46 version_t
get_trim_to() const override
;
48 bool preprocess_query(MonOpRequestRef op
) override
; // true if processed.
49 bool prepare_update(MonOpRequestRef op
) override
;
50 bool should_propose(double& delay
) override
;
52 void on_active() override
;
53 void on_restart() override
;
56 void check_sub(Subscription
*sub
);
58 void dump_info(Formatter
*f
);
59 int print_nodes(Formatter
*f
);
62 * Return true if a blacklist was done (i.e. OSD propose needed)
64 bool fail_mds_gid(FSMap
&fsmap
, mds_gid_t gid
);
66 bool is_leader() const override
{ return mon
->is_leader(); }
70 template<int dblV
= 7>
71 void print_map(const FSMap
&m
);
73 void _updated(MonOpRequestRef op
);
75 void _note_beacon(class MMDSBeacon
*m
);
76 bool preprocess_beacon(MonOpRequestRef op
);
77 bool prepare_beacon(MonOpRequestRef op
);
79 bool preprocess_offload_targets(MonOpRequestRef op
);
80 bool prepare_offload_targets(MonOpRequestRef op
);
82 int fail_mds(FSMap
&fsmap
, std::ostream
&ss
,
83 const std::string
&arg
,
84 MDSMap::mds_info_t
*failed_info
);
86 bool preprocess_command(MonOpRequestRef op
);
87 bool prepare_command(MonOpRequestRef op
);
89 int filesystem_command(
92 std::string
const &prefix
,
93 const cmdmap_t
& cmdmap
,
94 std::stringstream
&ss
);
97 struct beacon_info_t
{
98 mono_time stamp
= mono_clock::zero();
101 beacon_info_t(mono_time stamp
, uint64_t seq
) : stamp(stamp
), seq(seq
) {}
103 map
<mds_gid_t
, beacon_info_t
> last_beacon
;
105 std::list
<std::shared_ptr
<FileSystemCommandHandler
> > handlers
;
107 bool maybe_promote_standby(FSMap
& fsmap
, Filesystem
& fs
);
108 bool maybe_resize_cluster(FSMap
&fsmap
, fs_cluster_id_t fscid
);
109 void maybe_replace_gid(FSMap
&fsmap
, mds_gid_t gid
,
110 const MDSMap::mds_info_t
& info
, bool *mds_propose
, bool *osd_propose
);
111 void tick() override
; // check state, take actions
113 int dump_metadata(const FSMap
&fsmap
, const std::string
&who
, Formatter
*f
,
116 void update_metadata(mds_gid_t gid
, const Metadata
& metadata
);
117 void remove_from_metadata(const FSMap
&fsmap
, MonitorDBStore::TransactionRef t
);
118 int load_metadata(map
<mds_gid_t
, Metadata
>& m
);
119 void count_metadata(const std::string
& field
, Formatter
*f
);
121 void count_metadata(const std::string
& field
, map
<string
,int> *out
);
124 // MDS daemon GID to latest health state from that GID
125 std::map
<uint64_t, MDSHealth
> pending_daemon_health
;
126 std::set
<uint64_t> pending_daemon_health_rm
;
128 map
<mds_gid_t
, Metadata
> pending_metadata
;
130 mds_gid_t
gid_from_arg(const FSMap
&fsmap
, const std::string
&arg
, std::ostream
& err
);
132 // When did the mon last call into our tick() method? Used for detecting
133 // when the mon was not updating us for some period (e.g. during slow
134 // election) to reset last_beacon timeouts
135 mono_time last_tick
= mono_clock::zero();