cloudify service dependsOn other service

痴心易碎 提交于 2019-12-12 02:15:51

问题


When I use cloudify(2.7) to deploy an application,it includs two services(e.g. service A dependsOn service B),here is the app-application.groovy

application {
    name "app"

    service {
        name = "B"
    }

    service {
        name = "A"
        dependsOn = [ "B" ]
    }
}

when the service B has 2 instances,one of the instances of service B is available,the service A begin to invoke the start event,but the service A dependsOn all instance of service B, Does it have some configuration to solve it ?


回答1:


Copying my answer from https://groups.google.com/forum/#!topic/cloudify-developers/TZzwfzY-rLY:

The default behavior in Cloudify 2.7 is to start a service once there is at-least one running instance of all of the services it depends on. If you would like to wait for all instances of another service (or some other dependency logic) you should implement this in your lifecycle scripts. You can access the state of other services using the service context API: http://getcloudify.org/guide/2.7/developing/the_service_context_api.html

For example, you could add a 'preInstall' event that uses the waitForInstances() API to wait for the required number of instances. Note that this API gives you access to instances that may not have started yet. You can check the current state of an instance by calling:

serviceInstance.getMonitors("USM_State")

The possible values of USM_State are available here: https://github.com/CloudifySource/cloudify/blob/master/dsl/src/main/java/org/cloudifysource/dsl/internal/CloudifyConstants.java#L35

So a value of 2 indicates a running instance.



来源:https://stackoverflow.com/questions/25924933/cloudify-service-dependson-other-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!