brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #266: BROOKLYN-264: refactor wait-for-provision
Date Tue, 19 Jul 2016 10:34:53 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/266#discussion_r71313855
  
    --- Diff: software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
---
    @@ -379,20 +418,30 @@ public MachineLocation call() throws Exception {
                 if (!(location instanceof LocalhostMachineProvisioningLocation))
                     log.info("Starting {}, obtaining a new location instance in {} with ports
{}", new Object[]{entity(), location, flags.get("inboundPorts")});
                 entity().sensors().set(SoftwareProcess.PROVISIONING_LOCATION, location);
    +            Transition expectedState = entity().sensors().get(Attributes.SERVICE_STATE_EXPECTED);
    +            
    +            // BROOKLYN-263: see corresponding code in doStop()
    +            if (expectedState != null && (expectedState.getState() == Lifecycle.STOPPING
|| expectedState.getState() == Lifecycle.STOPPED)) {
    +                throw new IllegalStateException("Provisioning aborted before even begun
for "+entity()+" in "+location+" (presumably by a concurrent call to stop");
    +            }
    +            entity().sensors().set(PROVISIONING_TASK_STATE, ProvisioningTaskState.RUNNING);
    +            
                 MachineLocation machine;
                 try {
                     machine = Tasks.withBlockingDetails("Provisioning machine in " + location,
new ObtainLocationTask(location, flags));
    -                if (machine == null)
    -                    throw new NoMachinesAvailableException("Failed to obtain machine
in " + location.toString());
    -            } catch (Exception e) {
    -                throw Exceptions.propagate(e);
    +                entity().sensors().set(PROVISIONED_MACHINE, machine);
    --- End diff --
    
    I'm willing to take that risk - the description says "internal" etc. The problem is that
otherwise there is a big gap between when provisioning returns and when we add the machine
to the location. I worry that start() will not always go through all those steps if there
has been a concurrent call to stop. It might skip executing those subsequent tasks. With the
change I made, we set DONE and the machine in a finally block so it removes that risk.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message