brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [6/7] incubator-brooklyn git commit: address code review for startup info
Date Thu, 07 May 2015 10:57:21 GMT
address code review for startup info

JS masterUri fix, HA check cleanups, removing unneeded classes, and catch catalog error


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/7556c582
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/7556c582
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/7556c582

Branch: refs/heads/master
Commit: 7556c582ae253a655eb76abba92b75ac811a77b3
Parents: 7d0f1a0
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed May 6 10:48:16 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed May 6 10:48:16 2015 +0100

----------------------------------------------------------------------
 .../entity/brooklynnode/BrooklynNodeImpl.java   |   4 +
 .../BrooklynNodeIntegrationTest.java            |  23 ++-
 .../assets/js/model/server-extended-status.js   |  10 +-
 .../rest/filter/ServerStatusCheckFilter.java    | 120 -----------
 .../rest/resources/CatalogResource.java         |  17 +-
 .../test/java/brooklyn/rest/HaHotCheckTest.java |   4 +-
 .../brooklyn/rest/HaMasterCheckFilterTest.java  |   3 +-
 .../rest/testing/BrooklynRestResourceTest.java  |   2 +-
 .../mocks/HighAvailabilityManagerStub.java      | 121 -----------
 .../testing/mocks/ManagementContextMock.java    | 206 -------------------
 10 files changed, 47 insertions(+), 463 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
index d4b4992..9fd34eb 100644
--- a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
@@ -466,6 +466,10 @@ public class BrooklynNodeImpl extends SoftwareProcessImpl implements
BrooklynNod
                     .baseUri(webConsoleUri)
                     .credentialsIfNotNull(getConfig(MANAGEMENT_USER), getConfig(MANAGEMENT_PASSWORD))
                     .poll(new HttpPollConfig<Boolean>(WEB_CONSOLE_ACCESSIBLE)
+                            // TODO `BrooklynNode` shouldn't report `SERVICE_UP` until `/v1/server/healthy`
returns true;
+                            // but this should wait until v0.8.0 as we'll need managed nodes
to implement `/v1/server/healthy` (added May 2015);
+                            // when that is added BrooklynNodeIntegrationTest.waitForApps
can remove the 403 check, it should require 200 always.
+                            // .suburl("/v1/server/healthy")  then check: responseTextEquals("true")
                             .onSuccess(HttpValueFunctions.responseCodeEquals(200))
                             .setOnFailureOrException(false))
                     .poll(new HttpPollConfig<ManagementNodeState>(MANAGEMENT_NODE_STATE)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
b/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
index 717eb68..ff7b5fc 100644
--- a/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
@@ -347,23 +347,31 @@ services:
         log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod());
 
         URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
+        waitForApps(webConsoleUri.toString());
         String apps = HttpTestUtils.getContent(webConsoleUri.toString()+"/v1/applications");
         List<String> appType = parseJsonList(apps, ImmutableList.of("spec", "type"),
String.class);
         assertEquals(appType, ImmutableList.of(BasicApplication.class.getName()));
     }
 
+    protected static void waitForApps(String webConsoleUri) {
+        HttpTestUtils.assertHttpStatusCodeEquals(webConsoleUri+"/v1/applications", 200, 403);
+        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(webConsoleUri+"/v1/applications",
200);
+    }
+
     @Test(groups="Integration")
     public void testStartsAppViaEffector() throws Exception {
         BrooklynNode brooklynNode = app.createAndManageChild(newBrooklynNodeSpecForTest());
         app.start(locs);
         log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod());
         
+        // note there is also a test for this in DeployApplication
+        final URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
+        waitForApps(webConsoleUri.toString());
+
         final String id = brooklynNode.invoke(BrooklynNode.DEPLOY_BLUEPRINT, ConfigBag.newInstance()
             .configure(DeployBlueprintEffector.BLUEPRINT_TYPE, BasicApplication.class.getName())
             .getAllConfig()).get();
         
-        // note there is also a test for this in DeployApplication
-        final URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
         String apps = HttpTestUtils.getContent(webConsoleUri.toString()+"/v1/applications");
         List<String> appType = parseJsonList(apps, ImmutableList.of("spec", "type"),
String.class);
         assertEquals(appType, ImmutableList.of(BasicApplication.class.getName()));
@@ -389,6 +397,7 @@ services:
         log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod());
 
         URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
