示例#1
0
    void ExplorerReplicaSetFolderItem::on_repSetStatus()
    {
        if (!_server->replicaSetInfo()->primary.empty()) {
            openCurrentServerShell(_server, "rs.status()");
        }
        else // primary is unreachable
        {
            // Todo: do this before 
            // Run rs.status only if there is a reachable secondary
            mongo::HostAndPort onlineMember;
            for (auto const& member : _server->replicaSetInfo()->membersAndHealths) {
                if (member.second) {
                    onlineMember = mongo::HostAndPort(member.first);
                    break;
                }
            }
            if (onlineMember.empty())   // todo: throw error
                return;

            auto connSetting = _server->connectionRecord()->clone();    // todo: unique_ptr
            // Set connection settings of this replica member
            connSetting->setConnectionName(onlineMember.toString() + 
                                           " [member of " + connSetting->connectionName() + "]");
            connSetting->setServerHost(onlineMember.host());
            connSetting->setServerPort(onlineMember.port());
            connSetting->setReplicaSet(false);
            connSetting->replicaSetSettings()->setMembers(std::vector<std::string>()); 

            openCurrentServerShell(_server, connSetting, "rs.status()");
        }
    }
 void ExplorerServerTreeItem::ui_openShell()
 {
     openCurrentServerShell(_server,"");
 }
 void ExplorerServerTreeItem::ui_showLog()
 {
     openCurrentServerShell(_server,"show log");
 }
 void ExplorerServerTreeItem::ui_serverVersion()
 {
     openCurrentServerShell(_server,"db.version()");
 }
 void ExplorerServerTreeItem::ui_serverStatus()
 {
     openCurrentServerShell(_server,"db.serverStatus()");
 }
 void ExplorerServerTreeItem::ui_serverHostInfo()
 {
     openCurrentServerShell(_server,"db.hostInfo()");
 }
void ExplorerReplicaSetTreeItem::ui_openShell()
{
    openCurrentServerShell(_server, _connSettings.get(), "");
}
void ExplorerReplicaSetTreeItem::ui_showLog()
{
    openCurrentServerShell(_server, _connSettings.get(), "show log");
}
void ExplorerReplicaSetTreeItem::ui_serverVersion()
{
    openCurrentServerShell(_server, _connSettings.get(), "db.version()");
}
void ExplorerReplicaSetTreeItem::ui_serverHostInfo()
{
    openCurrentServerShell(_server, _connSettings.get(), "db.hostInfo()");
}