brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Don't leak machines on shutdown
Date Tue, 28 Jul 2015 10:02:37 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/771#discussion_r35631976
  
    --- Diff: software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
---
    @@ -568,4 +706,85 @@ protected String getInstallLabelExtraSalt() {
                 return (String)getEntity().getConfigRaw(ConfigKeys.newStringConfigKey("salt"),
true).or((String)null);
             }
         }
    +
    +    public static class ReleaseLatchLocation extends SimulatedLocation {
    +        private static final long serialVersionUID = 1L;
    +        
    +        private AtomicBoolean lock = new AtomicBoolean();
    +        private boolean isBlocked;
    +
    +        public void unblock() {
    +            synchronized (lock) {
    +                lock.set(true);
    +                lock.notifyAll();
    +            }
    +        }
    +        @Override
    +        public void release(MachineLocation machine) {
    +            super.release(machine);
    +            synchronized (lock) {
    +                if (!lock.get()) {
    +                    try {
    +                        isBlocked = true;
    +                        lock.wait();
    +                        isBlocked = false;
    +                    } catch (InterruptedException e) {
    +                        throw Exceptions.propagate(e);
    +                    }
    +                }
    +            }
    +        }
    +
    +        public boolean isBlocked() {
    +            return isBlocked;
    +        }
    +
    +    }
    +
    +    public static class GenericSoftwareProcessTestDriver implements SoftwareProcessDriver
{
    --- End diff --
    
    For the future (not this PR)...
    Feels like this is useful for more than just here. For example, we already have:
    * `DoNothingSoftwareProcessDriver`
    * `SoftwareProcessEntityTest.SimulatedDriver`
    * `SoftwareProcessSshDriverIntegrationTest.SimulatedDriver`
    * `MockSshDriver` (which is a stub rather than mock)
    * `RestMockSimpleEntity.MockSshDriver`



---
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