You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by ahgittin <gi...@git.apache.org> on 2017/11/06 14:41:00 UTC

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

GitHub user ahgittin opened a pull request:

    https://github.com/apache/brooklyn-docs/pull/231

    document the new ElectPrimaryPolicy and related items

    Documentation for https://github.com/apache/brooklyn-server/pull/879
    
    This has been developed in the field but is now generalized to the point I think it will be useful for many cases.
    
    @aledsage @grkvlt -- particularly welcome feedback from y'all as you've done similar things I know

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ahgittin/brooklyn-docs elect-primary

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-docs/pull/231.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #231
    
----
commit 20e497bf34971e72a97ee8899b55b90e4d4c7880
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Date:   2017-11-06T14:39:07Z

    document the new ElectPrimaryPolicy and related items

----


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-docs/pull/231


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r149105773
  
    --- Diff: guide/blueprints/_elect-primary-policies.md ---
    @@ -0,0 +1,149 @@
    +
    +There are a collection of policies, enrichers, and effectors to assist with common
    +failover scenarios and more general anything which wants a primary elected and
    --- End diff --
    
    general -> generally,


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r149114860
  
    --- Diff: guide/blueprints/_elect-primary-policies.md ---
    @@ -0,0 +1,149 @@
    +
    +There are a collection of policies, enrichers, and effectors to assist with common
    +failover scenarios and more general anything which wants a primary elected and
    +re-elected.
    +
    +These can be used for:
    +
    +* Nominating one child among many to be noted as a primary via a sensor (simply add the `ElectPrimaryPolicy`)
    +* Allowing preferences for such children to be specified  (via `ha.primary.weight`)
    +* Causing the primary to change if the current primary goes down or away
    +* Causing `promote` and `demote` effectors to be invoked on the appropriate nodes when the primary is elected/changed
    +  (with the parent reset to `STARTING` while this occurs)
    +* Mirroring sensors and optionally effectors from the primary to the parent
    +
    +A simple example is as follows, deploying two `item` entities with one designated as primary
    +and its `main.uri` sensor published at the root. If "Preferred Item" fails, "Failover Item"
    +will be become the primary. Any `demote` effector on "Preferred Item" and any `promote` effector
    +on "Failover Item" will be invoked on failover.
    +
    +```
    +brooklyn.policies:
    +- type: org.apache.brooklyn.policy.ha.ElectPrimaryPolicy
    +  brooklyn.config:
    +    # `best` will cause failback to occur automatically when possible; could use `failover` instead
    +    primary.selection.mode: best
    +    propagate.primary.sensors: [ main.uri ]
    +
    +brooklyn.enrichers:
    +- # this enricher will cause the parent to report as failed if there is no primary
    +  type: org.apache.brooklyn.policy.ha.PrimaryRunningEnricher
    +
    +services:
    +- type: item
    +  name: Preferred Item
    +  brooklyn.config:
    +    ha.primary.weight: 1
    +- type: item
    +  name: Failover Item
    +```
    +
    +
    +#### ElectPrimary Policy
    +
    +- org.apache.brooklyn.policy.ha.ElectPrimaryPolicy
    +
    +The ElectPrimaryPolicy acts to keep exactly one of its children or members as primary, promoting and demoting them when required.
    +
    +A simple use case is where we have two children, call them North and South, and we wish for North to be primary.  If North fails, however, we want to promote and fail over to South.  This can be done by:
    +
    +* adding this policy at the parent
    +* setting ` ha.primary.weight` on North
    --- End diff --
    
    erroneous space before ha


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r150210273
  
    --- Diff: guide/blueprints/_elect-primary-policies.md ---
    @@ -0,0 +1,146 @@
    +
    +There are a collection of policies, enrichers, and effectors to assist with common
    +failover scenarios and more generally anything which requires the election and re-election of a primary member.
    +
    +These can be used for:
    +
    +* Nominating one child among many to be noted as a primary via a sensor (simply add the `ElectPrimaryPolicy`)
    +* Allowing preferences for such children to be specified  (via `ha.primary.weight`)
    +* Causing the primary to change if the current primary goes down or away
    +* Causing `promote` and `demote` effectors to be invoked on the appropriate nodes when the primary is elected/changed
    +  (with the parent reset to `STARTING` while this occurs)
    +* Mirroring sensors and optionally effectors from the primary to the parent
    +
    +A simple example is as follows, deploying two `item` entities with one designated as primary
    +and its `main.uri` sensor published at the root. If "Preferred Item" fails, "Failover Item"
    +will be become the primary. Any `demote` effector on "Preferred Item" and any `promote` effector
    +on "Failover Item" will be invoked on failover.
    +
    +```
    --- End diff --
    
    Miss `yaml` after the 3 backticks


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r149106485
  
    --- Diff: guide/blueprints/_elect-primary-policies.md ---
    @@ -0,0 +1,149 @@
    +
    +There are a collection of policies, enrichers, and effectors to assist with common
    +failover scenarios and more general anything which wants a primary elected and
    --- End diff --
    
    which wants a primary elected and re-elected. -> which requires the election and re-election of a primary member.


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r149114727
  
    --- Diff: guide/blueprints/_elect-primary-policies.md ---
    @@ -0,0 +1,149 @@
    +
    +There are a collection of policies, enrichers, and effectors to assist with common
    +failover scenarios and more general anything which wants a primary elected and
    +re-elected.
    +
    +These can be used for:
    +
    +* Nominating one child among many to be noted as a primary via a sensor (simply add the `ElectPrimaryPolicy`)
    +* Allowing preferences for such children to be specified  (via `ha.primary.weight`)
    +* Causing the primary to change if the current primary goes down or away
    +* Causing `promote` and `demote` effectors to be invoked on the appropriate nodes when the primary is elected/changed
    +  (with the parent reset to `STARTING` while this occurs)
    +* Mirroring sensors and optionally effectors from the primary to the parent
    +
    +A simple example is as follows, deploying two `item` entities with one designated as primary
    +and its `main.uri` sensor published at the root. If "Preferred Item" fails, "Failover Item"
    +will be become the primary. Any `demote` effector on "Preferred Item" and any `promote` effector
    +on "Failover Item" will be invoked on failover.
    +
    +```
    +brooklyn.policies:
    +- type: org.apache.brooklyn.policy.ha.ElectPrimaryPolicy
    +  brooklyn.config:
    +    # `best` will cause failback to occur automatically when possible; could use `failover` instead
    +    primary.selection.mode: best
    +    propagate.primary.sensors: [ main.uri ]
    +
    +brooklyn.enrichers:
    +- # this enricher will cause the parent to report as failed if there is no primary
    +  type: org.apache.brooklyn.policy.ha.PrimaryRunningEnricher
    +
    +services:
    +- type: item
    +  name: Preferred Item
    +  brooklyn.config:
    +    ha.primary.weight: 1
    +- type: item
    +  name: Failover Item
    +```
    +
    +
    +#### ElectPrimary Policy
    +
    +- org.apache.brooklyn.policy.ha.ElectPrimaryPolicy
    +
    +The ElectPrimaryPolicy acts to keep exactly one of its children or members as primary, promoting and demoting them when required.
    +
    +A simple use case is where we have two children, call them North and South, and we wish for North to be primary.  If North fails, however, we want to promote and fail over to South.  This can be done by:
    +
    +* adding this policy at the parent
    +* setting ` ha.primary.weight` on North
    +* optionally defining `promote` on North and South (if action is required there to promote it)
    +* observing the `primary` sensor to see which is primary
    +* optionally setting `propagate.primary.sensor: main.uri` to publish `main.uri` from whichever of North or South is active
    +* optionally setting `primary.selection.mode: best` to switch back to North if it comes back online
    +
    +The policy works by listening for service-up changes in the target pool (children or members) and listening for `ha.primary.weight` sensor values from those elements.  On any change, it invokes an effector to perform the primary election.  By default, the effector invoked is `electPrimary`, but this can be changed with the `primary.election.effector` config key.  If this effector does not exist, the policy will add a default behaviour using `ElectPrimaryEffector`.  Details of the election are described in that effector, but to summarize, it will find an appropriate primary from the target pool and publish a sensor indicating who the new primary is.  Optionally it can invoke `promote` and `demote` on the relevant entities.
    +
    +All the `primary.*` parameters accepted by that effector can be defined on the policy and will be passed to the effector, along with an `event` parameter indicating the sensor which triggered the election.
    +
    +The policy also accepts a `propagate.primary.sensors` list of strings or sensors.
    +If present, this will add the `PropagatePrimaryEnricher` enricher with those sensors set to
    +be propagated (but not effectors).
    +For more sophisticated configuration, that enricher can be added and configured directly instead.  
    +
    +If no quorum.up or quorum.running is set on the entity, both will be set to a constant 1.
    --- End diff --
    
    put backticks round `quorum.up` and `quorum.running`?


---

[GitHub] brooklyn-docs issue #231: document the new ElectPrimaryPolicy and related it...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:

    https://github.com/apache/brooklyn-docs/pull/231
  
    all comments addressed i think, thanks.  ready for mege.


---

[GitHub] brooklyn-docs issue #231: document the new ElectPrimaryPolicy and related it...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:

    https://github.com/apache/brooklyn-docs/pull/231
  
    thanks @drigodwin - all addressed


---

[GitHub] brooklyn-docs pull request #231: document the new ElectPrimaryPolicy and rel...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/231#discussion_r149119018
  
    --- Diff: guide/blueprints/policies.md ---
    @@ -78,11 +78,18 @@ example of these working together.
     - org.apache.brooklyn.policy.ha.ServiceReplacer
     
     The ServiceReplacer attaches to a DynamicCluster and replaces a failed member in response to 
    -`ha.entityFailed` (or other configurable sensor).  
    +`ha.entityFailed` (or other configurable sensor) as typically emitted by the ServiceFailureDetector enricher.  
     The [introduction to policies]({{book.path.docs}}/start/policies.md) shows a worked 
     example of this policy in use.
     
     
    +#### ServiceFailureDetector Enricher
    +
    +- org.apache.brooklyn.policy.ha.ServiceFailureDetector
    +
    +TODO
    --- End diff --
    
    I don't think we should include TODOs in the docs


---