}
}
-std::string GuiMonitor::gen_osd_icon_caption(unsigned int begin, unsigned int end)
+std::string GuiMonitor::
+gen_osd_icon_caption(unsigned int begin, unsigned int end) const
{
boost::format rangeFormatter("OSDs %lu-%lu");
boost::format singleFormatter("OSD %lu");
}
std::string GuiMonitor::
-gen_mds_icon_caption(unsigned int begin, unsigned int end)
+gen_mds_icon_caption(unsigned int begin, unsigned int end) const
{
if (end == begin) {
ostringstream oss;
delete[] ranges;
}
-std::string GuiMonitor::gen_pg_icon_caption(unsigned int begin, unsigned int end)
+std::string GuiMonitor::
+gen_pg_icon_caption(unsigned int begin, unsigned int end) const
{
boost::format rangeFormatter("PGs %lu-%lu");
boost::format singleFormatter("PG %lu");
viewNodeDialog->hide();
}
-std::vector<NodeInfo *> GuiMonitor::gen_node_info_from_icons
- (Glib::RefPtr<Gtk::ListStore> iconStore, enum NodeType type)
+void GuiMonitor::gen_node_info_from_icons(Glib::RefPtr<Gtk::ListStore> iconStore,
+ enum NodeType type, std::vector<NodeInfo >& ret)
{
- vector<NodeInfo *> clusterInfo;
Gtk::TreeModel::Children icons = iconStore->children();
Gtk::TreeModel::iterator iter;
- Gtk::TreeModel::Row currentRow;
- NodeInfo *currentNodeInfo;
- int status;
+ int status = CEPH_OSD_UP;
for (iter = icons.begin(); iter != icons.end(); iter++) {
- currentRow = *iter;
-
- currentNodeInfo = new NodeInfo(currentRow[icon_columns.begin_range],
- currentRow[icon_columns.end_range], type, status);
+ Gtk::TreeModel::Row cur_row(*iter);
- clusterInfo.push_back(currentNodeInfo);
+ NodeInfo cur(cur_row[icon_columns.begin_range],
+ cur_row[icon_columns.end_range], type, status);
+ ret.push_back(cur);
}
-
- return clusterInfo;
}
-void GuiMonitor::gen_icons_from_node_info(vector<NodeInfo *>& nodeInfo)
+void GuiMonitor::gen_icons_from_node_info(const vector<NodeInfo>& node_info) const
{
Glib::RefPtr<Gtk::ListStore> icons;
Gtk::TreeModel::Row row;
- NodeInfo *node;
- switch (nodeInfo[0]->type) {
+ switch (node_info[0].type) {
case OSD_NODE:
icons = guiMonitorOSDClusterIcons;
break;
icons->clear();
- for (unsigned int i = 0; i < nodeInfo.size(); i++) {
- node = nodeInfo[i];
- row = *(icons->append());
+ vector<NodeInfo>::const_iterator i = node_info.begin();
+ vector<NodeInfo>::const_iterator end = node_info.end();
+ for (; i != end; ++i) {
+ const NodeInfo &node(*i);
+ row = *(icons->append());
- row[icon_columns.begin_range] = node->begin_range;
- row[icon_columns.end_range] = node->end_range;
+ row[icon_columns.begin_range] = node.begin_range;
+ row[icon_columns.end_range] = node.end_range;
- switch (node->type) {
- case OSD_NODE:
- row[icon_columns.caption] =
- gen_osd_icon_caption(node->begin_range, node->end_range);
+ switch (node.type) {
+ case OSD_NODE:
+ row[icon_columns.caption] =
+ gen_osd_icon_caption(node.begin_range, node.end_range);
+ switch (node.status) {
+ case CEPH_OSD_OUT:
+ row[icon_columns.icon] = outOSDIcon;
+ break;
+ case CEPH_OSD_UP:
+ row[icon_columns.icon] = upOSDIcon;
+ break;
+ default: // ~CEPH_OSD_UP
+ row[icon_columns.icon] = downOSDIcon;
+ break;
+ }
+ break;
- switch (node->status) {
- case CEPH_OSD_OUT:
- row[icon_columns.icon] = outOSDIcon;
- break;
- case CEPH_OSD_UP:
- row[icon_columns.icon] = upOSDIcon;
- break;
- default: // ~CEPH_OSD_UP
- row[icon_columns.icon] = downOSDIcon;
- break;
- }
+ case MDS_NODE:
+ row[icon_columns.caption] = gen_mds_icon_caption(node.begin_range, node.end_range);
+ row[icon_columns.icon] = MDSIcon;
+ break;
- break;
- case MDS_NODE:
- row[icon_columns.caption] =
- gen_mds_icon_caption(node->begin_range, node->end_range);
- row[icon_columns.icon] = MDSIcon;
-
- break;
- case PG_NODE:
- row[icon_columns.caption] =
- gen_pg_icon_caption(node->begin_range, node->end_range);
- row[icon_columns.icon] = PGIcon;
-
- break;
- default:
- break;
- }
+ case PG_NODE:
+ row[icon_columns.caption] =
+ gen_pg_icon_caption(node.begin_range, node.end_range);
+ row[icon_columns.icon] = PGIcon;
+ break;
- delete node;
+ default:
+ break;
+ }
}
-
- nodeInfo.clear();
}
// Constructs a StatsWindowInfo object and opens a window containing the stats
open_stats(OSD_NODE, false, begin_range);
// Zoom in, since this is a range. Place the old icons on the stack
// and then call view_osd_icons() on the narrower range.
- vector<NodeInfo *> oldOSDInfo =
- gen_node_info_from_icons(guiMonitorOSDClusterIcons, OSD_NODE);
+ vector<NodeInfo> old_osd_info;
+ gen_node_info_from_icons(guiMonitorOSDClusterIcons, OSD_NODE, old_osd_info);
//Glib::RefPtr<Gtk::ListStore> oldOSDIcons(guiMonitorOSDClusterIcons);
- old_osd_cluster_zoom_states.push(oldOSDInfo);
+ old_osd_cluster_zoom_states.push(old_osd_info);
osd_cluster_zoom++;
guiMonitorOSDClusterBackButton->set_sensitive(true);
void GuiMonitor::osdc_cluster_back()
{
if (osd_cluster_zoom) {
- vector<NodeInfo *> oldOSDInfo = old_osd_cluster_zoom_states.top();
+ const vector<NodeInfo> &old_osd_info = old_osd_cluster_zoom_states.top();
+ gen_icons_from_node_info(old_osd_info);
old_osd_cluster_zoom_states.pop();
-
- gen_icons_from_node_info(oldOSDInfo);
osd_cluster_zoom--;
if (!osd_cluster_zoom) {
if (end_range - begin_range) {
// Zoom in, since this is a range. Place the old icons on the stack
// and then call viewMDSIcons() on the narrower range.
- vector<NodeInfo *> old_mds_info =
- gen_node_info_from_icons(guiMonitorMDSClusterIcons, MDS_NODE);
+ vector<NodeInfo> old_mds_info;
+ gen_node_info_from_icons(guiMonitorMDSClusterIcons, MDS_NODE, old_mds_info);
old_mds_cluster_zoom_states.push(old_mds_info);
mds_cluster_zoom++;
{
if (!mds_cluster_zoom)
return;
- vector<NodeInfo *> old_mds_info = old_mds_cluster_zoom_states.top();
- old_mds_cluster_zoom_states.pop();
-
+ const vector<NodeInfo> &old_mds_info = old_mds_cluster_zoom_states.top();
gen_icons_from_node_info(old_mds_info);
+ old_mds_cluster_zoom_states.pop();
mds_cluster_zoom--;
if (!mds_cluster_zoom) {
if (end_range - begin_range) {
// Zoom in, since this is a range. Place the old icons on the stack
// and then call viewPGIcons() on the narrower range.
- vector<NodeInfo *> oldPGInfo =
- gen_node_info_from_icons(guiMonitorPGClusterIcons, PG_NODE);
+ vector<NodeInfo> old_pg_info;
+ gen_node_info_from_icons(guiMonitorPGClusterIcons, PG_NODE, old_pg_info);
- old_pg_cluster_zoom_states.push(oldPGInfo);
+ old_pg_cluster_zoom_states.push(old_pg_info);
pg_cluster_zoom++;
guiMonitorPGClusterBackButton->set_sensitive(true);
{
if (!pg_cluster_zoom)
return;
- vector<NodeInfo *> oldPGInfo = old_pg_cluster_zoom_states.top();
+ const vector<NodeInfo> &old_pg_info = old_pg_cluster_zoom_states.top();
+ gen_icons_from_node_info(old_pg_info);
old_pg_cluster_zoom_states.pop();
-
- gen_icons_from_node_info(oldPGInfo);
pg_cluster_zoom--;
if (!pg_cluster_zoom) {
void update_pg_cluster_view();
void update_mon_cluster_view();
- std::string gen_osd_icon_caption(unsigned int begin, unsigned int end);
- std::string gen_mds_icon_caption(unsigned int begin, unsigned int end);
- std::string gen_pg_icon_caption(unsigned int begin, unsigned int end);
+ 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;
- std::vector<NodeInfo *> gen_node_info_from_icons
- (Glib::RefPtr<Gtk::ListStore> iconStore, enum NodeType type);
- void gen_icons_from_node_info(vector<NodeInfo *>& node_info);
+ 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);
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;
+ 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;