Skip to content
Snippets Groups Projects
Commit e17f9d49 authored by vjrj's avatar vjrj
Browse files

Select more updated Cesium Plus node

parent cf4f60c1
No related branches found
No related tags found
No related merge requests found
...@@ -427,10 +427,25 @@ Future<NodeCheck> _pingNode(String node, NodeType type) async { ...@@ -427,10 +427,25 @@ Future<NodeCheck> _pingNode(String node, NodeType type) async {
} }
} else if (type == NodeType.cesiumPlus) { } else if (type == NodeType.cesiumPlus) {
// see: http://g1.data.e-is.pro/network/peering // see: http://g1.data.e-is.pro/network/peering
await http final Response response = await http
.get(Uri.parse('$node/network/peering')) .get(Uri.parse('$node/node/stats'))
// Decrease http timeout during ping // Decrease http timeout during ping
.timeout(timeout); .timeout(timeout);
if (response.statusCode == 200) {
try {
final Map<String, dynamic> json =
jsonDecode(response.body.replaceAll('"cluster"{', '"cluster": {'))
as Map<String, dynamic>;
currentBlock = ((((json['stats'] as Map<String, dynamic>)['cluster']
as Map<String, dynamic>)['indices']
as Map<String, dynamic>)['docs']
as Map<String, dynamic>)['count'] as int;
} catch (e) {
loggerDev('Cannot parse node/stats $e');
}
} else {
latency = wrongNodeDuration;
}
stopwatch.stop(); stopwatch.stop();
latency = stopwatch.elapsed; latency = stopwatch.elapsed;
} else { } else {
......
...@@ -38,7 +38,7 @@ class DebugNodeList extends StatelessWidget { ...@@ -38,7 +38,7 @@ class DebugNodeList extends StatelessWidget {
title: Text(node.url), title: Text(node.url),
subtitle: node.latency < wrongNode subtitle: node.latency < wrongNode
? Text( ? Text(
'${type != NodeType.cesiumPlus ? 'Current block: ${node.currentBlock}, ' : ''}errors: ${node.errors}, latency (ms): ${node.latency}') '${type != NodeType.cesiumPlus ? 'Current block: ${node.currentBlock}, ' : 'Current docs: ${node.currentBlock}, '}errors: ${node.errors}, latency (ms): ${node.latency}')
: null, : null,
leading: node.currentBlock == currentBlock && leading: node.currentBlock == currentBlock &&
node.latency < wrongNode node.latency < wrongNode
......
...@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev ...@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.2.3 version: 0.2.4-SNAPSHOT
environment: environment:
sdk: ">=2.17.1 <3.0.0" sdk: ">=2.17.1 <3.0.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment