forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FAB-17890 Ch.Part.API: allow registrar to list a single channel (hype…
…rledger#1349) * FAB-17890 Ch.Part.API: allow registrar to list a single channel Implement the ChannelInfo(..) method in the registrar that looks up a channel in the chains map and reports extended information on its status. For this end we have to introduce the follower.Chain and augment existing cluster type chains with means of reporting their status. - Introduce the skeleton a new type of consensus.Chain implementation: follower.Chain. This will be created and run when the orderer is required to follow the cluster and pull blocks from other orderers. - The plan (for future commits) is for the follower.Chain to trigger the creation of an etcdraft.Chain when it discovers the orderer was added to the cluster, and vise versa; the etcdraft.Chain will replace itself with a follower.Chain when the orderer is removed from the cluster. - Introduce a new interface that cluster-type chains implement, that allows them to report their relation to the cluster and their status. This is done because the registrar is not aware of the exact type of the chains it is keeping. The registrar cannot reflect on the type as well, as this will cause an import cycle (due to the etcdraft package importing multichannel). Signed-off-by: Yoav Tock <[email protected]> Change-Id: Ia454f47f04a8ba3dcd76886a5919d1c734c01015 * Review comments: add constants Add typed constatnts for the possible values of ChannelInfo.Status & ChannelInfo.ClusterRelation. Signed-off-by: Yoav Tock <[email protected]> Change-Id: I71062b944d4e5236c4df1462fa73740b68e2065b * Review comments: improve documentation Document types.ClusterRelation and types.Status. Signed-off-by: Yoav Tock <[email protected]> Change-Id: I8171e6cfe6c3a137e7f1f48a14d1b2fe7f1aea5a
- Loading branch information
Showing
15 changed files
with
297 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package consensus | ||
|
||
import "github.com/hyperledger/fabric/orderer/common/types" | ||
|
||
// StatusReporter is implemented by cluster-type Chain implementations. | ||
// It allows the node to report its cluster relation and its status within that relation. | ||
// This information is used to generate the channelparticipation.ChannelInfo in response | ||
// to a "List" request on a particular channel. | ||
// | ||
// Not all chains must implement this, in particular non-cluster-type (solo, kafka) are | ||
// assigned a StaticStatusReporter at construction time. | ||
type StatusReporter interface { | ||
// StatusReport provides the cluster relation and status. | ||
// See: channelparticipation.ChannelInfo for more details. | ||
StatusReport() (types.ClusterRelation, types.Status) | ||
} | ||
|
||
// StaticStatusReporter is intended for chains that do not implement the StatusReporter interface. | ||
type StaticStatusReporter struct { | ||
ClusterRelation types.ClusterRelation | ||
Status types.Status | ||
} | ||
|
||
func (s StaticStatusReporter) StatusReport() (types.ClusterRelation, types.Status) { | ||
return s.ClusterRelation, s.Status | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package consensus_test | ||
|
||
import ( | ||
"github.com/hyperledger/fabric/orderer/common/types" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/orderer/consensus" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStaticStatusReporter(t *testing.T) { | ||
staticSR := &consensus.StaticStatusReporter{ | ||
ClusterRelation: types.ClusterRelationNone, | ||
Status: types.StatusActive, | ||
} | ||
|
||
var sr consensus.StatusReporter = staticSR // make sure it implements this interface | ||
cRel, status := sr.StatusReport() | ||
assert.Equal(t, types.ClusterRelationNone, cRel) | ||
assert.Equal(t, types.StatusActive, status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.