~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/db/stats/top.cpp

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
 
18
18
 
19
 
#include "pch.h"
20
 
#include "top.h"
21
 
#include "../../util/net/message.h"
22
 
#include "../commands.h"
 
19
#include "mongo/pch.h"
 
20
 
 
21
#include "mongo/db/stats/top.h"
 
22
 
 
23
#include "mongo/db/auth/action_set.h"
 
24
#include "mongo/db/auth/action_type.h"
 
25
#include "mongo/db/auth/privilege.h"
 
26
#include "mongo/util/net/message.h"
 
27
#include "mongo/db/commands.h"
23
28
 
24
29
namespace mongo {
25
30
 
43
48
    }
44
49
 
45
50
    void Top::record( const StringData& ns , int op , int lockType , long long micros , bool command ) {
46
 
        if ( ns.data()[0] == '?' )
 
51
        if ( ns[0] == '?' )
47
52
            return;
48
53
 
49
54
        //cout << "record: " << ns << "\t" << op << "\t" << command << endl;
50
55
        SimpleMutex::scoped_lock lk(_lock);
51
56
 
52
 
        if ( ( command || op == dbQuery ) && str::equals( ns.data(), _lastDropped.c_str() ) ) {
 
57
        if ( ( command || op == dbQuery ) && ns == _lastDropped ) {
53
58
            _lastDropped = "";
54
59
            return;
55
60
        }
56
61
 
57
 
        CollectionData& coll = _usage[ns.data()];
 
62
        CollectionData& coll = _usage[ns];
58
63
        _record( coll , op , lockType , micros , command );
59
64
        _record( _global , op , lockType , micros , command );
60
65
    }
119
124
    }
120
125
 
121
126
    void Top::_appendToUsageMap( BSONObjBuilder& b , const UsageMap& map ) const {
122
 
        for ( UsageMap::const_iterator i=map.begin(); i!=map.end(); i++ ) {
123
 
            BSONObjBuilder bb( b.subobjStart( i->first ) );
124
 
 
125
 
            const CollectionData& coll = i->second;
 
127
        // pull all the names into a vector so we can sort them for the user
 
128
        
 
129
        vector<string> names;
 
130
        for ( UsageMap::const_iterator i = map.begin(); i != map.end(); ++i ) {
 
131
            names.push_back( i->first );
 
132
        }
 
133
        
 
134
        std::sort( names.begin(), names.end() );
 
135
 
 
136
        for ( size_t i=0; i<names.size(); i++ ) {
 
137
            BSONObjBuilder bb( b.subobjStart( names[i] ) );
 
138
 
 
139
            const CollectionData& coll = map.find(names[i])->second;
126
140
 
127
141
            _appendStatsEntry( b , "total" , coll.total );
128
142
 
155
169
        virtual bool adminOnly() const { return true; }
156
170
        virtual LockType locktype() const { return NONE; }
157
171
        virtual void help( stringstream& help ) const { help << "usage by collection, in micros "; }
158
 
 
 
172
        virtual void addRequiredPrivileges(const std::string& dbname,
 
173
                                           const BSONObj& cmdObj,
 
174
                                           std::vector<Privilege>* out) {
 
175
            ActionSet actions;
 
176
            actions.addAction(ActionType::top);
 
177
            out->push_back(Privilege(AuthorizationManager::SERVER_RESOURCE_NAME, actions));
 
178
        }
159
179
        virtual bool run(const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
160
180
            {
161
181
                BSONObjBuilder b( result.subobjStart( "totals" ) );