Skip to content

Commit 96de525

Browse files
author
Luis Sanchez
committed
[FAB-1241] Rename BatchSize configuration parameter
Subtask of FAB-1171 - In orderer.yaml, renamed General.BatchSize to General.BatchSize.MaxMessageCount. - In shared config, changed type of BatchSize from unit32 to *ab.BatchSize. These previously checked-in generated proto go source files did not match the output of `make protos`, so I'm checking them in now: msp/identities.pb.go protos/msp/mspconfig.pb.go This generated proto go source file was not previously checked in: core/crypto/attributes/proto/attributes.pb.go Change-Id: Ice3d398f191eaaeaaae8c3ce9d5612100a76b582 Signed-off-by: Luis Sanchez <[email protected]>
1 parent 6e9073c commit 96de525

File tree

18 files changed

+205
-94
lines changed

18 files changed

+205
-94
lines changed

core/crypto/attributes/proto/attributes.pb.go

+85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

msp/identities.pb.go

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

orderer/common/blockcutter/blockcutter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (r *receiver) Ordered(msg *cb.Envelope) ([][]*cb.Envelope, [][]filter.Commi
9090
r.curBatch = append(r.curBatch, msg)
9191
r.batchComs = append(r.batchComs, committer)
9292

93-
if uint32(len(r.curBatch)) < r.sharedConfigManager.BatchSize() {
93+
if uint32(len(r.curBatch)) < r.sharedConfigManager.BatchSize().MaxMessageCount {
9494
return nil, nil, true
9595
}
9696

orderer/common/blockcutter/blockcutter_test.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/hyperledger/fabric/orderer/common/filter"
2424
mocksharedconfig "github.com/hyperledger/fabric/orderer/mocks/sharedconfig"
2525
cb "github.com/hyperledger/fabric/protos/common"
26+
ab "github.com/hyperledger/fabric/protos/orderer"
2627
)
2728

2829
type isolatedCommitter struct{}
@@ -73,8 +74,8 @@ var unmatchedTx = &cb.Envelope{Payload: []byte("UNMATCHED")}
7374

7475
func TestNormalBatch(t *testing.T) {
7576
filters := getFilters()
76-
batchSize := uint32(2)
77-
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: batchSize}, filters)
77+
maxMessageCount := uint32(2)
78+
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount}}, filters)
7879

7980
batches, committers, ok := r.Ordered(goodTx)
8081

@@ -100,8 +101,8 @@ func TestNormalBatch(t *testing.T) {
100101

101102
func TestBadMessageInBatch(t *testing.T) {
102103
filters := getFilters()
103-
batchSize := uint32(2)
104-
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: batchSize}, filters)
104+
maxMessageCount := uint32(2)
105+
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount}}, filters)
105106

106107
batches, committers, ok := r.Ordered(badTx)
107108

@@ -136,8 +137,8 @@ func TestBadMessageInBatch(t *testing.T) {
136137

137138
func TestUnmatchedMessageInBatch(t *testing.T) {
138139
filters := getFilters()
139-
batchSize := uint32(2)
140-
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: batchSize}, filters)
140+
maxMessageCount := uint32(2)
141+
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount}}, filters)
141142

142143
batches, committers, ok := r.Ordered(unmatchedTx)
143144

@@ -172,8 +173,8 @@ func TestUnmatchedMessageInBatch(t *testing.T) {
172173

173174
func TestIsolatedEmptyBatch(t *testing.T) {
174175
filters := getFilters()
175-
batchSize := uint32(2)
176-
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: batchSize}, filters)
176+
maxMessageCount := uint32(2)
177+
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount}}, filters)
177178

178179
batches, committers, ok := r.Ordered(isolatedTx)
179180

@@ -196,8 +197,8 @@ func TestIsolatedEmptyBatch(t *testing.T) {
196197

197198
func TestIsolatedPartialBatch(t *testing.T) {
198199
filters := getFilters()
199-
batchSize := uint32(2)
200-
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: batchSize}, filters)
200+
maxMessageCount := uint32(2)
201+
r := NewReceiverImpl(&mocksharedconfig.Manager{BatchSizeVal: &ab.BatchSize{MaxMessageCount: maxMessageCount}}, filters)
201202

202203
batches, committers, ok := r.Ordered(goodTx)
203204

orderer/common/bootstrap/provisional/item.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (cbs *commonBootstrapper) encodeConsensusType() *cb.SignedConfigurationItem
3737

3838
func (cbs *commonBootstrapper) encodeBatchSize() *cb.SignedConfigurationItem {
3939
configItemKey := sharedconfig.BatchSizeKey
40-
configItemValue := utils.MarshalOrPanic(&ab.BatchSize{Messages: cbs.batchSize})
40+
configItemValue := utils.MarshalOrPanic(cbs.batchSize)
4141
modPolicy := configtx.DefaultModificationPolicyID
4242

4343
configItemChainHeader := utils.MakeChainHeader(cb.HeaderType_CONFIGURATION_ITEM, msgVersion, cbs.chainID, epoch)

orderer/common/bootstrap/provisional/provisional.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/hyperledger/fabric/orderer/common/bootstrap"
2323
"github.com/hyperledger/fabric/orderer/localconfig"
2424
cb "github.com/hyperledger/fabric/protos/common"
25+
ab "github.com/hyperledger/fabric/protos/orderer"
2526
"github.com/hyperledger/fabric/protos/utils"
2627
)
2728

@@ -55,7 +56,7 @@ var DefaultChainCreators = []string{AcceptAllPolicyKey}
5556
type commonBootstrapper struct {
5657
chainID string
5758
consensusType string
58-
batchSize uint32
59+
batchSize *ab.BatchSize
5960
}
6061

