brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [2/5] brooklyn-server git commit: minor tidies to utils
Date Mon, 31 Oct 2016 12:24:26 GMT
minor tidies to utils


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

Branch: refs/heads/master
Commit: aa3f1835fbf8104c0426f201343fe2d48241d71d
Parents: d9e4bac
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Sep 28 15:28:02 2016 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Sep 28 15:36:58 2016 +0100

----------------------------------------------------------------------
 .../entity/chef/ChefLiveTestSupport.java        | 20 ++++++--------------
 .../org/apache/brooklyn/util/ShellUtils.java    |  8 ++++----
 .../org/apache/brooklyn/util/http/HttpTool.java |  2 ++
 .../brooklyn/util/io/FilePermissions.java       | 17 +++++++++--------
 .../util/net/ReachableSocketFinder.java         |  1 -
 .../java/org/apache/brooklyn/util/os/Os.java    |  4 +---
 .../apache/brooklyn/util/repeat/Repeater.java   |  2 +-
 .../util/stream/InputStreamSupplier.java        |  4 ++++
 .../apache/brooklyn/util/text/Identifiers.java  |  2 ++
 .../util/collections/MutableSetTest.java        |  1 -
 10 files changed, 29 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/software/base/src/test/java/org/apache/brooklyn/entity/chef/ChefLiveTestSupport.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/chef/ChefLiveTestSupport.java
b/software/base/src/test/java/org/apache/brooklyn/entity/chef/ChefLiveTestSupport.java
index 9ee38e7..ff389b0 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/chef/ChefLiveTestSupport.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/chef/ChefLiveTestSupport.java
@@ -19,7 +19,6 @@
 package org.apache.brooklyn.entity.chef;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.brooklyn.api.entity.Entity;
@@ -31,13 +30,11 @@ import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.io.FileUtil;
-import org.apache.brooklyn.util.stream.InputStreamSupplier;
 import org.apache.brooklyn.util.stream.Streams;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
 
