Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Crystal Michelle Chua
QuarkDB
Commits
8786aad3
Commit
8786aad3
authored
Apr 27, 2018
by
Crystal Chua
Browse files
adding quarkdb-health redis command, currently displays free space left
parent
4d4b5510
Pipeline
#369208
passed with stages
in 16 minutes and 43 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Commands.cc
View file @
8786aad3
...
...
@@ -97,6 +97,7 @@ struct cmdMapInit {
redis_cmd_map
[
"activate_stale_reads"
]
=
{
RedisCommand
::
ACTIVATE_STALE_READS
,
CommandType
::
RAFT
};
redis_cmd_map
[
"quarkdb_info"
]
=
{
RedisCommand
::
QUARKDB_INFO
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_health"
]
=
{
RedisCommand
::
QUARKDB_HEALTH
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_detach"
]
=
{
RedisCommand
::
QUARKDB_DETACH
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_attach"
]
=
{
RedisCommand
::
QUARKDB_ATTACH
,
CommandType
::
QUARKDB
};
redis_cmd_map
[
"quarkdb_start_resilvering"
]
=
{
RedisCommand
::
QUARKDB_START_RESILVERING
,
CommandType
::
QUARKDB
};
...
...
src/Commands.hh
View file @
8786aad3
...
...
@@ -101,6 +101,7 @@ enum class RedisCommand {
ACTIVATE_STALE_READS
,
QUARKDB_INFO
,
QUARKDB_HEALTH
,
QUARKDB_DETACH
,
QUARKDB_ATTACH
,
QUARKDB_START_RESILVERING
,
...
...
src/QuarkDBNode.cc
View file @
8786aad3
...
...
@@ -31,6 +31,7 @@
#include "utils/TimeFormatting.hh"
#include <sys/stat.h>
#include <sys/statvfs.h>
using
namespace
quarkdb
;
...
...
@@ -98,6 +99,9 @@ LinkStatus QuarkDBNode::dispatch(Connection *conn, RedisRequest &req) {
case
RedisCommand
::
QUARKDB_INFO
:
{
return
conn
->
statusVector
(
this
->
info
().
toVector
());
}
case
RedisCommand
::
QUARKDB_HEALTH
:
{
return
conn
->
statusVector
(
this
->
health
().
toVector
());
}
default:
{
return
shard
->
dispatch
(
conn
,
req
);
}
...
...
@@ -119,3 +123,22 @@ std::vector<std::string> QuarkDBInfo::toVector() const {
ret
.
emplace_back
(
SSTR
(
"UPTIME "
<<
uptime
<<
" ("
<<
formatTime
(
std
::
chrono
::
seconds
(
uptime
))
<<
")"
));
return
ret
;
}
QuarkDBHealth
QuarkDBNode
::
health
()
{
struct
statvfs
buf
;
// add some error checking pls
statvfs
(
configuration
.
getDatabase
().
c_str
(),
&
buf
);
double
freeSpace
=
((
buf
.
f_bfree
*
1.
)
/
buf
.
f_blocks
)
*
100.
;
return
{
freeSpace
};
}
std
::
vector
<
std
::
string
>
QuarkDBHealth
::
toVector
()
const
{
std
::
vector
<
std
::
string
>
ret
;
ret
.
emplace_back
(
SSTR
(
"FREE-SPACE "
<<
freeSpace
<<
"%"
));
ret
.
emplace_back
(
SSTR
(
"RAFT-STABILITY placeholder"
));
ret
.
emplace_back
(
SSTR
(
"NODE-STATUS placeholder"
));
return
ret
;
}
src/QuarkDBNode.hh
View file @
8786aad3
...
...
@@ -44,6 +44,12 @@ struct QuarkDBInfo {
std
::
vector
<
std
::
string
>
toVector
()
const
;
};
struct
QuarkDBHealth
{
double
freeSpace
;
std
::
vector
<
std
::
string
>
toVector
()
const
;
};
class
Shard
;
class
ShardDirectory
;
class
MultiOp
;
class
QuarkDBNode
:
public
Dispatcher
{
...
...
@@ -70,6 +76,8 @@ private:
QuarkDBInfo
info
();
QuarkDBHealth
health
();
std
::
atomic
<
bool
>
shutdown
{
false
};
const
RaftTimeouts
timeouts
;
...
...
tools/quarkdb-create.cc
View file @
8786aad3
...
...
@@ -74,7 +74,7 @@ bool verify_options_sane(option::Parser &parse, std::vector<option::Option> &opt
std
::
vector
<
option
::
Option
>
parse_args
(
int
argc
,
char
**
argv
)
{
const
option
::
Descriptor
usage
[]
=
{
{
Opt
::
UNKNOWN
,
0
,
""
,
""
,
option
::
Arg
::
None
,
"Tool to initialize new quarkdb nodes.
\n
"
"USAGE: quarkdb-
journal
[options]
\n\n
"
"Options:"
},
"USAGE: quarkdb-
create
[options]
\n\n
"
"Options:"
},
{
Opt
::
HELP
,
0
,
""
,
"help"
,
option
::
Arg
::
None
,
" --help
\t
Print usage and exit."
},
{
Opt
::
PATH
,
0
,
""
,
"path"
,
Opt
::
nonempty
,
" --path
\t
the directory where the journal lives in."
},
{
Opt
::
CLUSTERID
,
0
,
""
,
"clusterID"
,
Opt
::
nonempty
,
" --clusterID
\t
specify the identifier for the new cluster - should be globally unique."
},
...
...
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