-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequencer entity #546
Sequencer entity #546
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can guess at why these are useful (e.g. some clusters require us to give each member an id that are sequential numbers). However, it would be very useful if you could give us some concrete use-cases so that we understand why these are being added to Brooklyn.
If that is the use-case, I'd prefer the effector approach, with DSL support to invoke the effector and format the result. That feels more explicit compared to the SequenceGroup
. But it really depends what use-cases you're envisaging.
public void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
app = TestApplication.Factory.newManagedInstanceForTests(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-class will have instantiated app - don't do it here, and delete the private field app
. Also delete tearDown
as that is done by super.
group.setEntityFilter(EntityPredicates.hasInterfaceMatching(".*TestEntity")); | ||
|
||
assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of(e1, e2, e3)); | ||
assertAttributeEquals(e1, value, 12345); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be sure that e1
, e2
, e3` will be the order of the members? Is that because it is called sequentially with the order that the entities were created?
String currentString(); | ||
|
||
@Effector(description = "Update and return the next numeric value of the sequence") | ||
Integer nextValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer we follow the naming conventions of AtomicInteger
- so rename increment
to incrementAndGet
, and delete nextValue
+ nextString
.
I'm inclined to let the caller do the formatting of the result, rather than having separate nextValue
and nextString
. The difference between those two methods, and their interaction, feels as though it might confuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, that would make things more obvious and simpler.
c65ae65
to
9e6a806
Compare
@grkvlt (cc @drigodwin) given we have |
@aledsage the use case in mind was to sequentially number across multiple clusters (i.e a fabric spread around several locations) which needed the implicit, |
@drigodwin we need to document this, I will add some descriptive text explaining this for Brooklyn docs |
I feel like this will soon be superseded, by being able to point at some shared-scoped atomic integer and request a That said not that opposed to adding for now if useful with an expectation it might fall away. |
@mikezaccardo is this still useful, e.g. for HLF blueprints? |
@grkvlt this would indeed be useful for the Hyperledger Fabric multi-cluster in place of this entity: https://github.com/cloudsoft/brooklyn-hyperledger/blob/c85c215d725017b787c133c1483a21f4e9433b09/catalog/hyperledger/multi-cluster.bom#L205-L251 |
9e6a806
to
62989ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is useful as @mikezaccardo has highlighted so I'm going to merge this now.
An entity and a group that manage sequential sensor values