Skip to content

Commit 5fdaedd

Browse files
committed
Update.
1 parent 719993e commit 5fdaedd

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

configuration/configuration.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type offeringChordDiscBackend struct {
6969
MaxRefreshesFailed int `json:"MaxRefreshesFailed"` // Maximum amount of refreshes that a supplier failed to reply
7070
MaxRefreshesMissed int `json:"MaxRefreshesMissed"` // Maximum amount of refreshes a trader failed to send to the supplier
7171
PartitionsStateBufferSize int `json:"PartitionsStateBufferSize"`
72+
MaxPartitionsSearch int `json:"MaxPartitionsSearch"`
7273
// Debug performance flags
7374
SpreadOffers bool `json:"SpreadOffers"` // Used to tell if the spread offers mechanism is used or not.
7475
SpreadPartitionsState bool `json:"SpreadPartitionsState"` // Used to tell if the spread partitions state is used or not.
@@ -136,6 +137,7 @@ func Default(hostIP string) *Configuration {
136137
MaxRefreshesFailed: 2,
137138
MaxRefreshesMissed: 2,
138139
PartitionsStateBufferSize: 15,
140+
MaxPartitionsSearch: 3,
139141
// Debug performance flags
140142
SpreadOffers: true,
141143
SpreadPartitionsState: true,
@@ -283,6 +285,10 @@ func (c *Configuration) validate() error {
283285
return fmt.Errorf("the partitions state buffer size must be > 0")
284286
}
285287

288+
if c.MaxPartitionsSearch() <= 0 {
289+
return fmt.Errorf("the max partitions search must be > 0")
290+
}
291+
286292
if c.GUIDEstimatedNetworkSize() <= 0 {
287293
return fmt.Errorf("estimated network size must a positive integer")
288294
}
@@ -362,6 +368,7 @@ func (c *Configuration) Print() {
362368
log.Printf(" Max num of refreshes failed: %d", c.MaxRefreshesFailed())
363369
log.Printf(" Max num of refreshes missed: %d", c.MaxRefreshesMissed())
364370
log.Printf(" Partitions State Buffer Size: %d", c.PartitionsStateBufferSize())
371+
log.Printf(" Max Partitions Search: %d", c.MaxPartitionsSearch())
365372
// Debug performance flags.
366373
log.Printf(" Spread Offers: %t", c.SpreadOffers())
367374
log.Printf(" Spread Partitions State: %t", c.SpreadPartitionsState())
@@ -485,6 +492,10 @@ func (c *Configuration) PartitionsStateBufferSize() int {
485492
return c.Caravela.DiscoveryBackend.OfferingChordBackend.PartitionsStateBufferSize
486493
}
487494

495+
func (c *Configuration) MaxPartitionsSearch() int {
496+
return c.Caravela.DiscoveryBackend.OfferingChordBackend.MaxPartitionsSearch
497+
}
498+
488499
// Debug performance flag.
489500
func (c *Configuration) SpreadOffers() bool {
490501
return c.Caravela.DiscoveryBackend.OfferingChordBackend.SpreadOffers

node/discovery/offering/supplier/multiple_offer_strategy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (m *multipleOfferStrategy) Init(supp *Supplier, resourcesMapping *resources
3636
func (m *multipleOfferStrategy) FindOffers(ctx context.Context, targetResources resources.Resources) []types.AvailableOffer {
3737
availableOffers := make([]types.AvailableOffer, 0)
3838

39-
for r := 0; r < 1; r++ {
39+
for r := 0; r < m.configs.MaxPartitionsSearch(); r++ {
4040
destinationGUID, err := m.resourcesMapping.RandGUIDFittestSearch(targetResources)
4141
if err != nil { // System can't handle that many resources
4242
return availableOffers

node/discovery/offering/supplier/single_offer_strategy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (b *baseOfferStrategy) findOffersLowToHigher(ctx context.Context, targetRes
162162
tries++
163163
}
164164

165-
if tries == 2 {
165+
if tries == (b.configs.MaxPartitionsSearch() - 1) {
166166
return availableOffers
167167
}
168168

@@ -218,7 +218,7 @@ func (b *baseOfferStrategy) findOffersHigherToLow(ctx context.Context, targetRes
218218
tries++
219219
}
220220

221-
if tries == 2 {
221+
if tries == (b.configs.MaxPartitionsSearch() - 1) {
222222
return availableOffers
223223
}
224224

0 commit comments

Comments
 (0)