Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
duniter4j
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clients
java
duniter4j
Commits
b8c29e75
Commit
b8c29e75
authored
Feb 01, 2019
by
Benoit Lavenier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] Network CLI: change default timeout to 300ms
parent
0c207fd3
Pipeline
#4521
passed with stage
in 25 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
20 deletions
+41
-20
duniter4j-client/src/main/java/org/duniter/client/actions/NetworkAction.java
...c/main/java/org/duniter/client/actions/NetworkAction.java
+29
-11
duniter4j-client/src/main/java/org/duniter/client/actions/params/PeerParameters.java
...ava/org/duniter/client/actions/params/PeerParameters.java
+1
-1
duniter4j-client/src/main/resources/i18n/duniter4j-client_en_GB.properties
...src/main/resources/i18n/duniter4j-client_en_GB.properties
+2
-2
duniter4j-client/src/main/resources/i18n/duniter4j-client_fr_FR.properties
...src/main/resources/i18n/duniter4j-client_fr_FR.properties
+4
-4
duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/NetworkServiceImpl.java
...duniter/core/client/service/local/NetworkServiceImpl.java
+5
-2
No files found.
duniter4j-client/src/main/java/org/duniter/client/actions/NetworkAction.java
View file @
b8c29e75
...
...
@@ -81,17 +81,21 @@ public class NetworkAction extends AbstractAction {
final
Peer
mainPeer
=
peerParameters
.
getPeer
();
checkOutputFileIfNotNull
();
// make sure the file (if any) is writable
// Reducing node timeout when broadcast
if
(
peerParameters
.
timeout
!=
null
)
{
Configuration
.
instance
().
getApplicationConfig
().
setOption
(
ConfigurationOption
.
NETWORK_TIMEOUT
.
getKey
(),
peerParameters
.
timeout
.
toString
());
Configuration
config
=
Configuration
.
instance
();
// Configure network timeout
Integer
timeout
=
peerParameters
.
timeout
;
if
(
timeout
==
null
)
{
timeout
=
300
;
// Override default timeout to 300ms.
}
config
.
getApplicationConfig
().
setOption
(
ConfigurationOption
.
NETWORK_TIMEOUT
.
getKey
(),
timeout
.
toString
());
dateFormat
=
SimpleDateFormat
.
getDateTimeInstance
(
SimpleDateFormat
.
SHORT
,
SimpleDateFormat
.
MEDIUM
,
I18n
.
getDefaultLocale
());
console
=
new
RegexAnsiConsole
();
System
.
setOut
(
console
);
log
.
info
(
I18n
.
t
(
"duniter4j.client.network.loadingPeers"
));
log
.
info
(
I18n
.
t
(
"duniter4j.client.network.loadingPeers"
,
timeout
));
NetworkService
service
=
ServiceLocator
.
instance
().
getNetworkService
();
...
...
@@ -130,11 +134,14 @@ public class NetworkAction extends AbstractAction {
return
;
}
Peer
mainConsensusPeer
=
peers
.
iterator
().
next
();
Peer
.
Stats
mainConsensusStats
=
mainConsensusPeer
.
getStats
();
if
(
mainConsensusStats
.
isMainConsensus
())
{
Long
mediantTime
=
mainConsensusStats
.
getMedianTime
();
String
medianTime
=
dateFormat
.
format
(
new
Date
(
mediantTime
*
1000
));
Peer
.
Stats
mainConsensusStats
=
peers
.
stream
()
.
filter
(
p
->
p
.
getStats
()
!=
null
&&
p
.
getStats
().
getMedianTime
()
!=
null
&&
p
.
getStats
().
isMainConsensus
())
.
map
(
Peer:
:
getStats
)
.
findFirst
().
orElse
(
null
);
// Define color of main consensus info
if
(
mainConsensusStats
!=
null
)
{
String
medianTime
=
dateFormat
.
format
(
new
Date
(
mainConsensusStats
.
getMedianTime
()
*
1000
));
String
mainBuid
=
formatBuid
(
mainConsensusStats
);
console
.
reset
()
...
...
@@ -144,7 +151,7 @@ public class NetworkAction extends AbstractAction {
.
fgString
(
medianTime
,
Ansi
.
Color
.
GREEN
);
peers
.
stream
()
.
filter
(
peer
->
peer
.
getStats
().
isForkConsensus
())
.
filter
(
peer
->
peer
.
getStats
()
!=
null
&&
peer
.
getStats
()
.
isForkConsensus
())
.
map
(
peer
->
formatBuid
(
peer
.
getStats
()))
.
forEach
(
forkConsensusBuid
->
console
.
fgString
(
Formatters
.
formatBuid
(
forkConsensusBuid
),
Ansi
.
Color
.
YELLOW
));
...
...
@@ -175,7 +182,7 @@ public class NetworkAction extends AbstractAction {
peer
.
getStats
().
getStatus
().
name
(),
isUp
?
formatApi
(
peer
)
:
""
,
isUp
?
peer
.
getStats
().
getVersion
()
:
""
,
(
isUp
&&
peer
.
getStats
().
getHardshipLevel
()
!=
null
)
?
peer
.
getStats
().
getHardshipLevel
()
:
(
peer
.
getStats
().
getUid
()
==
null
?
I18n
.
t
(
"duniter4j.client.network.mirror"
)
:
""
)
,
isUp
?
formatHarshipLevel
(
peer
)
:
""
,
isUp
?
formatBuid
(
peer
.
getStats
())
:
""
};
})
...
...
@@ -253,4 +260,15 @@ public class NetworkAction extends AbstractAction {
return
peer
.
getApi
();
}
protected
String
formatHarshipLevel
(
Peer
peer
)
{
// Mirror
if
(
peer
.
getStats
().
getHardshipLevel
()
==
null
||
peer
.
getStats
().
getUid
()
==
null
)
{
return
I18n
.
t
(
"duniter4j.client.network.mirror"
);
}
if
(
peer
.
getStats
().
getHardshipLevel
()
==
0
)
{
return
"?"
;
}
return
peer
.
getStats
().
getHardshipLevel
().
toString
();
}
}
duniter4j-client/src/main/java/org/duniter/client/actions/params/PeerParameters.java
View file @
b8c29e75
...
...
@@ -46,7 +46,7 @@ public class PeerParameters {
public
boolean
useSsl
=
false
;
@Parameter
(
names
=
"--timeout"
,
description
=
"HTTP request timeout, in millisecond"
,
descriptionKey
=
"duniter4j.client.params.peer.timeout"
)
public
Long
timeout
=
null
;
public
Integer
timeout
=
null
;
private
Peer
peer
=
null
;
...
...
duniter4j-client/src/main/resources/i18n/duniter4j-client_en_GB.properties
View file @
b8c29e75
...
...
@@ -4,8 +4,8 @@ duniter4j.client.network.action=Display network peers
duniter4j.client.network.cesiumPlus
=
Cs+
duniter4j.client.network.error.outputFieNotWritable
=
Output file not writable
duniter4j.client.network.executionTime
=
Execution time
\:
%s ms
duniter4j.client.network.header
=
Main block [%1$s] computed at [%2$s] validated by [%3$3.2f%%] of
peers
duniter4j.client.network.loadingPeers
=
Reading network peers...
duniter4j.client.network.header
=
Head: block {%1$s} computed at %2$s (UTC time) validated by {%3$3.2f%%} of the
peers
duniter4j.client.network.loadingPeers
=
Reading network peers...
(timeout
\:
%s ms)
duniter4j.client.network.mirror
=
Mirror
duniter4j.client.network.noPeers
=
No peers found
duniter4j.client.network.params.continue
=
Continue scanning? (Will refresh on new peer/block).
...
...
duniter4j-client/src/main/resources/i18n/duniter4j-client_fr_FR.properties
View file @
b8c29e75
duniter4j.client.info.peer
=
Noeud Duniter
\:
[%s
\:
%s]
duniter4j.client.info.peer.fallback
=
Noeud Duniter
(par défaut)
\:
[%s
\:
%d]
duniter4j.client.info.peer
=
Noeud Duniter
{%s
\:
%s}
duniter4j.client.info.peer.fallback
=
Noeud Duniter
par défaut {%s
\:
%d}
duniter4j.client.network.action
=
Afficher les noeuds Duniter
duniter4j.client.network.cesiumPlus
=
Cs+
duniter4j.client.network.error.outputFieNotWritable
=
Fichier de sortie non inscriptible
duniter4j.client.network.executionTime
=
Temps d'execution
\:
%s ms
duniter4j.client.network.header
=
B
loc principal [%1$s] calculé à [%2$s] validé par [%3$3.2f%%]
des noeuds
duniter4j.client.network.loadingPeers
=
Lecture des noeuds du réseau...
duniter4j.client.network.header
=
B
ranche principale: bloc {%1$s} calculé à %2$s (heure UTC) validé par {%3$3.2f%%}
des noeuds
duniter4j.client.network.loadingPeers
=
Lecture des noeuds du réseau...
(Délai d'attente
\:
%s ms)
duniter4j.client.network.mirror
=
Mirroir
duniter4j.client.network.noPeers
=
Aucun noeud trouvé
duniter4j.client.network.params.continue
=
Continue scanning? (Will refresh on new peer/block).
...
...
duniter4j-core-client/src/main/java/org/duniter/core/client/service/local/NetworkServiceImpl.java
View file @
b8c29e75
...
...
@@ -417,8 +417,11 @@ public class NetworkServiceImpl extends BaseRemoteServiceImpl implements Network
lockManager
.
unlock
(
PEERS_UPDATE_LOCK_NAME
);
}
}
else
{
log
.
debug
(
"Could not acquire lock for reloading all peers. Skipping."
);
}
}
catch
(
InterruptedException
e
)
{
log
.
warn
(
"
Could not acquire lock for reloading all peers. Skipping."
);
log
.
warn
(
"
Stopping reloading all peers: "
+
e
.
getMessage
()
);
}
};
...
...
@@ -487,7 +490,7 @@ public class NetworkServiceImpl extends BaseRemoteServiceImpl implements Network
// If new block + wait 3s for network propagation
if
(
isNewBlock
)
{
schedule
(
loadAllPeers
,
pool
,
3000
/*waiting block propagation*/
);
schedule
(
loadAllPeers
,
pool
,
3000
/*waiting
3s, for
block propagation*/
);
}
}
catch
(
IOException
e
)
{
...
...
Write
Preview
Markdown
is supported
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