+        waitForApps(webConsoleUri.toString());
 
         // Check that "mynamedloc" has been picked up from the brooklyn.properties
         String locsContent = HttpTestUtils.getContent(webConsoleUri.toString()+"/v1/locations");
@@ -486,6 +495,8 @@ services:
         File pidFile = new File(getDriver(brooklynNode).getPidFile());
         URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
 
+        waitForApps(webConsoleUri.toString());
+
         // Stop just the process; will not have unmanaged entity unless machine was being
terminated 
         brooklynNode.invoke(BrooklynNode.STOP, ImmutableMap.<String, Object>of(
                 BrooklynNode.StopSoftwareParameters.STOP_MACHINE_MODE.getName(), StopMode.NEVER,
@@ -512,7 +523,9 @@ services:
 
         // Note can't use driver.isRunning to check shutdown; can't invoke scripts on an
unmanaged entity
         EntityTestUtils.assertAttributeEquals(brooklynNode, BrooklynNode.SERVICE_UP, false);
-        assertFalse(Entities.isManaged(brooklynNode));
+        // previously we unmanaged the node on stop, but that behaviour has been removed
(noticed May 2015)
+        // TODO remove this after a couple of months, for awareness/confirmation
+//        assertFalse(Entities.isManaged(brooklynNode));
         assertFalse(isPidRunning(pidFile), "pid in "+pidFile+" still running");
     }
 
@@ -548,11 +561,13 @@ services:
 
         EntityTestUtils.assertAttributeEqualsEventually(brooklynNode, BrooklynNode.SERVICE_UP,
true);
 
+        String baseUrl = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI).toString();
+        waitForApps(baseUrl);
+        
         final String id = brooklynNode.invoke(BrooklynNode.DEPLOY_BLUEPRINT, ConfigBag.newInstance()
                 .configure(DeployBlueprintEffector.BLUEPRINT_TYPE, BasicApplication.class.getName())
                 .getAllConfig()).get();
 
