Skip to content

Commit

Permalink
BE-829 Distinguish each node with both IP and Port (#203)
Browse files Browse the repository at this point in the history
Signed-off-by: Atsushi Neki <atsushin@fast.au.fujitsu.com>
  • Loading branch information
nekia authored Nov 30, 2020
1 parent ba7739a commit 8b8ddc6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 40 deletions.
15 changes: 4 additions & 11 deletions app/platform/fabric/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Proxy {
continue;
}
for (const peer of org.peers) {
if (peer.endpoint.indexOf(node.server_hostname) > -1) {
if (peer.endpoint === node.requests) {
node.ledger_height_low = peer.ledgerHeight.low;
node.ledger_height_high = peer.ledgerHeight.high;
node.ledger_height_unsigned = peer.ledgerHeight.unsigned;
Expand All @@ -141,16 +141,9 @@ export class Proxy {
peers.push(node);
} else if (node.peer_type === 'ORDERER') {
node.status = 'DOWN';
if (discover_results && discover_results.orderers) {
const org = discover_results.orderers[node.mspid];
for (const endpoint of org.endpoints) {
if (endpoint.host.indexOf(node.server_hostname) > -1) {
node.ledger_height_low = '-';
node.ledger_height_high = '-';
node.ledger_height_unsigned = '-';
}
}
}
node.ledger_height_low = '-';
node.ledger_height_high = '-';
node.ledger_height_unsigned = '-';
peers.push(node);
}
}
Expand Down
26 changes: 7 additions & 19 deletions app/platform/fabric/sync/SyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,29 +212,18 @@ export class SyncServices {
* @memberof SyncServices
*/
async insertNewPeer(peer, channel_genesis_hash, client) {
let eventurl = '';
let requesturl = peer.endpoint;
const network_id = client.getNetworkId();
const host_port = peer.endpoint.split(':');
const peers = client.getNetworkConfig().peers;
if (peers && peers[host_port[0]] && peers[host_port[0]].url) {
requesturl = peers[host_port[0]].url;
}
if (peers && peers[host_port[0]] && peers[host_port[0]].eventUrl) {
eventurl = peers[host_port[0]].eventUrl;
}

const peer_row = {
mspid: peer.mspid,
requests: requesturl.replace(/^grpcs*:\/\//, ''),
events: eventurl,
server_hostname: host_port[0],
requests: peer.endpoint,
server_hostname: peer.endpoint,
channel_genesis_hash,
peer_type: 'PEER'
};
await this.persistence.getCrudService().savePeer(network_id, peer_row);
const channel_peer_row = {
peerid: host_port[0],
peerid: peer.endpoint,
channelid: channel_genesis_hash
};
await this.persistence
Expand All @@ -253,7 +242,7 @@ export class SyncServices {
async insertNewOrderers(orderer, channel_genesis_hash, client) {
const network_id = client.getNetworkId();
const discoveryProtocol = client.fabricGateway.getDiscoveryProtocol();
const requesturl = `${discoveryProtocol}://${orderer.host}:${orderer.port}`;
const requesturl = `${orderer.host}:${orderer.port}`;
logger.debug(
'insertNewOrderers discoveryProtocol ',
discoveryProtocol,
Expand All @@ -263,8 +252,8 @@ export class SyncServices {

const orderer_row = {
mspid: orderer.org_name,
requests: requesturl.replace(/^grpcs*:\/\//, ''),
server_hostname: orderer.host,
requests: requesturl,
server_hostname: requesturl,
channel_genesis_hash,
peer_type: 'ORDERER'
};
Expand Down Expand Up @@ -351,11 +340,10 @@ export class SyncServices {
channel_genesis_hash
) {
const network_id = client.getNetworkId();
const host_port = endpoint.split(':');
const chaincode_peer_row = {
chaincodeid: chaincode.name,
cc_version: chaincode.version,
peerid: host_port[0],
peerid: endpoint,
channelid: channel_genesis_hash
};
await this.persistence
Expand Down
10 changes: 5 additions & 5 deletions client/e2e-test/specs/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ function test() {
const peerUrlStrList = peerUrlList.map((elm, idx, array) => {
return elm.getText();
});
expect(peerUrlStrList).to.include('peer0-org1');
expect(peerUrlStrList).to.include('peer1-org1');
expect(peerUrlStrList).to.include('peer0-org2');
expect(peerUrlStrList).to.include('orderer0-ordererorg1');
expect(peerUrlStrList).to.include('orderer1-ordererorg1');
expect(peerUrlStrList).to.include('peer0-org1:31000');
expect(peerUrlStrList).to.include('peer1-org1:31001');
expect(peerUrlStrList).to.include('peer0-org2:31002');
expect(peerUrlStrList).to.include('orderer0-ordererorg1:30000');
expect(peerUrlStrList).to.include('orderer1-ordererorg1:30001');
});
});

Expand Down
10 changes: 5 additions & 5 deletions client/e2e-test/specs/network/network_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function test() {
const nodeStrList = nodeLists.map((elm, idx, array) => {
return elm.getText();
});
expect(nodeStrList).to.include('peer0-org1');
expect(nodeStrList).to.include('peer1-org1');
expect(nodeStrList).to.include('peer0-org2');
expect(nodeStrList).to.include('orderer0-ordererorg1');
expect(nodeStrList).to.include('orderer1-ordererorg1');
expect(nodeStrList).to.include('peer0-org1:31000');
expect(nodeStrList).to.include('peer1-org1:31001');
expect(nodeStrList).to.include('peer0-org2:31002');
expect(nodeStrList).to.include('orderer0-ordererorg1:30000');
expect(nodeStrList).to.include('orderer1-ordererorg1:30001');
});
});
});
Expand Down

0 comments on commit 8b8ddc6

Please sign in to comment.