Java Code Examples for org.apache.brooklyn.api.mgmt.ManagementContext#isRunning()

The following examples show how to use org.apache.brooklyn.api.mgmt.ManagementContext#isRunning() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JcloudsRebindStubTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
    List<Exception> exceptions = Lists.newArrayList();
    for (ManagementContext mgmt : mgmts) {
        try {
            if (mgmt.isRunning()) Entities.destroyAll(mgmt);
        } catch (Exception e) {
            LOG.warn("Error destroying management context", e);
            exceptions.add(e);
        }
    }
    mgmts.clear();
    origManagementContext = null;
    newManagementContext = null;
    origApp = null;
    newApp = null;
    
    super.tearDown();
    
    if (exceptions.size() > 0) {
        throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
    }
}
 
Example 2
Source File: JcloudsRebindStubUnitTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
    try {
        List<Exception> exceptions = Lists.newArrayList();
        for (ManagementContext mgmt : mgmts) {
            try {
                if (mgmt.isRunning()) Entities.destroyAll(mgmt);
            } catch (Exception e) {
                LOG.warn("Error destroying management context", e);
                exceptions.add(e);
            }
        }
        
        super.tearDown();
        
        if (exceptions.size() > 0) {
            throw new CompoundRuntimeException("Error in tearDown of "+getClass(), exceptions);
        }
    } finally {
        mgmts.clear();
        origManagementContext = null;
        newManagementContext = null;
        origApp = null;
        newApp = null;
        RecordingSshTool.clear();
        RecordingWinRmTool.clear();
    }
}
 
Example 3
Source File: HaHotCheckHelperAbstract.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/** Returns a string describing the problem if mgmt is null or not running; returns absent if no problems */
public static Maybe<String> getProblemMessageIfServerNotRunning(ManagementContext mgmt) {
    if (mgmt==null) return Maybe.of("no management context available");
    if (!mgmt.isRunning()) return Maybe.of("server no longer running");
    if (!mgmt.isStartupComplete()) return Maybe.of("server not in required startup-completed state");
    return Maybe.absent();
}
 
Example 4
Source File: Locations.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public static boolean isManaged(Location loc) {
    ManagementContext mgmt = ((LocationInternal)loc).getManagementContext();
    return (mgmt != null) && mgmt.isRunning() && mgmt.getLocationManager().isManaged(loc);
}