Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Config based routing #850

Merged
merged 5 commits into from
May 23, 2016

Conversation

marcin-krolik
Copy link
Collaborator

@marcin-krolik marcin-krolik commented Apr 11, 2016

Fixes #539

Summary of changes:

  • removed SelectablePlugin interface, since AvailablePlugin interface can be used as well. SelectablePlugin did not introduce any usable abstraction in my opinion.
  • aliased map[uint32]AvailablePlugin to MapAvailablePlugin to ease working with keys/values of map
  • implemented naive config_based routing based on sticky routing implementation

@intelsdi-x/snap-maintainers

// bail to prevent deadlock.
if to.(*pool) == p {
return []subscription{}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason to remove this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should not be removed. Thanks for noticing!

@@ -227,6 +230,9 @@ func (p *pool) applyPluginMeta(a AvailablePlugin) error {
case plugin.StickyRouting:
p.RoutingAndCaching = NewSticky(cacheTTL)
p.concurrencyCount = 1
case plugin.ConfigRouting:
p.RoutingAndCaching = NewConfigBased(cacheTTL)
p.concurrencyCount = 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to override the currency count here or allow it to be defined by the plugin author?

Copy link
Collaborator Author

@marcin-krolik marcin-krolik Apr 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I forgot this value can be provided via plugin metadata.

There's one more thing regarding concurrencyCount. I think I found an error in pool.Eligible() that for p.concurrencyCount != 1 function pool.Eligibility() does not work properly.

Main condition:

should := p.SubscriptionCount() / p.concurrencyCount
if should > p.Count() && should <= p.max {
    return true
}
return false

p.SubscriptionCount() and p.concurrencyCount are both int

Let's say p.Count() = 1, p.max = 3, p.SubscriptionCount() = 4 and p.concurrencyCount = 3 then should = 1

Main condition is false, thus pool.Eligible() = false while in my opinion it should be true

Maybe it should be reimplemented to work on floats?

@marcin-krolik marcin-krolik changed the title wip: Config based routing first naive implementation Config based routing May 11, 2016
@marcin-krolik marcin-krolik force-pushed the kromar-rac-cb-noabs branch from 4d09369 to 204bc40 Compare May 11, 2016 10:13
@marcin-krolik
Copy link
Collaborator Author

Tests fail because of #910

@marcin-krolik marcin-krolik force-pushed the kromar-rac-cb-noabs branch 3 times, most recently from 2673585 to 04496d4 Compare May 12, 2016 07:11
"time"
)

// config-based provides a strategy that ... concurrency count is 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// config-based provides a strategy that selects a plugin based on the given config

@pittma
Copy link
Contributor

pittma commented May 19, 2016

Dude, Marcin, I love this! It looks so good. Would you mind adding a test to pool_test.go around SelectAP?

- removed overwritting setting of concurrencyCount to 3
- removed commented code
- added case to config based routing unit tests
@marcin-krolik marcin-krolik force-pushed the kromar-rac-cb-noabs branch from 04496d4 to f8ff158 Compare May 22, 2016 17:17
@marcin-krolik
Copy link
Collaborator Author

@danielscottt : Thanks! I wrote some additional tests for pool.SelectAP(). take a look and say what you think!

@marcin-krolik marcin-krolik force-pushed the kromar-rac-cb-noabs branch from f8ff158 to 4a6fe7f Compare May 22, 2016 18:24
@pittma
Copy link
Contributor

pittma commented May 23, 2016

LGTM!

@marcin-krolik marcin-krolik merged commit 596c943 into intelsdi-x:master May 23, 2016
@marcin-krolik marcin-krolik deleted the kromar-rac-cb-noabs branch August 29, 2016 12:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants