-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgui.h
413 lines (338 loc) · 13.1 KB
/
gui.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* gui.h
*
*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* 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.
*
* Copyright (C) 2009-2010 Michael McThrow <[email protected]>
* Portions Copyright Dreamhost 2010
*
*/
#ifndef CEPH_GUI_H
#define CEPH_GUI_H
#include "global/global_init.h"
#include "mds/MDSMap.h"
#include "mon/MonMap.h"
#include "mon/PGMap.h"
#include "msg/tcp.h"
#include "osd/OSDMap.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <gtkmm.h>
#include <iosfwd>
#include <stack>
enum NodeType {
OSD_NODE = 0,
PG_NODE,
MDS_NODE,
MON_NODE,
NUM_NODE_TYPES
};
class GuiMonitorThread;
// Contains information about a range of nodes (or a specific node)
class NodeInfo {
public:
unsigned int begin_range;
unsigned int end_range;
enum NodeType type;
int status;
NodeInfo(unsigned int begin_range_, unsigned int end_range_,
enum NodeType type_, int status_)
: begin_range(begin_range_),
end_range(end_range_),
type(type_),
status(status_)
{
}
};
// Variables, classes, and methods releated to handling the main window and
// dialog boxes are stored in the GuiMonitor class.
class GuiMonitor
{
private:
// Used for displaying icons of the nodes in a cluster.
class NodeIconColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
Gtk::TreeModelColumn<Glib::ustring> caption;
Gtk::TreeModelColumn<unsigned int> begin_range;
Gtk::TreeModelColumn<unsigned int> end_range;
Gtk::TreeModelColumn<int> status;
NodeIconColumns() {
add(icon);
add(caption);
add(begin_range);
add(end_range);
add(status);
}
};
// Used for displaying information about either a cluter or a node.
class KeyValueModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<Glib::ustring> key;
Gtk::TreeModelColumn<Glib::ustring> value;
KeyValueModelColumns() {
add(key);
add(value);
}
};
// Used for displaying different types of nodes in the "View Node..." dialog
// box.
class ViewNodeOptionColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<enum NodeType> type;
Gtk::TreeModelColumn<Glib::ustring> name;
ViewNodeOptionColumns() {
add(type);
add(name);
}
};
// Variables, classes, and methods related to the node statistics and cluster
// statistics windows.
class StatsWindowInfo {
public:
StatsWindowInfo(GuiMonitor *gui_,
Glib::RefPtr<Gtk::Builder> builder,
bool is_cluster_, enum NodeType type_, int id_);
~StatsWindowInfo();
void init();
public:
/*
* GUI Elements
*/
GuiMonitor *gui;
Gtk::Window *stats_window;
Gtk::Label *stats_info_label;
Gtk::TreeView *stats_info_tree_view;
Gtk::Button *stats_copy_button;
Gtk::Button *stats_save_button;
Gtk::Button *stats_close_button;
private:
KeyValueModelColumns columns;
Glib::RefPtr<Gtk::ListStore> stats;
bool is_cluster;
enum NodeType type;
int id;
CephToolCtx *ctx;
/*
* Private Functions
*/
private:
// Closes the window that contains the statistics of a node or cluster.
// Called by nodeStatsWindow by signal_delete_event.
bool closeWindow(GdkEventAny *event) {
delete this;
return true;
}
void copy();
// Closes the window that contains the statistics of a node or cluster.
// Called by nodeStatsCloseButton by signal_clicked.
void close() {
delete this;
}
void gen_osd_cluster_columns();
void gen_mds_cluster_columns();
void gen_pg_cluster_columns();
void gen_monitor_cluster_columns();
void gen_osd_node_columns();
void gen_mds_node_columns();
void gen_pg_node_columns();
std::string stats_string();
void insert_stats(const std::string &key, const std::string &value);
};
friend class StatsWindowInfo;
public:
GuiMonitor(Glib::RefPtr<Gtk::Builder> builder, CephToolCtx *ctx_);
~GuiMonitor();
bool init();
void run_main_loop(Gtk::Main &kit);
void thread_shutdown();
void check_status();
private:
/*
* Private Functions
*/
bool open_icon(Glib::RefPtr<Gdk::Pixbuf> &icon, const std::string &path);
void connect_signals();
void link_elements();
void update_osd_cluster_view();
void update_mds_cluster_view();
void update_pg_cluster_view();
void update_mon_cluster_view();
std::string gen_osd_icon_caption(unsigned int begin, unsigned int end) const;
std::string gen_mds_icon_caption(unsigned int begin, unsigned int end) const;
std::string gen_pg_icon_caption(unsigned int begin, unsigned int end) const;
void gen_node_info_from_icons(Glib::RefPtr<Gtk::ListStore> iconStore,
enum NodeType type, std::vector<NodeInfo >& ret);
void gen_icons_from_node_info(const std::vector<NodeInfo>& node_info) const;
void view_osd_nodes(unsigned int begin, unsigned int end,
bool view_all = true);
void view_mds_nodes(unsigned int begin = 0, unsigned int end = 0,
bool view_all = true);
void view_pg_nodes(unsigned int begin, unsigned int end,
bool view_all);
int find_mds_id(const std::string &name);
void open_stats(enum NodeType type, bool is_cluster, int id);
void dialog_error(const std::string &msg, Gtk::MessageType type);
/*
* Signal handlers
*/
// Exits the program. Called by Gtk::Main by signal_quit
bool quit_signal_handler();
// Quits the GUI. Called by guiMonitorWindow by signal_delete_event.
bool quit_gui(GdkEventAny *event);
// Quits the GUI. Called by guiMonitorQuitImageMenuItem by signal_activate.
void gui_monitor_quit();
// Copies the text in guiMonitorLogTextView onto the clipboard. Called by
// guiMonitorCopyImageMenuItem by signal_activate.
void copy_log();
// Opens the "Send Command...." window. Called by
// guiMonitorSendCommandMenuItem for signal_activate.
void open_send_command();
// Opens the "View Node..." window. Called by guiMonitorViewNodeMenuItem by
// signal_activate.
void open_view_mode();
// Opens the "About" dialog box. Called by guiMonitorAboutImageMenuItem by
// signal_activate.
void open_about_dialog();
// Performs "zoom in" option for the PG cluster icon view area. Allows the
// user to "zoom in" on a narrower range of nodes until he or she selects a
// specific node of interest. Called by guiMonitorPGClusterIconView by
// signal_item_activated.
void pg_cluster_zoom_in(const Gtk::TreeModel::Path& path);
// Allows user to "zoom out" one level of the PG cluster view area to obtain
// a broader range of nodes until he or she views the overall amount of
// nodes. Called by guiMonitorPGClusterBackButton by signal_clicked
void pg_cluster_back();
// Allows user to view the broadest range of nodes in the PG cluster. Called
// by guiMonitorPGClusterViewAllButton by signal_clicked.
void pg_cluster_view_all();
// Allows user to obtain the statistics of the PG cluster. Called by
// guiMonitorPCClusterStatsButton by signal_clicked.
void pg_cluster_stats();
// Allows user to obtain the statistics of the monitor cluster. Called by
// guiMonitorMonitorClusterStatsButton by signal_clicked.
void monitor_cluster_stats();
// Performs "zoom in" option for the OSD cluster icon view area. Allows the
// user to "zoom in" on a narrower range of nodes until he or she selects a
// specific node of interest. Called by guiMonitorOSDClusterIconView by
// signal_item_activated.
void osdc_cluster_zoom_in(const Gtk::TreeModel::Path& path);
// Allows user to "zoom out" one level of the OSD cluster view area to obtain
// a broader range of nodes until he or she views the overall amount of
// nodes. Called by guiMonitorOSDClusterBackButton by signal_clicked
void osdc_cluster_back();
// Allows user to view the broadest range of nodes in the PG cluster. Called
// by guiMonitorOSDClusterViewAllButton by signal_clicked.
void osdc_cluster_view_all();
// Allows user to obtain the statistics of the OSD cluster. Called by
// guiMonitorOSDClusterStatsButton by signal_clicked.
void osdc_cluster_stats();
// Performs "zoom in" option for the MDS cluster icon view area. Allows the
// user to "zoom in" on a narrower range of nodes until he or she selects a
// specific node of interest. Called by guiMonitorMDSClusterIconView by
// signal_item_activated.
void mds_cluster_zoom_in(const Gtk::TreeModel::Path& path);
// Allows user to "zoom out" one level of the MDS cluster view area to obtain
// a broader range of nodes until he or she views the overall amount of
// nodes. Called by guiMonitorMDSClusterBackButton by signal_clicked.
void mds_cluster_back();
// Allows user to view the broadest range of nodes in the MDS cluster.
// Called by guiMonitorMDSClusterViewAllButton by signal_clicked.
void mds_cluster_view_all();
// Allows user to obtain the statistics of the MDS cluster. Called by
// guiMonitorMDSClusterStatsButton by signal_clicked.
void mds_cluster_stats();
// Called when a button is pressed in the "View Node..." dialog box.
void handle_view_node_response(int response);
// Called when a node type is selected in the "View Node..." dialog box.
void handle_view_node_change();
// Called when a button is pressed in the "Send Command..." dialog box.
void handle_send_command_response(int response);
unsigned int pg_cluster_zoom; // current zoom level of the PG cluster view
unsigned int osd_cluster_zoom; // current zoom level of the OSD cluster view
unsigned int mds_cluster_zoom; // current zoom level of the MDS cluster view
stack<vector<NodeInfo> > old_pg_cluster_zoom_states;
stack<vector<NodeInfo> > old_osd_cluster_zoom_states;
stack<vector<NodeInfo> > old_mds_cluster_zoom_states;
std::vector <std::string> current_up_mds;
std::vector <pg_t> current_pgs;
bool send_command_success; // did "Send Command..." end without errors?
bool view_node_success; // did "View Node..." end without errors?"
GuiMonitorThread *thread;
///// GUI Elements /////
// Main Window
Gtk::Window *guiMonitorWindow;
Gtk::ImageMenuItem *guiMonitorQuitImageMenuItem;
Gtk::ImageMenuItem *guiMonitorCopyImageMenuItem;
Gtk::MenuItem *guiMonitorSendCommandMenuItem;
Gtk::MenuItem *guiMonitorViewNodeMenuItem;
Gtk::ImageMenuItem *guiMonitorAboutImageMenuItem;
Gtk::TextView *guiMonitorLogTextView;
Glib::RefPtr<Gtk::TextBuffer> guiMonitorLogTextBuffer;
Gtk::Statusbar *guiMonitorStatusbar;
// Main Window -- Placement Groups Section
Gtk::Label *guiMonitorPGClusterStatsLabel;
Gtk::IconView *guiMonitorPGClusterIconView;
Glib::RefPtr<Gtk::ListStore> guiMonitorPGClusterIcons;
Gtk::Button *guiMonitorPGClusterBackButton;
Gtk::Button *guiMonitorPGClusterViewAllButton;
Gtk::Button *guiMonitorPGClusterStatsButton;
// Main Window -- Monitor Cluster Section
Gtk::Label *guiMonitorMonitorClusterStatsLabel;
Gtk::Button *guiMonitorMonitorClusterStatsButton;
Gtk::TreeView *guiMonitorMonitorClusterTreeView;
Glib::RefPtr<Gtk::ListStore> guiMonitorMonitorClusterEntries;
KeyValueModelColumns monitorColumns;
// Main Window -- OSD Cluster Section
Gtk::Label *guiMonitorOSDClusterStatsLabel;
Gtk::IconView *guiMonitorOSDClusterIconView;
Glib::RefPtr<Gtk::ListStore> guiMonitorOSDClusterIcons;
Gtk::Button *guiMonitorOSDClusterBackButton;
Gtk::Button *guiMonitorOSDClusterViewAllButton;
Gtk::Button *guiMonitorOSDClusterStatsButton;
// Main Window -- Metadata Server Section
Gtk::Label *guiMonitorMDSClusterStatsLabel;
Gtk::IconView *guiMonitorMDSClusterIconView;
Glib::RefPtr<Gtk::ListStore> guiMonitorMDSClusterIcons;
Gtk::Button *guiMonitorMDSClusterBackButton;
Gtk::Button *guiMonitorMDSClusterViewAllButton;
Gtk::Button *guiMonitorMDSClusterStatsButton;
// View Node Dialog
Gtk::Dialog *viewNodeDialog;
Gtk::Entry *viewNodeNameEntry;
Gtk::ComboBox *viewNodeTypeComboBox;
Glib::RefPtr<Gtk::ListStore> viewNodeNodeTypeListStore;
Gtk::Label *viewNodeNameLabel;
ViewNodeOptionColumns viewNodeColumns;
// Send Command Window
Gtk::Dialog *sendCommandDialog;
Gtk::Entry *sendCommandPromptEntry;
// About Dialog
Gtk::AboutDialog *guiMonitorAboutDialog;
// Icons
Glib::RefPtr<Gdk::Pixbuf> blacklistIcon;
Glib::RefPtr<Gdk::Pixbuf> clientIcon;
//Glib::RefPtr<Gdk::Pixbuf> failedMDSIcon;
Glib::RefPtr<Gdk::Pixbuf> MDSIcon;
Glib::RefPtr<Gdk::Pixbuf> monitorIcon;
Glib::RefPtr<Gdk::Pixbuf> upOSDIcon;
Glib::RefPtr<Gdk::Pixbuf> downOSDIcon;
Glib::RefPtr<Gdk::Pixbuf> outOSDIcon;
Glib::RefPtr<Gdk::Pixbuf> PGIcon;
//Glib::RefPtr<Gdk::Pixbuf> stoppedMDSIcon;
NodeIconColumns icon_columns;
public:
CephToolCtx *ctx;
};
#endif