Repository: brooklyn-docs
Updated Branches:
  refs/heads/master 8384923ea -> 11414400e


Document the latch improvements - max concurrency behaviour


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/commit/9fc73fac
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/tree/9fc73fac
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/diff/9fc73fac

Branch: refs/heads/master
Commit: 9fc73facf5daa7df7b6930e95aa0e507c72d6562
Parents: 8049f2e
Author: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com>
Authored: Fri Jan 27 12:43:43 2017 +0200
Committer: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com>
Committed: Fri Jan 27 12:54:43 2017 +0200

----------------------------------------------------------------------
 guide/yaml/advanced-example.md | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/9fc73fac/guide/yaml/advanced-example.md
----------------------------------------------------------------------
diff --git a/guide/yaml/advanced-example.md b/guide/yaml/advanced-example.md
index 2b7957d..6513191 100644
--- a/guide/yaml/advanced-example.md
+++ b/guide/yaml/advanced-example.md
@@ -201,6 +201,36 @@ certain conditions are met before continuing. For example:
 This latch is used to stop Kibana customizing until the Elasticsearch cluster 
is up. We do this to ensure 
 that the URL sensors have been setup, so that they can be passed into Kibana 
during the customization phase.
 
+Latches can also be used to control how many entities can execute the same 
step at any given moment. When
+a latch is given the value of a `MaxConcurrencySensor` it will unblock 
execution only when there are
+available "slots" to execute (think of it as a semaphore). For example to let 
a single entity execute the
+launch step of the start effector:
+
+~~~yaml
+services:
+- type: cluster
+
+  brooklyn.initializers:
+  - type: org.apache.brooklyn.core.sensor.MaxConcurrencySensor
+    brooklyn.config:
+      name: single-executor
+      latch.concurrency.max: 1
+
+  brooklyn.config: 
+    initialSize: 10
+    memberSpec:
+      $brooklyn:entitySpec:
+        type: vanilla-bash-server
+        brooklyn.config:
+          launch.command: sleep 2
+          checkRunning.command: true
+          launch.latch: 
$brooklyn:parent().attributeWhenReady("single-executor")
+~~~
+
+It's important to note that the above setup is not reentrant. This means that 
users should be careful to
+avoid deadlocks. For example having a start and launch latches against the 
`single-executor` from above.
+The launch latch will block forever since the start latch already would've 
acquired the free slot.
+
 #### Child entities
 The ELK blueprint also contains a good example of a child entity.
 

Reply via email to