Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
c10c4251
Commit
c10c4251
authored
7 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
proxy server: print stats to stdout once in a while
parent
8b90c473
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dht_proxy_server.h
+2
-0
2 additions, 0 deletions
include/opendht/dht_proxy_server.h
src/dht_proxy_server.cpp
+8
-0
8 additions, 0 deletions
src/dht_proxy_server.cpp
with
10 additions
and
0 deletions
include/opendht/dht_proxy_server.h
+
2
−
0
View file @
c10c4251
...
@@ -230,6 +230,8 @@ private:
...
@@ -230,6 +230,8 @@ private:
Scheduler
scheduler_
;
Scheduler
scheduler_
;
std
::
thread
schedulerThread_
;
std
::
thread
schedulerThread_
;
Sp
<
Scheduler
::
Job
>
printStatsJob_
;
// Handle client quit for listen.
// Handle client quit for listen.
// NOTE: can be simplified when we will supports restbed 5.0
// NOTE: can be simplified when we will supports restbed 5.0
std
::
thread
listenThread_
;
std
::
thread
listenThread_
;
...
...
This diff is collapsed.
Click to expand it.
src/dht_proxy_server.cpp
+
8
−
0
View file @
c10c4251
...
@@ -45,6 +45,7 @@ struct DhtProxyServer::SearchPuts {
...
@@ -45,6 +45,7 @@ struct DhtProxyServer::SearchPuts {
std
::
map
<
dht
::
Value
::
Id
,
PermanentPut
>
puts
;
std
::
map
<
dht
::
Value
::
Id
,
PermanentPut
>
puts
;
};
};
constexpr
const
std
::
chrono
::
minutes
PRINT_STATS_PERIOD
{
2
};
DhtProxyServer
::
DhtProxyServer
(
std
::
shared_ptr
<
DhtRunner
>
dht
,
in_port_t
port
,
const
std
::
string
&
pushServer
)
DhtProxyServer
::
DhtProxyServer
(
std
::
shared_ptr
<
DhtRunner
>
dht
,
in_port_t
port
,
const
std
::
string
&
pushServer
)
:
dht_
(
dht
)
,
pushServer_
(
pushServer
)
:
dht_
(
dht
)
,
pushServer_
(
pushServer
)
...
@@ -122,6 +123,12 @@ DhtProxyServer::DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port ,
...
@@ -122,6 +123,12 @@ DhtProxyServer::DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port ,
while
(
not
service_
->
is_up
()
and
not
stopListeners
)
{
while
(
not
service_
->
is_up
()
and
not
stopListeners
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
1
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
1
));
}
}
printStatsJob_
=
scheduler_
.
add
(
scheduler_
.
time
()
+
PRINT_STATS_PERIOD
,
[
this
]{
if
(
service_
->
is_up
()
and
not
stopListeners
)
{
std
::
cout
<<
getStats
().
toString
()
<<
std
::
endl
;
scheduler_
.
edit
(
printStatsJob_
,
scheduler_
.
time
()
+
PRINT_STATS_PERIOD
);
}
});
while
(
service_
->
is_up
()
and
not
stopListeners
)
{
while
(
service_
->
is_up
()
and
not
stopListeners
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
schedulerLock_
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
schedulerLock_
);
auto
next
=
scheduler_
.
run
();
auto
next
=
scheduler_
.
run
();
...
@@ -143,6 +150,7 @@ DhtProxyServer::~DhtProxyServer()
...
@@ -143,6 +150,7 @@ DhtProxyServer::~DhtProxyServer()
void
void
DhtProxyServer
::
stop
()
DhtProxyServer
::
stop
()
{
{
printStatsJob_
->
cancel
();
service_
->
stop
();
service_
->
stop
();
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lockListener_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
lockListener_
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment