knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: Add closure support to client.
Date Fri, 15 Mar 2013 20:25:07 GMT
Updated Branches:
  refs/heads/master 511fae36d -> 61c4d0307


Add closure support to client.


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

Branch: refs/heads/master
Commit: 61c4d0307cd5ca86f754f7318aa3145e781c5bd4
Parents: 511fae3
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Fri Mar 15 16:25:02 2013 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Fri Mar 15 16:25:02 2013 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/shell/AbstractRequest.java      |    5 +++++
 .../org/apache/hadoop/gateway/shell/Hadoop.java    |   11 +++++++++++
 .../hadoop/gateway/shell/hdfs/Example.groovy       |    4 ++++
 3 files changed, 20 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/61c4d030/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 1e5eeee..02f8a8a 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,5 +1,6 @@
 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;
@@ -72,4 +73,8 @@ public abstract class AbstractRequest<T> {
     return hadoop().executeLater( callable() );
   }
 
+  public void later( Closure<T> closure ) {
+    hadoop().executeLater( callable(), closure );
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/61c4d030/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 4fcd3c9..9dd4aee 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,6 +17,7 @@
  */
 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;
@@ -104,4 +105,14 @@ 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/61c4d030/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 4d39b93..2bb88a5 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
@@ -41,3 +41,7 @@ hdfs.get(hadoop).file( "/Users/kevin.minder/Projects/gateway-0.2.0-SNAPSHOT/OUTP
 
 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
+}


Mime
View raw message