-        String baseUrl = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI).toString();
         String entityUrl = Urls.mergePaths(baseUrl, "v1/applications/", id, "entities", id);
         
         Entity mirror = brooklynNode.addChild(EntitySpec.create(BrooklynEntityMirror.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js b/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js
index 2f5ccb3..e774294 100644
--- a/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js
+++ b/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js
@@ -73,13 +73,9 @@ define(["backbone", "brooklyn", "view/viewutils"], function (Backbone,
Brooklyn,
         getMasterUri: function() {
             // Might be undefined if first fetch hasn't completed
             ha = this.get("ha") || {};
-            states = ha.states || {};
-            if (!states) return null;
-            
-            var nodes = this.get("nodes") || {};
-            var master = nodes[this.get("masterId")];
-            // defensive, if this happens something more serious has gone wrong!
-            if (!master) {
+            nodes = ha.nodes || {};
+            master = nodes[ha.masterId];
+            if (!master || master.status != "MASTER") {
                 return null;
             } else {
                 return master.nodeUri;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/main/java/brooklyn/rest/filter/ServerStatusCheckFilter.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/filter/ServerStatusCheckFilter.java
b/usage/rest-server/src/main/java/brooklyn/rest/filter/ServerStatusCheckFilter.java
deleted file mode 100644
index d5c30a3..0000000
--- a/usage/rest-server/src/main/java/brooklyn/rest/filter/ServerStatusCheckFilter.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.rest.filter;
-
-import java.io.IOException;
-import java.util.Set;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.Response;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.config.BrooklynServiceAttributes;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.ha.ManagementNodeState;
-import brooklyn.rest.domain.ApiError;
-import brooklyn.rest.util.WebResourceUtils;
-
-import com.google.common.collect.Sets;
-
-/**
- * Checks that the request is appropriate given the high availability status of the server.
- *
- * @see brooklyn.management.ha.ManagementNodeState
- */
-public class ServerStatusCheckFilter implements Filter {
-
-    private static final Logger log = LoggerFactory.getLogger(ServerStatusCheckFilter.class);
-    
-    public static final String SKIP_CHECK_HEADER = "Brooklyn-Allow-Non-Master-Access";
-    private static final Set<String> SAFE_STANDBY_METHODS = Sets.newHashSet("GET",
"HEAD");
-
-    protected ServletContext servletContext;
-    protected ManagementContext mgmt;
-
-    @Override
-    public void init(FilterConfig config) throws ServletException {
-        servletContext = config.getServletContext();
-        mgmt = (ManagementContext) servletContext.getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);
-    }
-
-    private String lookForProblem(ServletRequest request) {
-        if (isMasterRequiredForRequest(request)) {
-            if (mgmt==null) return "no management context available";
-            if (!mgmt.isRunning()) return "server no longer running";
-            if (!mgmt.isStartupComplete()) return "server not in required startup-completed
state";
-            if (!isMaster()) return "server not in required HA master state";
-        }
-        return null;
-    }
-    
-    @Override
-    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
-        String problem = lookForProblem(request);
-        if (problem!=null) {
-            log.warn("Disallowing request as "+problem+"/"+request.getParameterMap()+" (caller
should set '"+SKIP_CHECK_HEADER+"' to force)");
-            WebResourceUtils.applyJsonResponse(servletContext, ApiError.builder()
-                .message("This request is only permitted against an active master Brooklyn
server")
-                .errorCode(Response.Status.FORBIDDEN).build().asJsonResponse(), (HttpServletResponse)response);
-        } else {
-            chain.doFilter(request, response);
-        }
-    }
-
-    @Override
-    public void destroy() {
-    }
-
-    private boolean isMaster() {
-        return ManagementNodeState.MASTER.equals(mgmt.getHighAvailabilityManager().getNodeState());
-    }
-
-    private boolean isMasterRequiredForRequest(ServletRequest request) {
-        if (request instanceof HttpServletRequest) {
-            HttpServletRequest httpRequest = (HttpServletRequest) request;
-            String checkOverridden = httpRequest.getHeader(SKIP_CHECK_HEADER);
-            if ("true".equalsIgnoreCase(checkOverridden)) return false;
-            
-            String method = httpRequest.getMethod().toUpperCase();
-            // gets usually okay
-            if (SAFE_STANDBY_METHODS.contains(method)) return false;
-            
-            // explicitly allow calls to shutdown
-            // (if stopAllApps is specified, the method itself will fail; but we do not want
to consume parameters here, that breaks things!)
-            // TODO combine with HaHotCheckResourceFilter and use an annotation HaAnyStateAllowed
or similar
-            if ("/v1/server/shutdown".equals(httpRequest.getRequestURI())) return false;
-            
-            // master required for everything else
-            return true;
-        }
-        // previously non-HttpServletRequests were allowed but I don't think they should
be
-        return true;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
index a3eb161..a93f9a0 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
@@ -21,6 +21,7 @@ package brooklyn.rest.resources;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -454,8 +455,20 @@ public class CatalogResource extends AbstractBrooklynRestResource implements
Cat
     @SuppressWarnings("unchecked")
     private static <T> List<T> castList(List<? super T> list, Class<T>
elementType) {
         List<T> result = Lists.newArrayList();
-        for (Object element : list) {
-            result.add((T) element);
+        Iterator<? super T> li = list.iterator();
+        while (li.hasNext()) {
+            try {
+                result.add((T) li.next());
+            } catch (Throwable throwable) {
+                if (throwable instanceof NoClassDefFoundError) {
+                    // happens if class cannot be loaded for any reason during transformation
- don't treat as fatal
+                } else {
+                    Exceptions.propagateIfFatal(throwable);
+                }
+                
+                // item cannot be transformed; we will have logged a warning earlier
+                log.debug("Ignoring invalid catalog item: "+throwable);
+            }
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/test/java/brooklyn/rest/HaHotCheckTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/HaHotCheckTest.java b/usage/rest-server/src/test/java/brooklyn/rest/HaHotCheckTest.java
index e6ca1d1..7ce6a97 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/HaHotCheckTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/HaHotCheckTest.java
@@ -43,10 +43,12 @@ import com.sun.jersey.api.core.ResourceConfig;
 
 public class HaHotCheckTest extends BrooklynRestResourceTest {
 
+    // setup and teardown before/after each method
+    
     @BeforeMethod(alwaysRun = true)
     public void setUp() throws Exception { super.setUp(); }
 
-    @AfterMethod(alwaysRun = false)
+    @AfterMethod(alwaysRun = true)
     public void tearDown() throws Exception { super.tearDown(); }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/test/java/brooklyn/rest/HaMasterCheckFilterTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/HaMasterCheckFilterTest.java b/usage/rest-server/src/test/java/brooklyn/rest/HaMasterCheckFilterTest.java
index 671a6b2..27d8d6c 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/HaMasterCheckFilterTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/HaMasterCheckFilterTest.java
@@ -64,6 +64,7 @@ public class HaMasterCheckFilterTest extends BrooklynRestApiLauncherTestFixture
 
     @AfterMethod(alwaysRun=true)
     public void tearDown() throws Exception {
+System.err.println("TEAR DOWN");
         server.stop();
         Entities.destroyAll(writeMgmt);
         Entities.destroyAll(readMgmt);
@@ -151,7 +152,7 @@ public class HaMasterCheckFilterTest extends BrooklynRestApiLauncherTestFixture
 
         writeMgmt = createManagementContext(mementoDir, writeMode);
         appId = createApp(writeMgmt);
-        writeMgmt.getRebindManager().getPersister().waitForWritesCompleted(TIMEOUT);
+        writeMgmt.getRebindManager().waitForPendingComplete(TIMEOUT);
 
         if (readMode == HighAvailabilityMode.DISABLED) {
             //no HA, one node only

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestResourceTest.java
index 485d5a8..42a622a 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestResourceTest.java
@@ -60,7 +60,7 @@ public abstract class BrooklynRestResourceTest extends BrooklynRestApiTest
{
         setUpJersey();
     }
 
-    @AfterClass(alwaysRun = false)
+    @AfterClass(alwaysRun = true)
     public void tearDown() throws Exception {
         tearDownJersey();
         super.tearDown();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/HighAvailabilityManagerStub.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/HighAvailabilityManagerStub.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/HighAvailabilityManagerStub.java
deleted file mode 100644
index 98fb8d5..0000000
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/HighAvailabilityManagerStub.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.rest.testing.mocks;
-
-import java.util.Map;
-
-import brooklyn.management.ha.HighAvailabilityManager;
-import brooklyn.management.ha.HighAvailabilityMode;
-import brooklyn.management.ha.ManagementNodeState;
-import brooklyn.management.ha.ManagementPlaneSyncRecord;
-import brooklyn.management.ha.ManagementPlaneSyncRecordPersister;
-
-public class HighAvailabilityManagerStub implements HighAvailabilityManager {
-
-    private ManagementNodeState state = ManagementNodeState.MASTER;
-
-    public void setState(ManagementNodeState state) {
-        this.state = state;
-    }
-
-    private static RuntimeException fail() {
-        throw new UnsupportedOperationException("Mocked method not implemented");
-    }
-
-    @Override
-    public boolean isRunning() {
-        return state != ManagementNodeState.TERMINATED;
-    }
-
-    @Override
-    public ManagementNodeState getNodeState() {
-        return state;
-    }
-
-    @Override
-    public long getLastStateChange() {
-        return 0;
-    }
-
-    @Override
-    public HighAvailabilityManager setPersister(ManagementPlaneSyncRecordPersister persister)
{
-        throw fail();
-    }
-
-    @Override
-    public void disabled() {
-        throw fail();
-    }
-
-    @Override
-    public void start(HighAvailabilityMode startMode) {
-        throw fail();
-    }
-
-    @Override
-    public void stop() {
-        throw fail();
-    }
-
-    @Override
-    public void changeMode(HighAvailabilityMode mode) {
-        throw fail();
-    }
-
-    @Override
-    public void setPriority(long priority) {
-        throw fail();
-    }
-
-    @Override
-    public long getPriority() {
-        throw fail();
-    }
-
-    @Override
-    public void publishClearNonMaster() {
-        throw fail();
-    }
-
-    @Override
-    public ManagementPlaneSyncRecord getLastManagementPlaneSyncRecord() {
-        throw fail();
-    }
-
-    @Override
-    public ManagementPlaneSyncRecord getManagementPlaneSyncState() {
-        throw fail();
-    }
-
-    @Override
-    public ManagementPlaneSyncRecord loadManagementPlaneSyncRecord(boolean useLocalKnowledgeForThisNode)
{
-        throw fail();
-    }
-
-    @Override
-    public ManagementPlaneSyncRecordPersister getPersister() {
-        throw fail();
-    }
-
-    @Override
-    public Map<String, Object> getMetrics() {
-        throw fail();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7556c582/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/ManagementContextMock.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/ManagementContextMock.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/ManagementContextMock.java
deleted file mode 100644
index 423743f..0000000
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/mocks/ManagementContextMock.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.rest.testing.mocks;
-
-import java.net.URI;
-import java.util.Collection;
-
-import brooklyn.basic.BrooklynObject;
-import brooklyn.catalog.BrooklynCatalog;
-import brooklyn.config.StringConfigMap;
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.drivers.EntityDriverManager;
-import brooklyn.entity.drivers.downloads.DownloadResolverManager;
-import brooklyn.entity.rebind.RebindManager;
-import brooklyn.location.LocationRegistry;
-import brooklyn.management.AccessController;
-import brooklyn.management.EntityManager;
-import brooklyn.management.ExecutionContext;
-import brooklyn.management.ExecutionManager;
-import brooklyn.management.LocationManager;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.SubscriptionContext;
-import brooklyn.management.SubscriptionManager;
-import brooklyn.management.entitlement.EntitlementManager;
-import brooklyn.management.ha.HighAvailabilityManager;
-import brooklyn.management.ha.ManagementNodeState;
-import brooklyn.util.guava.Maybe;
-import brooklyn.util.javalang.JavaClassNames;
-
-public class ManagementContextMock implements ManagementContext {
-    private Boolean running;
-    private Boolean startupComplete;
-    private HighAvailabilityManagerStub haMock = new HighAvailabilityManagerStub();
-
-    public void setRunning(Boolean running) {
-        this.running = running;
-    }
-    public void setStartupComplete(Boolean startupComplete) {
-        this.startupComplete = startupComplete;
-    }
-    
-    public void setState(ManagementNodeState state) {
-        haMock.setState(state);
-    }
-
-    private static RuntimeException fail() {
-        throw new UnsupportedOperationException("Mocked method not implemented - "+JavaClassNames.callerNiceClassAndMethod(1));
-    }
-
-    @Override
-    public HighAvailabilityManager getHighAvailabilityManager() {
-        return haMock;
-    }
-
-    @Override
-    public String getManagementPlaneId() {
-        throw fail();
-    }
-
-    @Override
-    public String getManagementNodeId() {
-        throw fail();
-    }
-
-    @Override
-    public Maybe<URI> getManagementNodeUri() {
-        throw fail();
-    }
-
-    @Override
-    public Collection<Application> getApplications() {
-        throw fail();
-    }
-
-    @Override
-    public EntityManager getEntityManager() {
-        throw fail();
-    }
-
-    @Override
-    public ExecutionManager getExecutionManager() {
-        throw fail();
-    }
-
-    @Override
-    public ExecutionContext getServerExecutionContext() {
-        throw fail();
-    }
-
-    @Override
-    public EntityDriverManager getEntityDriverManager() {
-        throw fail();
-    }
-
-    @Override
-    public DownloadResolverManager getEntityDownloadsManager() {
-        throw fail();
-    }
-
-    @Override
-    public SubscriptionManager getSubscriptionManager() {
-        throw fail();
-    }
-
-    @Override
-    public ExecutionContext getExecutionContext(Entity entity) {
-        throw fail();
-    }
-
-    @Override
-    public SubscriptionContext getSubscriptionContext(Entity entity) {
-        throw fail();
-    }
-
-    @Override
-    public RebindManager getRebindManager() {
-        throw fail();
-    }
-
-    @Override
-    public StringConfigMap getConfig() {
-        throw fail();
-    }
-
-    @Override
-    public boolean isRunning() {
-        if (running==null) throw fail();
-        return running;
-    }
-
-    @Override
-    public boolean isStartupComplete() {
-        if (startupComplete==null) throw fail();
-        return startupComplete;
-    }
-    
-    @Override
-    public LocationRegistry getLocationRegistry() {
-        throw fail();
-    }
-
-    @Override
-    public BrooklynCatalog getCatalog() {
-        throw fail();
-    }
-
-    @Override
-    public LocationManager getLocationManager() {
-        throw fail();
-    }
-
-    @Override
-    public AccessController getAccessController() {
-        throw fail();
-    }
-
-    @Override
-    public void reloadBrooklynProperties() {
-        throw fail();
-
-    }
-
-    @Override
-    public void addPropertiesReloadListener(PropertiesReloadListener listener) {
-        throw fail();
-
-    }
-
-    @Override
-    public void removePropertiesReloadListener(PropertiesReloadListener listener) {
-        throw fail();
-    }
-
-    @Override
-    public EntitlementManager getEntitlementManager() {
-        throw fail();
-    }
-
-    @Override
-    public BrooklynObject lookup(String id) {
-        throw fail();
-    }
-
-    @Override
-    public <T extends BrooklynObject> T lookup(String id, Class<T> type) {
-        throw fail();
-    }
-
-}


Mime
View raw message