-import com.google.common.base.Throwables;
 import com.google.common.io.Files;
 
 public class ChefLiveTestSupport extends BrooklynAppLiveTestSupport {
@@ -82,18 +79,13 @@ public class ChefLiveTestSupport extends BrooklynAppLiveTestSupport {
         if (defaultConfigFile!=null) return defaultConfigFile;
         File tempDir = Files.createTempDir();
         ResourceUtils r = ResourceUtils.create(ChefServerTasksIntegrationTest.class);
-        try {
-            for (String f: new String[] { "knife.rb", "brooklyn-tests.pem", "brooklyn-validator.pem"
}) {
-                String contents = r.getResourceAsString("classpath:///org/apache/brooklyn/entity/chef/hosted-chef-brooklyn-credentials/"+f);
-                InputStream in = InputStreamSupplier.fromString(contents).getInput();
-                try {
-                    FileUtil.copyTo(in, new File(tempDir, f));
-                } finally {
-                    Streams.closeQuietly(in);
-                }
+        for (String f: new String[] { "knife.rb", "brooklyn-tests.pem", "brooklyn-validator.pem"
}) {
+            InputStream in = r.getResourceFromUrl("classpath:///org/apache/brooklyn/entity/chef/hosted-chef-brooklyn-credentials/"+f);
+            try {
+                FileUtil.copyTo(in, new File(tempDir, f));
+            } finally {
+                Streams.closeQuietly(in);
             }
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
         }
         File knifeConfig = new File(tempDir, "knife.rb");
         defaultConfigFile = knifeConfig.getPath();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/ShellUtils.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/ShellUtils.java b/utils/common/src/main/java/org/apache/brooklyn/util/ShellUtils.java
index 7a9b1af..ce053b2 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/ShellUtils.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/ShellUtils.java
@@ -64,11 +64,11 @@ public class ShellUtils {
         return exec(new String[] { "bash", "-l", "-c", cmd }, null, null, input, log, context);
     }
     /** @see {@link #exec(Map, String[], String[], File, String, Logger, Object)} */
-    public static String[] exec(Map flags, String cmd, Logger log, Object context) {
+    public static String[] exec(Map<?,?> flags, String cmd, Logger log, Object context)
{
         return exec(flags, new String[] { "bash", "-l", "-c", cmd }, null, null, null, log,
context);
     }
     /** @see {@link #exec(Map, String[], String[], File, String, Logger, Object)} */
-    public static String[] exec(Map flags, String cmd, String input, Logger log, Object context)
{
+    public static String[] exec(Map<?,?> flags, String cmd, String input, Logger log,
Object context) {
         return exec(flags, new String[] { "bash", "-l", "-c", cmd }, null, null, input, log,
context);
     }
     /** @see {@link #exec(Map, String[], String[], File, String, Logger, Object)} */
@@ -76,7 +76,7 @@ public class ShellUtils {
         return exec(Maps.newLinkedHashMap(), cmd, envp, dir, input, log, context);
     }
 
-    private static long getTimeoutMs(Map flags) {
+    private static long getTimeoutMs(Map<?,?> flags) {
         long timeout = TIMEOUT;
 
         Object tf = flags.get("timeout");
@@ -103,7 +103,7 @@ public class ShellUtils {
      * @throws IllegalStateException if return code non-zero
      * @return lines from stdout.
      */
-    public static String[] exec(Map flags, final String[] cmd, String[] envp, File dir, String
input, final Logger log, final Object context) {
+    public static String[] exec(Map<?,?> flags, final String[] cmd, String[] envp,
File dir, String input, final Logger log, final Object context) {
         if (log.isDebugEnabled()) {
             log.debug("Running local command: {}% {}", context, Strings.join(cmd, " "));
         }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/http/HttpTool.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/http/HttpTool.java b/utils/common/src/main/java/org/apache/brooklyn/util/http/HttpTool.java
index 719f304..e704886 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/http/HttpTool.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/http/HttpTool.java
@@ -241,6 +241,8 @@ public class HttpTool {
         return new HttpClientBuilder();
     }
     
+    // TODO deprecate this and use the new Apache Commons HttpClientBuilder instead
+    @SuppressWarnings("deprecation")
     public static class HttpClientBuilder {
         private ClientConnectionManager clientConnectionManager;
         private HttpParams httpParams;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/io/FilePermissions.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/io/FilePermissions.java b/utils/common/src/main/java/org/apache/brooklyn/util/io/FilePermissions.java
index d366af5..b59d77e 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/io/FilePermissions.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/io/FilePermissions.java
@@ -15,23 +15,24 @@
  */
 package org.apache.brooklyn.util.io;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.attribute.PosixFileAttributeView;
-import java.nio.file.attribute.PosixFilePermission;
 import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE;
 import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
 import static java.nio.file.attribute.PosixFilePermission.GROUP_WRITE;
+import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE;
 import static java.nio.file.attribute.PosixFilePermission.OTHERS_READ;
 import static java.nio.file.attribute.PosixFilePermission.OTHERS_WRITE;
-import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE;
+import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
 import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
 import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
-import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermission;
 import java.util.EnumSet;
 import java.util.Set;
+
 import org.apache.brooklyn.util.os.Os;
 
 /**

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
b/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
index 72fb71c..05c1fa3 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
@@ -18,7 +18,6 @@ package org.apache.brooklyn.util.net;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.util.concurrent.MoreExecutors.listeningDecorator;
 
 import java.util.Collection;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java b/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
index 6ff2b3a..27a2c70 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
@@ -34,7 +34,7 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 import org.apache.brooklyn.util.net.Urls;
-import org.apache.brooklyn.util.os.Os;
+import org.apache.brooklyn.util.osgi.OsgiUtil;
 import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.text.Strings;
@@ -51,8 +51,6 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.io.ByteStreams;
 import com.google.common.io.Files;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.brooklyn.util.osgi.OsgiUtil;
 
 public class Os {
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java b/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
index 9dfc9fb..581a61b 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
@@ -346,7 +346,7 @@ public class Repeater implements Callable<Boolean> {
                 if (log.isDebugEnabled()) {
                     String msg = String.format("%s: unsatisfied during iteration %s %s",
description, iterations,
                         (iterationLimit > 0 ? "(max "+iterationLimit+" attempts)" : "")
+ 
-                        (timer.isRunning() ? "("+Time.makeTimeStringRounded(timer.getDurationRemaining())+"
remaining)" : ""));
+                        (timer.isNotPaused() ? "("+Time.makeTimeStringRounded(timer.getDurationRemaining())+"
remaining)" : ""));
                     if (iterations == 1) {
                         log.debug(msg);
                     } else {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/stream/InputStreamSupplier.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/stream/InputStreamSupplier.java
b/utils/common/src/main/java/org/apache/brooklyn/util/stream/InputStreamSupplier.java
index e1832f1..2b6afac 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/stream/InputStreamSupplier.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/stream/InputStreamSupplier.java
@@ -21,8 +21,12 @@ package org.apache.brooklyn.util.stream;
 import java.io.IOException;
 import java.io.InputStream;
 
+import com.google.common.io.ByteSource;
 import com.google.common.io.InputSupplier;
 
+/** @deprecated since 0.10.0; underlying guava deprecated; 
+ * guava says to use a {@link ByteSource}; and in many cases there's also a better way */
+@Deprecated
 public class InputStreamSupplier implements InputSupplier<InputStream> {
 
     private final InputStream target;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java b/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
index d025f5c..97eb024 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
@@ -168,9 +168,11 @@ public class Identifiers {
         return Joiner.on("").join(list);
     }
 
+    @SuppressWarnings({ "rawtypes", "unchecked" })  
     protected static String mergeCharacterSets(String... s) {
         Set characters = new HashSet<Character>();
         for (String characterSet : s) {
+            // more efficient to lose the generics here
             characters.addAll(Arrays.asList(characterSet.split("")));
         }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/aa3f1835/utils/common/src/test/java/org/apache/brooklyn/util/collections/MutableSetTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/collections/MutableSetTest.java
b/utils/common/src/test/java/org/apache/brooklyn/util/collections/MutableSetTest.java
index fb776d3..fedb9c9 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/collections/MutableSetTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/collections/MutableSetTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.brooklyn.util.collections;
 
-import java.util.List;
 import java.util.Set;
 
 import org.testng.Assert;


Mime
View raw message