6162
type soloBootstrapper struct {
@@ -72,7 +73,9 @@ func New(conf *config.TopLevel) bootstrap.Helper {
7273
cbs := &commonBootstrapper{
7374
chainID: TestChainID,
7475
consensusType: conf.General.OrdererType,
75-
batchSize: conf.General.BatchSize,
76+
batchSize: &ab.BatchSize{
77+
MaxMessageCount: conf.General.BatchSize.MaxMessageCount,
78+
},
7679
}
7780

7881
switch conf.General.OrdererType {

orderer/common/sharedconfig/sharedconfig.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type Manager interface {
5858
ConsensusType() string
5959

6060
// BatchSize returns the maximum number of messages to include in a block
61-
BatchSize() uint32
61+
BatchSize() *ab.BatchSize
6262

6363
// ChainCreators returns the policy names which are allowed for chain creation
6464
// This field is only set for the system ordering chain
@@ -72,7 +72,7 @@ type Manager interface {
7272

7373
type ordererConfig struct {
7474
consensusType string
75-
batchSize uint32
75+
batchSize *ab.BatchSize
7676
chainCreators []string
7777
kafkaBrokers []string
7878
}
@@ -97,7 +97,7 @@ func (pm *ManagerImpl) ConsensusType() string {
9797
}
9898

9999
// BatchSize returns the maximum number of messages to include in a block
100-
func (pm *ManagerImpl) BatchSize() uint32 {
100+
func (pm *ManagerImpl) BatchSize() *ab.BatchSize {
101101
return pm.config.batchSize
102102
}
103103

@@ -164,10 +164,10 @@ func (pm *ManagerImpl) ProposeConfig(configItem *cb.ConfigurationItem) error {
164164
return fmt.Errorf("Unmarshaling error for BatchSize: %s", err)
165165
}
166166

167-
if batchSize.Messages <= 0 {
168-
return fmt.Errorf("Attempted to set the batch size to %d which is less than or equal to 0", batchSize.Messages)
167+
if batchSize.MaxMessageCount <= 0 {
168+
return fmt.Errorf("Attempted to set the batch size max message count to %d which is less than or equal to 0", batchSize.MaxMessageCount)
169169
}
170-
pm.pendingConfig.batchSize = batchSize.Messages
170+
pm.pendingConfig.batchSize = batchSize
171171
case ChainCreatorsKey:
172172
chainCreators := &ab.ChainCreators{}
173173
err := proto.Unmarshal(configItem.Value, chainCreators)

orderer/common/sharedconfig/sharedconfig_test.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ func TestConsensusType(t *testing.T) {
125125
}
126126

127127
func TestBatchSize(t *testing.T) {
128-
endBatchSize := uint32(10)
128+
endBatchSize := struct{ MaxMessageCount uint32 }{
129+
MaxMessageCount: uint32(10),
130+
}
129131
invalidMessage := &cb.ConfigurationItem{
130132
Type: cb.ConfigurationItem_Orderer,
131133
Key: BatchSizeKey,
@@ -134,12 +136,12 @@ func TestBatchSize(t *testing.T) {
134136
zeroBatchSize := &cb.ConfigurationItem{
135137
Type: cb.ConfigurationItem_Orderer,
136138
Key: BatchSizeKey,
137-
Value: utils.MarshalOrPanic(&ab.BatchSize{Messages: 0}),
139+
Value: utils.MarshalOrPanic(&ab.BatchSize{MaxMessageCount: 0}),
138140
}
139141
validMessage := &cb.ConfigurationItem{
140142
Type: cb.ConfigurationItem_Orderer,
141143
Key: BatchSizeKey,
142-
Value: utils.MarshalOrPanic(&ab.BatchSize{Messages: endBatchSize}),
144+
Value: utils.MarshalOrPanic(&ab.BatchSize{MaxMessageCount: endBatchSize.MaxMessageCount}),
143145
}
144146
m := NewManagerImpl()
145147
m.BeginConfig()
@@ -161,8 +163,12 @@ func TestBatchSize(t *testing.T) {
161163

162164
m.CommitConfig()
163165

164-
if nowBatchSize := m.BatchSize(); nowBatchSize != endBatchSize {
165-
t.Fatalf("Got batch size of %d when expecting batch size of %d", nowBatchSize, endBatchSize)
166+
nowBatchSize := struct{ MaxMessageCount uint32 }{
167+
MaxMessageCount: m.BatchSize().MaxMessageCount,
168+
}
169+
170+
if nowBatchSize.MaxMessageCount != endBatchSize.MaxMessageCount {
171+
t.Fatalf("Got batch size max message count of %d. Expected: %d", nowBatchSize.MaxMessageCount, endBatchSize.MaxMessageCount)
166172
}
167173
}
168174

orderer/kafka/config_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ var testConf = &config.TopLevel{
4242
OrdererType: "kafka",
4343
LedgerType: "ram",
4444
BatchTimeout: 500 * time.Millisecond,
45-
BatchSize: 100,
4645
QueueSize: 100,
4746
MaxWindowSize: 100,
4847
ListenAddress: "127.0.0.1",
4948
ListenPort: 7050,
5049
GenesisMethod: "provisional",
50+
BatchSize: config.BatchSize{
51+
MaxMessageCount: 100,
52+
},
5153
},
5254
Kafka: config.Kafka{
5355
Brokers: []string{"127.0.0.1:9092"},

orderer/localconfig/config.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@ type General struct {
4242
OrdererType string
4343
LedgerType string
4444
BatchTimeout time.Duration
45-
BatchSize uint32
4645
QueueSize uint32
4746
MaxWindowSize uint32
4847
ListenAddress string
4948
ListenPort uint16
5049
GenesisMethod string
50+
BatchSize BatchSize
5151
Profile Profile
5252
}
5353

54+
// BatchSize contains configuration affecting the size of batches
55+
type BatchSize struct {
56+
MaxMessageCount uint32
57+
}
58+
5459
// Profile contains configuration for Go pprof profiling
5560
type Profile struct {
5661
Enabled bool
@@ -99,12 +104,14 @@ var defaults = TopLevel{
99104
OrdererType: "solo",
100105
LedgerType: "ram",
101106
BatchTimeout: 10 * time.Second,
102-
BatchSize: 10,
103107
QueueSize: 1000,
104108
MaxWindowSize: 1000,
105109
ListenAddress: "127.0.0.1",
106110
ListenPort: 7050,
107111
GenesisMethod: "provisional",
112+
BatchSize: BatchSize{
113+
MaxMessageCount: 10,
114+
},
108115
Profile: Profile{
109116
Enabled: false,
110117
Address: "0.0.0.0:6060",
@@ -142,9 +149,9 @@ func (c *TopLevel) completeInitialization() {
142149
case c.General.BatchTimeout == 0:
143150
logger.Infof("General.BatchTimeout unset, setting to %s", defaults.General.BatchTimeout)
144151
c.General.BatchTimeout = defaults.General.BatchTimeout
145-
case c.General.BatchSize == 0:
146-
logger.Infof("General.BatchSize unset, setting to %s", defaults.General.BatchSize)
147-
c.General.BatchSize = defaults.General.BatchSize
152+
case c.General.BatchSize.MaxMessageCount == 0:
153+
logger.Infof("General.BatchSize.MaxMessageCount unset, setting to %s", defaults.General.BatchSize.MaxMessageCount)
154+
c.General.BatchSize.MaxMessageCount = defaults.General.BatchSize.MaxMessageCount
148155
case c.General.QueueSize == 0:
149156
logger.Infof("General.QueueSize unset, setting to %s", defaults.General.QueueSize)
150157
c.General.QueueSize = defaults.General.QueueSize

0 commit comments

Comments
 (0)