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
172b1089
Commit
172b1089
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dht: search log improvements
parent
6cdc242b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dht.cpp
+32
-47
32 additions, 47 deletions
src/dht.cpp
with
32 additions
and
47 deletions
src/dht.cpp
+
32
−
47
View file @
172b1089
...
@@ -295,7 +295,7 @@ struct Dht::Search {
...
@@ -295,7 +295,7 @@ struct Dht::Search {
/**
/**
* @return The number of non-good search nodes.
* @return The number of non-good search nodes.
*/
*/
unsigned
getNumberOfBadNodes
();
unsigned
getNumberOfBadNodes
()
const
;
/**
/**
* ret = 0 : no announce required.
* ret = 0 : no announce required.
...
@@ -703,12 +703,8 @@ Dht::searchSendGetValues(std::shared_ptr<Search> sr, SearchNode* pn, bool update
...
@@ -703,12 +703,8 @@ Dht::searchSendGetValues(std::shared_ptr<Search> sr, SearchNode* pn, bool update
auto
onExpired
=
auto
onExpired
=
[
this
,
ws
](
const
Request
&
status
,
bool
over
)
mutable
{
[
this
,
ws
](
const
Request
&
status
,
bool
over
)
mutable
{
if
(
auto
sr
=
ws
.
lock
())
{
if
(
auto
sr
=
ws
.
lock
())
{
if
(
auto
srn
=
sr
->
getNode
(
status
.
node
))
{
if
(
auto
srn
=
sr
->
getNode
(
status
.
node
))
/*DHT_LOG.DEBUG("[search %s IPv%c] [node %s] 'get' expired",
sr->id.toString().c_str(), sr->af == AF_INET ? '4' : '6',
srn->node->toString().c_str());*/
srn
->
candidate
=
not
over
;
srn
->
candidate
=
not
over
;
}
scheduler
.
edit
(
sr
->
nextSearchStep
,
scheduler
.
time
());
scheduler
.
edit
(
sr
->
nextSearchStep
,
scheduler
.
time
());
}
}
};
};
...
@@ -933,7 +929,7 @@ Dht::Search::isSynced(time_point now) const
...
@@ -933,7 +929,7 @@ Dht::Search::isSynced(time_point now) const
return
i
>
0
;
return
i
>
0
;
}
}
unsigned
Dht
::
Search
::
getNumberOfBadNodes
()
{
unsigned
Dht
::
Search
::
getNumberOfBadNodes
()
const
{
return
std
::
count_if
(
nodes
.
begin
(),
nodes
.
end
(),
return
std
::
count_if
(
nodes
.
begin
(),
nodes
.
end
(),
[
=
](
const
SearchNode
&
sn
)
{
return
sn
.
isBad
();
}
[
=
](
const
SearchNode
&
sn
)
{
return
sn
.
isBad
();
}
);
);
...
@@ -1890,15 +1886,17 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
...
@@ -1890,15 +1886,17 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
{
{
const
auto
&
now
=
scheduler
.
time
();
const
auto
&
now
=
scheduler
.
time
();
using
namespace
std
::
chrono
;
using
namespace
std
::
chrono
;
out
<<
std
::
endl
<<
"Search IPv"
<<
(
sr
.
af
==
AF_INET6
?
'6'
:
'4'
)
<<
' '
<<
sr
.
id
<<
"
G
"
<<
sr
.
callbacks
.
size
();
out
<<
std
::
endl
<<
"Search IPv"
<<
(
sr
.
af
==
AF_INET6
?
'6'
:
'4'
)
<<
' '
<<
sr
.
id
<<
"
gets:
"
<<
sr
.
callbacks
.
size
();
out
<<
" age "
<<
duration_cast
<
seconds
>
(
now
-
sr
.
step_time
).
count
()
<<
"
s
s
ync ops: "
<<
sr
.
currentGetRequests
()
;
out
<<
"
,
age
:
"
<<
duration_cast
<
seconds
>
(
now
-
sr
.
step_time
).
count
()
<<
" s
"
;
if
(
sr
.
done
)
if
(
sr
.
done
)
out
<<
" [done]"
;
out
<<
" [done]"
;
if
(
sr
.
expired
)
out
<<
" [expired]"
;
bool
synced
=
sr
.
isSynced
(
now
);
bool
synced
=
sr
.
isSynced
(
now
);
out
<<
(
synced
?
" [synced]"
:
" [not synced]"
);
out
<<
(
synced
?
" [synced]"
:
" [not synced]"
);
if
(
synced
&&
sr
.
isListening
(
now
))
{
if
(
synced
&&
sr
.
isListening
(
now
))
{
auto
lt
=
sr
.
getListenTime
(
now
);
auto
lt
=
sr
.
getListenTime
(
now
);
out
<<
" [listening, next in "
<<
duration_cast
<
minute
s
>
(
lt
-
now
).
count
()
<<
"
min
]"
;
out
<<
" [listening, next in "
<<
duration_cast
<
second
s
>
(
lt
-
now
).
count
()
<<
"
s
]"
;
}
}
out
<<
std
::
endl
;
out
<<
std
::
endl
;
...
@@ -1907,46 +1905,37 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
...
@@ -1907,46 +1905,37 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
out
<<
"Announcement: "
<<
*
n
.
value
<<
(
announced
?
" [announced]"
:
""
)
<<
std
::
endl
;
out
<<
"Announcement: "
<<
*
n
.
value
<<
(
announced
?
" [announced]"
:
""
)
<<
std
::
endl
;
}
}
out
<<
" Common bits InfoHash
Conn. Get
Put
IP"
<<
std
::
endl
;
out
<<
" Common bits InfoHash Conn. Get
Ops
IP"
<<
std
::
endl
;
unsigned
i
=
0
;
unsigned
i
=
0
;
auto
last_get
=
sr
.
getLastGetTime
();
auto
last_get
=
sr
.
getLastGetTime
();
for
(
const
auto
&
n
:
sr
.
nodes
)
{
for
(
const
auto
&
n
:
sr
.
nodes
)
{
i
++
;
i
++
;
out
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
3
)
<<
InfoHash
::
commonBits
(
sr
.
id
,
n
.
node
->
id
)
<<
' '
<<
n
.
node
->
id
;
out
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
3
)
<<
InfoHash
::
commonBits
(
sr
.
id
,
n
.
node
->
id
)
<<
' '
<<
n
.
node
->
id
;
out
<<
' '
<<
(
findNode
(
n
.
node
->
id
,
AF_INET
)
||
findNode
(
n
.
node
->
id
,
AF_INET6
)
?
'*'
:
' '
);
out
<<
' '
<<
(
findNode
(
n
.
node
->
id
,
sr
.
af
)
?
'*'
:
' '
);
out
<<
' '
<<
(
n
.
candidate
?
'c'
:
' '
);
out
<<
" ["
;
out
<<
" ["
if
(
auto
pendingCount
=
n
.
node
->
getPendingMessageCount
())
<<
(
n
.
node
->
isMessagePending
()
?
'f'
:
' '
);
out
<<
pendingCount
;
else
out
<<
' '
;
out
<<
' '
;
out
<<
(
n
.
node
->
isExpired
()
?
'x'
:
' '
)
<<
"]"
;
out
<<
(
n
.
node
->
isExpired
()
?
'x'
:
' '
)
<<
"]"
;
// Get status
{
{
bool
pending
{
false
},
expired
{
false
};
char
g_i
=
(
n
.
getStatus
&&
n
.
getStatus
->
pending
())
?
(
n
.
candidate
?
'c'
:
'f'
)
:
' '
;
if
(
n
.
getStatus
)
{
char
s_i
=
n
.
isSynced
(
now
)
?
(
n
.
last_get_reply
>
last_get
?
'u'
:
's'
)
:
'-'
;
pending
=
n
.
getStatus
->
pending
();
out
<<
" ["
<<
s_i
<<
g_i
<<
"] "
;
expired
=
n
.
getStatus
->
expired
();
}
out
<<
" ["
<<
(
pending
?
'f'
:
(
expired
?
'x'
:
' '
))
<<
(
n
.
isSynced
(
now
)
?
's'
:
'-'
)
<<
((
n
.
last_get_reply
>
last_get
)
?
'u'
:
'-'
)
<<
"] "
;
}
}
{
// Listen status
bool
pending
{
false
},
expired
{
false
};
if
(
not
sr
.
listeners
.
empty
())
{
if
(
n
.
listenStatus
)
{
if
(
not
n
.
listenStatus
)
pending
=
n
.
listenStatus
->
pending
();
expired
=
n
.
listenStatus
->
expired
();
}
if
(
not
sr
.
listeners
.
empty
()
and
n
.
listenStatus
)
{
/*if (!n.listenStatus)
out
<<
" "
;
out
<<
" "
;
else
*/
else
out
<<
"["
out
<<
"["
<<
(
pending
?
'f'
:
(
expired
?
'x'
:
' '
))
<<
(
n
.
isListening
(
now
)
?
'l'
:
(
n
.
listenStatus
->
pending
()
?
'f'
:
' '
))
<<
"] "
;
<<
(
n
.
isListening
(
now
)
?
'l'
:
'-'
)
<<
"] "
;
}
}
}
// Announce status
if
(
not
sr
.
announce
.
empty
())
{
if
(
not
sr
.
announce
.
empty
())
{
if
(
n
.
acked
.
empty
())
{
if
(
n
.
acked
.
empty
())
{
out
<<
" "
;
out
<<
" "
;
...
@@ -1956,18 +1945,13 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
...
@@ -1956,18 +1945,13 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const
out
<<
"["
;
out
<<
"["
;
for
(
const
auto
&
a
:
sr
.
announce
)
{
for
(
const
auto
&
a
:
sr
.
announce
)
{
auto
ack
=
n
.
acked
.
find
(
a
.
value
->
id
);
auto
ack
=
n
.
acked
.
find
(
a
.
value
->
id
);
if
(
ack
==
n
.
acked
.
end
())
{
if
(
ack
==
n
.
acked
.
end
()
or
not
ack
->
second
)
{
out
<<
' '
;
out
<<
' '
;
}
else
{
}
else
{
auto
&
astatus
=
ack
->
second
;
if
(
ack
->
second
->
reply_time
+
getType
(
a
.
value
->
type
).
expiration
>
now
)
if
(
astatus
and
astatus
->
reply_time
+
getType
(
a
.
value
->
type
).
expiration
>
now
)
out
<<
'a'
;
out
<<
'a'
;
else
if
(
a
status
and
astatus
->
pending
())
else
if
(
a
ck
->
second
->
pending
())
out
<<
'f'
;
out
<<
'f'
;
else
if
(
astatus
and
astatus
->
expired
())
out
<<
'x'
;
else
out
<<
' '
;
}
}
}
}
out
<<
"] "
;
out
<<
"] "
;
...
@@ -2012,6 +1996,7 @@ Dht::getStorageLog() const
...
@@ -2012,6 +1996,7 @@ Dht::getStorageLog() const
std
::
stringstream
out
;
std
::
stringstream
out
;
for
(
const
auto
&
st
:
store
)
{
for
(
const
auto
&
st
:
store
)
{
out
<<
"Storage "
<<
st
.
id
<<
" "
<<
st
.
listeners
.
size
()
<<
" list., "
<<
st
.
valueCount
()
<<
" values ("
<<
st
.
totalSize
()
<<
" bytes)"
<<
std
::
endl
;
out
<<
"Storage "
<<
st
.
id
<<
" "
<<
st
.
listeners
.
size
()
<<
" list., "
<<
st
.
valueCount
()
<<
" values ("
<<
st
.
totalSize
()
<<
" bytes)"
<<
std
::
endl
;
if
(
not
st
.
local_listeners
.
empty
())
out
<<
" "
<<
st
.
local_listeners
.
size
()
<<
" local listeners"
<<
std
::
endl
;
out
<<
" "
<<
st
.
local_listeners
.
size
()
<<
" local listeners"
<<
std
::
endl
;
for
(
const
auto
&
l
:
st
.
listeners
)
{
for
(
const
auto
&
l
:
st
.
listeners
)
{
out
<<
" "
<<
"Listener "
<<
l
.
first
->
toString
();
out
<<
" "
<<
"Listener "
<<
l
.
first
->
toString
();
...
...
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