Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE-331 Display health status of peers and orderers- Backend #337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions app/platform/fabric/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Proxy {
async getPeersStatus(network_id, channel_genesis_hash) {
const client = await this.platform.getClient(network_id);
const channel_name = client.getChannelNameByHash(channel_genesis_hash);
let orderersList = await client.fabricGateway.getActiveOrderersList(channel_name);
const nodes = await this.persistence
.getMetricService()
.getPeerList(network_id, channel_genesis_hash);
Expand All @@ -123,9 +124,10 @@ export class Proxy {
const peers = [];

for (const node of nodes) {
node.status = "";
if (node.peer_type === 'PEER') {
node.status = 'DOWN';
if (discover_results && discover_results.peers_by_org) {
node.status = "DOWN";
const org = discover_results.peers_by_org[node.mspid];
if (org === undefined) {
continue;
Expand All @@ -135,23 +137,35 @@ export class Proxy {
node.ledger_height_low = peer.ledgerHeight.low;
node.ledger_height_high = peer.ledgerHeight.high;
node.ledger_height_unsigned = peer.ledgerHeight.unsigned;
node.status = 'UP';
}
}
}
// Sometime 'peers_by_org' property is not included in discover result
if(typeof node.ledger_height_low === 'undefined')
if (typeof node.ledger_height_low === 'undefined') {
node.ledger_height_low = '-';
if(typeof node.ledger_height_high === 'undefined')
}
if (typeof node.ledger_height_high === 'undefined') {
node.ledger_height_high = '-';
if(typeof node.ledger_height_unsigned === 'undefined')
}
if (typeof node.ledger_height_unsigned === 'undefined') {
node.ledger_height_unsigned = '-';
}
peers.push(node);
} else if (node.peer_type === 'ORDERER') {
node.status = 'DOWN';
node.ledger_height_low = '-';
node.ledger_height_high = '-';
node.ledger_height_unsigned = '-';
peers.push(node);
let orderersCount = orderersList.length;
if (orderersCount != 0) {
for (const orderer of orderersList) {
if (orderer.name === node.requests && orderer.connected == true) {
node.status = 'UP';
}
}
}
peers.push(node);
}
}

Expand Down
13 changes: 13 additions & 0 deletions app/platform/fabric/gateway/FabricGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,17 @@ export class FabricGateway {

return null;
}

async getActiveOrderersList(channel_name) {
const network = await this.gateway.getNetwork(channel_name);
let orderers = [];
for (let [orderer, ordererMetadata] of network.discoveryService.channel.committers) {
let ordererAtrributes = {
name: orderer,
connected: ordererMetadata.connected
}
orderers.push(ordererAtrributes);
}
return orderers;
}
}