Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
f29f4bdb
Commit
f29f4bdb
authored
May 23, 2019
by
Georgios Bitzes
Browse files
Implement COMMAND-STATS to expose total number of reads/writes since startup
parent
1fb3c40f
Pipeline
#878558
passed with stages
in 38 minutes and 26 seconds
Changes
9
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/Commands.cc
View file @
f29f4bdb
...
...
@@ -35,6 +35,7 @@ struct cmdMapInit {
redis_cmd_map
[
"debug"
]
=
{
RedisCommand
::
DEBUG
,
CommandType
::
CONTROL
};
redis_cmd_map
[
"monitor"
]
=
{
RedisCommand
::
MONITOR
,
CommandType
::
CONTROL
};
redis_cmd_map
[
"client_id"
]
=
{
RedisCommand
::
CLIENT_ID
,
CommandType
::
CONTROL
};
redis_cmd_map
[
"command_stats"
]
=
{
RedisCommand
::
COMMAND_STATS
,
CommandType
::
CONTROL
};
redis_cmd_map
[
"auth"
]
=
{
RedisCommand
::
AUTH
,
CommandType
::
AUTHENTICATION
};
redis_cmd_map
[
"hmac_auth_generate_challenge"
]
=
{
RedisCommand
::
HMAC_AUTH_GENERATE_CHALLENGE
,
CommandType
::
AUTHENTICATION
};
...
...
src/Commands.hh
View file @
f29f4bdb
...
...
@@ -35,6 +35,7 @@ enum class RedisCommand {
DEBUG
,
MONITOR
,
CLIENT_ID
,
COMMAND_STATS
,
FLUSHALL
,
...
...
src/Formatter.cc
View file @
f29f4bdb
...
...
@@ -27,6 +27,7 @@
#include "Formatter.hh"
#include "redis/ArrayResponseBuilder.hh"
#include "redis/Transaction.hh"
#include "utils/Statistics.hh"
using
namespace
quarkdb
;
RedisEncodedResponse
Formatter
::
moved
(
int64_t
shardId
,
const
RaftServer
&
location
)
{
...
...
@@ -191,6 +192,14 @@ RedisEncodedResponse Formatter::multiply(const RedisEncodedResponse &resp, size_
return
RedisEncodedResponse
(
ss
.
str
());
}
RedisEncodedResponse
Formatter
::
stats
(
const
Statistics
&
stats
)
{
std
::
vector
<
std
::
string
>
arr
;
arr
.
emplace_back
(
SSTR
(
"TOTAL-READS "
<<
stats
.
reads
));
arr
.
emplace_back
(
SSTR
(
"TOTAL-WRITES "
<<
stats
.
writes
));
arr
.
emplace_back
(
SSTR
(
"TOTAL-BATCHES "
<<
stats
.
batches
));
return
statusVector
(
arr
);
}
RedisEncodedResponse
Formatter
::
subscribe
(
std
::
string_view
channel
,
size_t
active
)
{
return
strstrint
(
"subscribe"
,
channel
,
active
);
}
...
...
src/Formatter.hh
View file @
f29f4bdb
...
...
@@ -32,6 +32,7 @@ namespace quarkdb {
struct
RaftEntry
;
class
RedisRequest
;
struct
Statistics
;
class
Formatter
{
public:
...
...
@@ -64,6 +65,7 @@ public:
static
RedisEncodedResponse
redisRequest
(
const
RedisRequest
&
req
);
static
RedisEncodedResponse
multiply
(
const
RedisEncodedResponse
&
resp
,
size_t
factor
);
static
RedisEncodedResponse
stats
(
const
Statistics
&
stats
);
private:
static
RedisEncodedResponse
strstrint
(
std
::
string_view
str1
,
std
::
string_view
str2
,
int
num
);
...
...
src/Shard.cc
View file @
f29f4bdb
...
...
@@ -220,6 +220,15 @@ LinkStatus Shard::dispatch(Connection *conn, RedisRequest &req) {
return
conn
->
status
(
ss
.
str
());
}
case
RedisCommand
::
COMMAND_STATS
:
{
if
(
req
.
size
()
!=
1
)
return
conn
->
errArgs
(
req
[
0
]);
InFlightRegistration
registration
(
inFlightTracker
);
if
(
!
registration
.
ok
())
{
return
conn
->
err
(
"unavailable"
);
}
return
conn
->
raw
(
Formatter
::
stats
(
stateMachine
->
commandStats
()));
}
default:
{
if
(
req
.
getCommandType
()
==
CommandType
::
QUARKDB
)
{
qdb_critical
(
"Unable to dispatch command '"
<<
req
[
0
]
<<
"' of type QUARKDB"
);
...
...
src/StateMachine.cc
View file @
f29f4bdb
...
...
@@ -1786,12 +1786,18 @@ std::string StateMachine::statistics() {
return
stats
;
}
//------------------------------------------------------------------------------
// Get level stats
//------------------------------------------------------------------------------
std
::
string
StateMachine
::
levelStats
()
{
std
::
string
stats
;
db
->
GetProperty
(
rocksdb
::
DB
::
Properties
::
kLevelStats
,
&
stats
);
return
stats
;
}
//------------------------------------------------------------------------------
// Get compression stats
//------------------------------------------------------------------------------
std
::
vector
<
std
::
string
>
StateMachine
::
compressionStats
()
{
std
::
vector
<
std
::
string
>
results
;
...
...
@@ -1804,6 +1810,13 @@ std::vector<std::string> StateMachine::compressionStats() {
return
results
;
}
//------------------------------------------------------------------------------
// Get command stats
//------------------------------------------------------------------------------
Statistics
StateMachine
::
commandStats
()
{
return
requestCounter
.
getOverallStats
();
}
rocksdb
::
Status
StateMachine
::
noop
(
LogIndex
index
)
{
StagingArea
stagingArea
(
*
this
);
return
stagingArea
.
commit
(
index
);
...
...
src/StateMachine.hh
View file @
f29f4bdb
...
...
@@ -243,6 +243,11 @@ public:
//----------------------------------------------------------------------------
std
::
vector
<
std
::
string
>
compressionStats
();
//----------------------------------------------------------------------------
// Get command stats
//----------------------------------------------------------------------------
Statistics
commandStats
();
bool
inBulkLoad
()
const
{
return
bulkLoad
;
}
...
...
src/utils/RequestCounter.cc
View file @
f29f4bdb
...
...
@@ -65,6 +65,10 @@ void RequestCounter::setReportingStatus(bool val) {
activated
=
val
;
}
Statistics
RequestCounter
::
getOverallStats
()
{
return
aggregator
.
getOverallStats
();
}
void
RequestCounter
::
mainThread
(
ThreadAssistant
&
assistant
)
{
while
(
!
assistant
.
terminationRequested
())
{
...
...
src/utils/RequestCounter.hh
View file @
f29f4bdb
...
...
@@ -48,6 +48,8 @@ public:
void
setReportingStatus
(
bool
val
);
void
account
(
const
RedisRequest
&
req
);
Statistics
getOverallStats
();
private:
void
account
(
const
RedisRequest
&
req
,
Statistics
*
stats
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment