You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2013/03/15 21:46:58 UTC

git commit: Reduce dependency on Groovy classes to a single class AbstractRequest.

Updated Branches:
  refs/heads/master 61c4d0307 -> 282261ff6


Reduce dependency on Groovy classes to a single class AbstractRequest.


Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/282261ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/282261ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/282261ff

Branch: refs/heads/master
Commit: 282261ff6026c5bd35163e5bd2905195714c2908
Parents: 61c4d03
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Fri Mar 15 16:46:54 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Fri Mar 15 16:46:54 2013 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/shell/AbstractRequest.java      |   42 ++++++++------
 .../org/apache/hadoop/gateway/shell/Hadoop.java    |   11 ----
 .../hadoop/gateway/shell/hdfs/Example.groovy       |    9 ++--
 3 files changed, 28 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/282261ff/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/AbstractRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/AbstractRequest.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/AbstractRequest.java
index 02f8a8a..d987c4f 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/AbstractRequest.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/AbstractRequest.java
@@ -1,19 +1,3 @@
-package org.apache.hadoop.gateway.shell;
-
-import groovy.lang.Closure;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.message.BasicNameValuePair;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -31,6 +15,22 @@ import java.util.concurrent.Future;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.hadoop.gateway.shell;
+
+import groovy.lang.Closure;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.message.BasicNameValuePair;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
 public abstract class AbstractRequest<T> {
 
   private Hadoop hadoop;
@@ -73,8 +73,14 @@ public abstract class AbstractRequest<T> {
     return hadoop().executeLater( callable() );
   }
 
-  public void later( Closure<T> closure ) {
-    hadoop().executeLater( callable(), closure );
+  public void later( final Closure<T> closure ) {
+    hadoop().executeLater( new Callable<T>() {
+      @Override
+      public T call() throws Exception {
+        return closure.call( callable().call() );
+      }
+    } );
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/282261ff/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
index 9dd4aee..4fcd3c9 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.gateway.shell;
 
-import groovy.lang.Closure;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
@@ -105,14 +104,4 @@ public class Hadoop {
     return executor.submit( callable );
   }
 
-  public <T> void executeLater( final Callable<T> callable, final Closure<T> closure ) {
-    executor.submit( new Callable<T>() {
-      @Override
-      public T call() throws Exception {
-        closure.call( callable.call() );
-        return null;
-      }
-    } );
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/282261ff/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Example.groovy
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Example.groovy b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Example.groovy
index 2bb88a5..4408652 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Example.groovy
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Example.groovy
@@ -37,11 +37,10 @@ hdfs.mkdir(hadoop).dir( "/tmp/test").now()
 
 hdfs.put(hadoop).file( inputFile ).to( "/tmp/test/input/LICENSE" ).now()
 
-hdfs.get(hadoop).file( "/Users/kevin.minder/Projects/gateway-0.2.0-SNAPSHOT/OUTPUT" ).from( "/tmp/test/input/LICENSE" ).now()
-
 future = hdfs.put(hadoop).file( inputFile ).to( "/tmp/test/input/LICENSE2" ).later()
 println future.get().statusCode
 
-hdfs.put(hadoop).file( inputFile ).to( "/tmp/test/input/LICENSE3" ).later() {
-  println it.statusCode
-}
+hdfs.put(hadoop).file( inputFile ).to( "/tmp/test/input/LICENSE3" ).later() { println it.statusCode }
+
+hdfs.get(hadoop).file( "/Users/kevin.minder/Projects/gateway-0.2.0-SNAPSHOT/OUTPUT" ).from( "/tmp/test/input/LICENSE" ).now()
+