]>
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
25 #include "include/types.h"
26 #include "PaxosFSMap.h"
27 #include "PaxosService.h"
28 #include "msg/Messenger.h"
29 #include "messages/MMDSBeacon.h"
32 class MMDSLoadTargets
;
34 class FileSystemCommandHandler
;
36 class MDSMonitor
: public PaxosService
, public PaxosFSMap
{
38 MDSMonitor(Monitor
*mn
, Paxos
*p
, string service_name
);
41 void create_initial() override
;
42 void get_store_prefixes(std::set
<string
>& s
) override
;
43 void update_from_paxos(bool *need_bootstrap
) override
;
45 void create_pending() override
;
46 void encode_pending(MonitorDBStore::TransactionRef t
) override
;
47 // we don't require full versions; don't encode any.
48 void encode_full(MonitorDBStore::TransactionRef t
) override
{ }
49 version_t
get_trim_to() override
;
51 bool preprocess_query(MonOpRequestRef op
) override
; // true if processed.
52 bool prepare_update(MonOpRequestRef op
) override
;
53 bool should_propose(double& delay
) override
;
55 void on_active() override
;
56 void on_restart() override
;
59 void check_sub(Subscription
*sub
);
61 void dump_info(Formatter
*f
);
62 int print_nodes(Formatter
*f
);
65 * Return true if a blacklist was done (i.e. OSD propose needed)
67 bool fail_mds_gid(mds_gid_t gid
);
69 bool is_leader() const override
{ return mon
->is_leader(); }
73 void print_map(const FSMap
&m
, int dbl
=7);
76 void _updated(MonOpRequestRef op
);
78 void _note_beacon(class MMDSBeacon
*m
);
79 bool preprocess_beacon(MonOpRequestRef op
);
80 bool prepare_beacon(MonOpRequestRef op
);
82 bool preprocess_offload_targets(MonOpRequestRef op
);
83 bool prepare_offload_targets(MonOpRequestRef op
);
85 void get_health(list
<pair
<health_status_t
,string
> >& summary
,
86 list
<pair
<health_status_t
,string
> > *detail
,
87 CephContext
*cct
) const override
;
88 int fail_mds(std::ostream
&ss
, const std::string
&arg
,
89 MDSMap::mds_info_t
*failed_info
);
91 bool preprocess_command(MonOpRequestRef op
);
92 bool prepare_command(MonOpRequestRef op
);
95 const std::string
&role_str
,
99 void modify_legacy_filesystem(
100 std::function
<void(std::shared_ptr
<Filesystem
> )> fn
);
101 int legacy_filesystem_command(
103 std::string
const &prefix
,
104 map
<string
, cmd_vartype
> &cmdmap
,
105 std::stringstream
&ss
);
106 int filesystem_command(
108 std::string
const &prefix
,
109 map
<string
, cmd_vartype
> &cmdmap
,
110 std::stringstream
&ss
);
113 struct beacon_info_t
{
117 map
<mds_gid_t
, beacon_info_t
> last_beacon
;
119 bool try_standby_replay(
120 const MDSMap::mds_info_t
& finfo
,
121 const Filesystem
&leader_fs
,
122 const MDSMap::mds_info_t
& ainfo
);
124 std::list
<std::shared_ptr
<FileSystemCommandHandler
> > handlers
;
126 bool maybe_promote_standby(std::shared_ptr
<Filesystem
> &fs
);
127 bool maybe_expand_cluster(std::shared_ptr
<Filesystem
> &fs
);
128 void maybe_replace_gid(mds_gid_t gid
, const MDSMap::mds_info_t
& info
,
129 bool *mds_propose
, bool *osd_propose
);
130 void tick() override
; // check state, take actions
132 int dump_metadata(const string
& who
, Formatter
*f
, ostream
& err
);
134 void update_metadata(mds_gid_t gid
, const Metadata
& metadata
);
135 void remove_from_metadata(MonitorDBStore::TransactionRef t
);
136 int load_metadata(map
<mds_gid_t
, Metadata
>& m
);
137 void count_metadata(const string
& field
, Formatter
*f
);
139 void count_metadata(const string
& field
, map
<string
,int> *out
);
142 // MDS daemon GID to latest health state from that GID
143 std::map
<uint64_t, MDSHealth
> pending_daemon_health
;
144 std::set
<uint64_t> pending_daemon_health_rm
;
147 map
<mds_gid_t
, Metadata
> pending_metadata
;
149 mds_gid_t
gid_from_arg(const std::string
& arg
, std::ostream
& err
);
151 // When did the mon last call into our tick() method? Used for detecting
152 // when the mon was not updating us for some period (e.g. during slow
153 // election) to reset last_beacon timeouts