You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by tb...@apache.org on 2017/10/19 13:39:54 UTC
[4/5] brooklyn-server git commit: Move Tasks.dumpInfo to Dumper.*
Move Tasks.dumpInfo to Dumper.*
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/bea2e7d8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/bea2e7d8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/bea2e7d8
Branch: refs/heads/master
Commit: bea2e7d8dfdea2d677ea3bbd243652c8b55b5ce0
Parents: 84eb1d0
Author: Aled Sage <al...@gmail.com>
Authored: Thu Oct 19 10:00:03 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Oct 19 10:03:38 2017 +0100
----------------------------------------------------------------------
.../org/apache/brooklyn/core/entity/Dumper.java | 35 +++++++++++++++++---
.../apache/brooklyn/util/core/task/Tasks.java | 29 ++++++++++++----
.../rest/resources/ActivityRestTest.java | 4 +--
3 files changed, 54 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bea2e7d8/core/src/main/java/org/apache/brooklyn/core/entity/Dumper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/Dumper.java b/core/src/main/java/org/apache/brooklyn/core/entity/Dumper.java
index 17fdcf7..7323e11 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/Dumper.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/Dumper.java
@@ -34,6 +34,7 @@ import java.util.concurrent.ExecutionException;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.Group;
import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.HasTaskChildren;
import org.apache.brooklyn.api.mgmt.Task;
import org.apache.brooklyn.api.policy.Policy;
import org.apache.brooklyn.api.sensor.AttributeSensor;
@@ -54,7 +55,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
- * Convenience methods for dumping info about entities etc.
+ * Convenience methods for dumping info about entities, locations, policies, etc.
*/
public class Dumper {
@@ -242,10 +243,6 @@ public class Dumper {
out.flush();
}
- public static void dumpInfo(Task<?> t) {
- Dumper.dumpInfo(t);
- }
-
public static void dumpInfo(Enricher enr) {
try {
dumpInfo(enr, new PrintWriter(System.out), "", " ");
@@ -336,6 +333,34 @@ public class Dumper {
out.flush();
}
+ public static void dumpInfo(Task<?> t) {
+ try {
+ dumpInfo(t, new PrintWriter(System.out), "", " ");
+ } catch (IOException exc) {
+ // system.out throwing an exception is odd, so don't have IOException on signature
+ throw new RuntimeException(exc);
+ }
+ }
+
+ public static void dumpInfo(Task<?> t, Writer out) throws IOException {
+ dumpInfo(t, out, "", " ");
+ }
+
+ static void dumpInfo(Task<?> t, String currentIndentation, String tab) throws IOException {
+ dumpInfo(t, new PrintWriter(System.out), currentIndentation, tab);
+ }
+
+ static void dumpInfo(Task<?> t, Writer out, String currentIndentation, String tab) throws IOException {
+ out.append(currentIndentation+t+": "+t.getStatusDetail(false)+"\n");
+
+ if (t instanceof HasTaskChildren) {
+ for (Task<?> child: ((HasTaskChildren)t).getChildren()) {
+ dumpInfo(child, out, currentIndentation+tab, tab);
+ }
+ }
+ out.flush();
+ }
+
@SuppressWarnings({ "rawtypes", "unchecked" })
static List<Sensor<?>> sortSensors(Set<Sensor<?>> sensors) {
List result = new ArrayList(sensors);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bea2e7d8/core/src/main/java/org/apache/brooklyn/util/core/task/Tasks.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/task/Tasks.java b/core/src/main/java/org/apache/brooklyn/util/core/task/Tasks.java
index 90a6bdc..a31c663 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/task/Tasks.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/task/Tasks.java
@@ -37,6 +37,7 @@ import org.apache.brooklyn.api.mgmt.TaskAdaptable;
import org.apache.brooklyn.api.mgmt.TaskFactory;
import org.apache.brooklyn.api.mgmt.TaskQueueingContext;
import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.entity.Dumper;
import org.apache.brooklyn.util.core.config.ConfigBag;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.exceptions.ReferenceWithError;
@@ -502,20 +503,34 @@ public class Tasks {
}
+ /**
+ * @deprecated since 1.0.0; instead use {@link Dumper} methods
+ */
+ @Deprecated
public static void dumpInfo(Task<?> t) {
- try {
- dumpInfo(t, new PrintWriter(System.out), "", " ");
- } catch (IOException exc) {
- // system.out throwing an exception is odd, so don't have IOException on signature
- throw new RuntimeException(exc);
- }
+ Dumper.dumpInfo(t);
}
+
+ /**
+ * @deprecated since 1.0.0; instead use {@link Dumper} methods
+ */
+ @Deprecated
public static void dumpInfo(Task<?> t, Writer out) throws IOException {
- dumpInfo(t, out, "", " ");
+ Dumper.dumpInfo(t, out);
}
+
+ /**
+ * @deprecated since 1.0.0; instead use {@link Dumper} methods
+ */
+ @Deprecated
public static void dumpInfo(Task<?> t, String currentIndentation, String tab) throws IOException {
dumpInfo(t, new PrintWriter(System.out), currentIndentation, tab);
}
+
+ /**
+ * @deprecated since 1.0.0; instead use {@link Dumper} methods
+ */
+ @Deprecated
public static void dumpInfo(Task<?> t, Writer out, String currentIndentation, String tab) throws IOException {
out.append(currentIndentation+t+": "+t.getStatusDetail(false)+"\n");
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bea2e7d8/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
index a5424f8..fe7c6ff 100644
--- a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
+++ b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ActivityRestTest.java
@@ -33,6 +33,7 @@ import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.mgmt.HasTaskChildren;
import org.apache.brooklyn.api.mgmt.Task;
import org.apache.brooklyn.core.effector.SampleManyTasksEffector;
+import org.apache.brooklyn.core.entity.Dumper;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.mgmt.EntityManagementUtils;
import org.apache.brooklyn.core.mgmt.EntityManagementUtils.CreationResult;
@@ -43,7 +44,6 @@ import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.apache.brooklyn.util.core.task.Tasks;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.http.HttpAsserts;
import org.apache.brooklyn.util.time.CountdownTimer;
@@ -133,7 +133,7 @@ Task[eatand]@J90TKfIX: Waiting on Task[eat-sleep-rave-repeat]@QPa5o4kF
}
i++;
} while (true);
- Tasks.dumpInfo(me.lastTask);
+ Dumper.dumpInfo(me.lastTask);
log.info("Seed "+i+" is good ^");
}