mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 15:20:21 +00:00
showStats
This commit is contained in:
parent
5893d17131
commit
04e62337da
@ -18,6 +18,7 @@ func askAllAndSend(peer: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInte
|
||||
|
||||
|
||||
func findAndAskNeighboursSchema(
|
||||
knownPeers: []PeerId,
|
||||
clientId: PeerId,
|
||||
collectPeerInfo: PeerInfoCb,
|
||||
collectServiceInterface: ServiceInterfaceCb,
|
||||
@ -61,7 +62,8 @@ func getAll(
|
||||
-- in order to temporarily reduce the number of particles sent to client
|
||||
-- we gather data from the known peers only.
|
||||
-- Known peers are explicitly represent the whole network atm
|
||||
-- for peer <- knownPeers par:
|
||||
-- askAllAndSend(peer, collectPeerInfo, collectServiceInterface)
|
||||
for peer <- knownPeers par:
|
||||
on peer:
|
||||
askAllAndSend(peer, collectPeerInfo, collectServiceInterface)
|
||||
|
||||
co findAndAskNeighboursSchema(%init_peer_id%, collectPeerInfo, collectServiceInterface, logNeighs, logFail)
|
||||
-- co findAndAskNeighboursSchema(%init_peer_id%, collectPeerInfo, collectServiceInterface, logNeighs, logFail)
|
||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"version": "0.1.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.15.4",
|
||||
"@fluencelabs/fluence": "0.16.0",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.13",
|
||||
"css-spinners": "^1.0.1",
|
||||
"tachyons": "^4.12.0",
|
||||
@ -1339,20 +1339,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.17.8",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.17.8.tgz",
|
||||
"integrity": "sha512-g4tNo0P/DlfE4tru3j4jlQ8aBbQkEY1aVE+xK+/LMr126L9Jma9ILykleVl7T1RhVZInvCwuw4gmv7P23bsUqA==",
|
||||
"version": "0.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.3.tgz",
|
||||
"integrity": "sha512-KvrQrh41dpKzYzgbozmTykwD/E3me3Boiz7rC/zjs5xma738YibjymCV30ZXMfe3iNT5JlXsj3LJML6HlkjNfA==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.15.4.tgz",
|
||||
"integrity": "sha512-rWt+o7PQUTHZa2dqo1B0mfKasncTIeV6rwCWHRdmlkkSsdV99Z0EOOqx/3hYk0DCRhF7NWY+8EhwfDSku/wcgg==",
|
||||
"version": "0.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.16.0.tgz",
|
||||
"integrity": "sha512-eQOm+ZfEmAmH0b8mzn4+O6RG3WHrNKMvxmamu8ePpSugTkmuQ4vqq9CtQKxstTSqoountRlw2E376oIGs5tLVA==",
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "^0.17.7",
|
||||
"@fluencelabs/avm": "^0.19.3",
|
||||
"async": "3.2.0",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
@ -19329,20 +19329,20 @@
|
||||
"dev": true
|
||||
},
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.17.8",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.17.8.tgz",
|
||||
"integrity": "sha512-g4tNo0P/DlfE4tru3j4jlQ8aBbQkEY1aVE+xK+/LMr126L9Jma9ILykleVl7T1RhVZInvCwuw4gmv7P23bsUqA==",
|
||||
"version": "0.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.19.3.tgz",
|
||||
"integrity": "sha512-KvrQrh41dpKzYzgbozmTykwD/E3me3Boiz7rC/zjs5xma738YibjymCV30ZXMfe3iNT5JlXsj3LJML6HlkjNfA==",
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.15.4.tgz",
|
||||
"integrity": "sha512-rWt+o7PQUTHZa2dqo1B0mfKasncTIeV6rwCWHRdmlkkSsdV99Z0EOOqx/3hYk0DCRhF7NWY+8EhwfDSku/wcgg==",
|
||||
"version": "0.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.16.0.tgz",
|
||||
"integrity": "sha512-eQOm+ZfEmAmH0b8mzn4+O6RG3WHrNKMvxmamu8ePpSugTkmuQ4vqq9CtQKxstTSqoountRlw2E376oIGs5tLVA==",
|
||||
"requires": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "^0.17.7",
|
||||
"@fluencelabs/avm": "^0.19.3",
|
||||
"async": "3.2.0",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
|
@ -31,7 +31,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/fluence-admin#readme",
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.15.4",
|
||||
"@fluencelabs/fluence": "0.16.0",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.13",
|
||||
"css-spinners": "^1.0.1",
|
||||
"tachyons": "^4.12.0",
|
||||
|
2
src/_aqua/app.d.ts
vendored
2
src/_aqua/app.d.ts
vendored
@ -55,6 +55,7 @@ export function askAllAndSend(
|
||||
|
||||
|
||||
export function findAndAskNeighboursSchema(
|
||||
knownPeers: string[],
|
||||
clientId: string,
|
||||
collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>,
|
||||
collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>,
|
||||
@ -65,6 +66,7 @@ export function findAndAskNeighboursSchema(
|
||||
|
||||
export function findAndAskNeighboursSchema(
|
||||
peer: FluencePeer,
|
||||
knownPeers: string[],
|
||||
clientId: string,
|
||||
collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>,
|
||||
collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>,
|
||||
|
113
src/_aqua/app.js
113
src/_aqua/app.js
@ -255,7 +255,10 @@ export function findAndAskNeighboursSchema(...args) {
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "clientId") [] clientId)
|
||||
)
|
||||
(xor
|
||||
@ -356,6 +359,12 @@ export function findAndAskNeighboursSchema(...args) {
|
||||
"tag" : "void"
|
||||
},
|
||||
"argDefs" : [
|
||||
{
|
||||
"name" : "knownPeers",
|
||||
"argType" : {
|
||||
"tag" : "primitive"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "clientId",
|
||||
"argType" : {
|
||||
@ -507,98 +516,54 @@ export function getAll(...args) {
|
||||
)
|
||||
(xor
|
||||
(par
|
||||
(xor
|
||||
(seq
|
||||
(call -relay- ("kad" "neighborhood") [%init_peer_id% [] []] neighbors)
|
||||
(par
|
||||
(fold neighbors n
|
||||
(par
|
||||
(xor
|
||||
(fold knownPeers peer
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call n ("kad" "neighborhood") [n [] []] neighbors2)
|
||||
(par
|
||||
(fold neighbors2 n2
|
||||
(par
|
||||
(new $status
|
||||
(seq
|
||||
(call n ("peer" "connect") [n2 []] connected)
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(par
|
||||
(xor
|
||||
(match connected true
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(par
|
||||
(seq
|
||||
(xor
|
||||
(seq
|
||||
(call n2 ("peer" "identify") [])
|
||||
(ap "done" $status)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
)
|
||||
(call n ("op" "noop") [])
|
||||
)
|
||||
(null)
|
||||
)
|
||||
(call n ("peer" "timeout") [1000 "timedout"] $status)
|
||||
)
|
||||
(xor
|
||||
(match $status.$.[0]! "done"
|
||||
(xor
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "logFail") ["success" n2])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "logFail") ["timed out" n2])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
|
||||
)
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "logFail") ["failed to connect" n2])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
|
||||
)
|
||||
(call %init_peer_id% ("callbackSrv" "logFail") [peer "on"])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
(null)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(next n2)
|
||||
(call peer ("peer" "identify") [] ident)
|
||||
)
|
||||
(call peer ("dist" "list_blueprints") [] blueprints)
|
||||
)
|
||||
(null)
|
||||
(call peer ("dist" "list_modules") [] modules)
|
||||
)
|
||||
(call peer ("srv" "list") [] services)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 7])
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
(next n)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
(null)
|
||||
)
|
||||
(next peer)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 8])
|
||||
)
|
||||
(null)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 9])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 10])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
|
||||
)
|
||||
`
|
||||
return callFunction(
|
||||
|
124
src/index.js
124
src/index.js
@ -30,7 +30,7 @@ import { askAllAndSend, getAll } from './_aqua/app';
|
||||
const defaultNetworkName = 'testNet + krasnodar';
|
||||
|
||||
const defaultEnv = {
|
||||
relays: [...testNet, ...krasnodar, ...stage],
|
||||
relays: [...krasnodar, ...testNet, ...stage],
|
||||
relayIdx: 2,
|
||||
logLevel: 'info',
|
||||
};
|
||||
@ -119,6 +119,118 @@ function genFlags(peerId, relays, relayIdx) {
|
||||
const flags = genFlags(pid, relays, relayIdx);
|
||||
console.log(`Own peer id: ${pid}`);
|
||||
|
||||
if (window) {
|
||||
window.collectedData = {
|
||||
// service ids
|
||||
services: new Map(),
|
||||
// services per creator
|
||||
creators: new Map(),
|
||||
// blueprints used in services
|
||||
serviceBlueprints: new Set(),
|
||||
// all blueprints
|
||||
blueprints: new Map(),
|
||||
// module hashes used in services
|
||||
serviceModules: new Set(),
|
||||
// unique module names used in services
|
||||
moduleNames: new Set(),
|
||||
// all modules
|
||||
modules: new Map(),
|
||||
// peer infos per PeerId
|
||||
peerInfos: new Map(),
|
||||
};
|
||||
|
||||
window.showStat = () => {
|
||||
/*
|
||||
1490 users created 3018 services
|
||||
from 280 blueprints
|
||||
from 299 modules of which there are 43 unique module names
|
||||
*/
|
||||
let usersCount = window.collectedData.creators.size;
|
||||
let serviceCount = window.collectedData.services.size;
|
||||
let blueprintCount = window.collectedData.serviceBlueprints.size;
|
||||
let moduleCount = window.collectedData.serviceModules.size;
|
||||
let nameCount = window.collectedData.moduleNames.size;
|
||||
let totalModules = window.collectedData.modules.size;
|
||||
|
||||
console.log(`${usersCount} users created ${serviceCount} services`);
|
||||
console.log(`from ${blueprintCount} blueprints`);
|
||||
console.log(`from ${moduleCount} modules of which there are ${nameCount} unique module names`);
|
||||
console.log(`total ${totalModules} modules were uploaded`);
|
||||
|
||||
let servicesPerHost = new Map();
|
||||
for (let service of window.collectedData.services.values()) {
|
||||
let perHost = servicesPerHost.has(service.host) ? servicesPerHost.get(service.host) : new Set();
|
||||
perHost.add(service.id);
|
||||
servicesPerHost.set(service.host, perHost);
|
||||
}
|
||||
|
||||
let N = 10;
|
||||
let sorted = [...servicesPerHost.entries()].sort((a, b) => b[1].size - a[1].size);
|
||||
console.log(`top ${N} nodes by hosted services:`)
|
||||
let slice = sorted.slice(0, 10);
|
||||
for (let entry of slice) {
|
||||
console.log(`\t node ${entry[0]} has ${entry[1].size} services`);
|
||||
}
|
||||
|
||||
let byNodeVersion = new Map();
|
||||
let byAirVersion = new Map();
|
||||
for (let info of window.collectedData.peerInfos.values()) {
|
||||
let byNodeCount = byNodeVersion.get(info.node_version) || 0;
|
||||
byNodeVersion.set(info.node_version, byNodeCount + 1)
|
||||
let byAirCount = byAirVersion.get(info.air_version) || 0;
|
||||
byAirVersion.set(info.air_version, byAirCount + 1)
|
||||
}
|
||||
|
||||
console.log("Nodes version distribution:");
|
||||
for (let entry of byNodeVersion.entries()) {
|
||||
let version = entry[0];
|
||||
let count = entry[1];
|
||||
console.log(`\t${version}: ${count} nodes`);
|
||||
}
|
||||
|
||||
console.log("AIR intepreter versions distribution:");
|
||||
for (let entry of byAirVersion.entries()) {
|
||||
let version = entry[0];
|
||||
let count = entry[1];
|
||||
console.log(`\t${version}: ${count} nodes`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function collectStats(peerId, identify, services, blueprints, modules) {
|
||||
if (window) {
|
||||
window.collectedData.peerInfos.set(peerId, identify);
|
||||
|
||||
for (let blueprint of blueprints) {
|
||||
window.collectedData.blueprints.set(blueprint.id, blueprint);
|
||||
}
|
||||
|
||||
for (let module of modules) {
|
||||
window.collectedData.modules.set(module.hash, module);
|
||||
}
|
||||
|
||||
for (let service of services) {
|
||||
service.host = peerId;
|
||||
window.collectedData.services.set(service.id, service);
|
||||
window.collectedData.serviceBlueprints.add(service.blueprint_id);
|
||||
|
||||
let blueprint = window.collectedData.blueprints.get(service.blueprint_id);
|
||||
for (let prefixedHash of blueprint.dependencies) {
|
||||
let moduleHash = prefixedHash.split(':')[1];
|
||||
window.collectedData.serviceModules.add(moduleHash);
|
||||
|
||||
let module = window.collectedData.modules.get(moduleHash);
|
||||
window.collectedData.moduleNames.add(module.name);
|
||||
}
|
||||
|
||||
let perCreator = window.collectedData.creators.has(service.owner_id) ? window.collectedData.creators.get(service.owner_id) : new Set();
|
||||
perCreator.add(service.id);
|
||||
window.collectedData.creators.set(service.owner_id, perCreator);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If the relay is ever changed, an event shall be sent to elm
|
||||
|
||||
const app = Elm.Main.init({
|
||||
@ -143,6 +255,14 @@ function genFlags(peerId, relays, relayIdx) {
|
||||
}
|
||||
|
||||
// alias PeerInfoCb: PeerId, Info, []Service, []Blueprint, []Module -> ()
|
||||
// {
|
||||
// "aliases": [
|
||||
// "aqua-dht"
|
||||
// ],
|
||||
// "blueprint_id": "577c7cbfc3e96b401e5fb424094ed9118b947162bb38f4ead5702597711c2151",
|
||||
// "id": "99be2f7a-2f43-4732-8259-e5b187ecbafa",
|
||||
// "owner_id": "12D3KooWST6zQwqN6UCTuLAAV8mJL3wbrmPeiPaYXcuUdUT4XZs3"
|
||||
// }
|
||||
function collectPeerInfo(peerId, identify, services, blueprints, modules, interfaces) {
|
||||
console.log('peer info from %s, %s services', peerId, services.length);
|
||||
try {
|
||||
@ -154,6 +274,8 @@ function genFlags(peerId, relays, relayIdx) {
|
||||
modules,
|
||||
};
|
||||
|
||||
collectStats(peerId, identify, services, blueprints, modules,);
|
||||
|
||||
app.ports.collectPeerInfo.send(eventRaw);
|
||||
} catch (err) {
|
||||
log.error('Elm eventreceiver failed: ', err);
|
||||
|
Loading…
Reference in New Issue
Block a user