[2/3] brooklyn-server git commit: Useful methods for working with the Brooklyn API programatically.

2016-02-04 Thread sjcorbett
Useful methods for working with the Brooklyn API programatically.


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

Branch: refs/heads/master
Commit: d173390039887e2da6717f5ca0d1b4c91fb8657b
Parents: 6528d25
Author: Sam Corbett 
Authored: Wed Feb 3 17:09:17 2016 +
Committer: Sam Corbett 
Committed: Wed Feb 3 17:09:17 2016 +

--
 rest/rest-client/pom.xml|   5 +
 .../brooklyn/rest/client/BrooklynApiUtil.java   | 154 +++
 .../rest/client/BrooklynApiUtilTest.java| 129 
 3 files changed, 288 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d1733900/rest/rest-client/pom.xml
--
diff --git a/rest/rest-client/pom.xml b/rest/rest-client/pom.xml
index 5b27148..f3fa883 100644
--- a/rest/rest-client/pom.xml
+++ b/rest/rest-client/pom.xml
@@ -144,6 +144,11 @@
 ${project.version}
 test
 
+
+com.google.mockwebserver
+mockwebserver
+test
+
 
 
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d1733900/rest/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
--
diff --git 
a/rest/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
 
b/rest/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
new file mode 100644
index 000..ce57da5
--- /dev/null
+++ 
b/rest/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
@@ -0,0 +1,154 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class BrooklynApiUtil {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(BrooklynApiUtil.class);
+private static final Duration DEFAULT_POLL_PERIOD = Duration.FIVE_SECONDS;
+private static final Duration DEFAULT_TIMEOUT = Duration.FIVE_MINUTES;
+
+private BrooklynApiUtil() {}
+
+/**
+ * Deploys the blueprint and returns the task summary.
+ * @throws Exception If the response from the server when deploying was 
{@link #isUnhealthyResponse unhealthy}.
+ */
+public static TaskSummary deployBlueprint(BrooklynApi api, String 
blueprint) throws Exception {
+Response r = api.getApplicationApi().createFromYaml(blueprint);
+if (isUnhealthyResponse(r)) {
+throw new Exception("Unexpected response deploying blueprint to 
server: " + r.getStatus());
+} else {
+LOG.debug("Server response to deploy blueprint: " + r.getStatus());
+}
+return BrooklynApi.getEntity(r, TaskSummary.class);
+}
+
+/**
+ * Waits for the application with the given ID to be running.
+ *
+ * @throws IllegalStateException If the application was not running after 
{@link #DEFAULT_TIMEOUT}.
+ */
+public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String 
applicationId, String taskId) throws IllegalStateException {
+waitForRunningAndThrowOtherwise(api, 

[1/3] brooklyn-server git commit: Typo

2016-02-04 Thread sjcorbett
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 90eb128ba -> 1298d378c


Typo


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/6528d25b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/6528d25b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/6528d25b

Branch: refs/heads/master
Commit: 6528d25b32f24c29ecb2ce602e437fd9f53e2182
Parents: d03f254
Author: Sam Corbett 
Authored: Wed Feb 3 17:08:29 2016 +
Committer: Sam Corbett 
Committed: Wed Feb 3 17:08:29 2016 +

--
 .../brooklyn/core/catalog/internal/BasicBrooklynCatalog.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6528d25b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
--
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
 
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index 41a0a9c..8306168 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -414,7 +414,7 @@ public class BasicBrooklynCatalog implements 
BrooklynCatalog {
 }
 
 } else {
-log.info("No Camp-YAML parser regsitered for parsing catalog item 
DSL; skipping DSL-parsing");
+log.info("No Camp-YAML parser registered for parsing catalog item 
DSL; skipping DSL-parsing");
 }
 
 Map catalogMetadata = MutableMap.builder()



[3/3] brooklyn-server git commit: This closes #5

2016-02-04 Thread sjcorbett
This closes #5

Brooklyn API utilities


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/1298d378
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/1298d378
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/1298d378

Branch: refs/heads/master
Commit: 1298d378c6c1154dd4bba890c41b5a2751fbcc12
Parents: 90eb128 d173390
Author: Sam Corbett 
Authored: Thu Feb 4 14:31:40 2016 +
Committer: Sam Corbett 
Committed: Thu Feb 4 14:31:40 2016 +

--
 .../catalog/internal/BasicBrooklynCatalog.java  |   2 +-
 rest/rest-client/pom.xml|   5 +
 .../brooklyn/rest/client/BrooklynApiUtil.java   | 154 +++
 .../rest/client/BrooklynApiUtilTest.java| 129 
 4 files changed, 289 insertions(+), 1 deletion(-)
--