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/09/07 01:11:41 UTC

git commit: Rename some of the groovy samples to more clearly describe purpose. Also updated some to use user's home dir instead of tmp.

Updated Branches:
  refs/heads/master 07b887083 -> 3952c850d


Rename some of the groovy samples to more clearly describe purpose.  Also updated some to use user's home dir instead of tmp.


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

Branch: refs/heads/master
Commit: 3952c850d78bc5273d1cc575f3976209f124463f
Parents: 07b8870
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Fri Sep 6 19:11:31 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Fri Sep 6 19:11:31 2013 -0400

----------------------------------------------------------------------
 gateway-release/home/samples/ExampleHdfs.groovy |  37 -------
 .../home/samples/ExampleOozieWorkflow.groovy    | 104 +++++++++++++++++++
 .../home/samples/ExamplePutFile.groovy          |  34 ------
 .../home/samples/ExampleSubmitJob.groovy        |  64 ------------
 .../home/samples/ExampleSubmitWorkflow.groovy   |  98 -----------------
 .../home/samples/ExampleWebHCatJob.groovy       |  62 +++++++++++
 .../home/samples/ExampleWebHdfsGet.groovy       |  37 +++++++
 .../home/samples/ExampleWebHdfsLs.groovy        |  31 ++++++
 .../home/samples/ExampleWebHdfsPut.groovy       |  35 +++++++
 9 files changed, 269 insertions(+), 233 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleHdfs.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleHdfs.groovy b/gateway-release/home/samples/ExampleHdfs.groovy
deleted file mode 100644
index 1f45f99..0000000
--- a/gateway-release/home/samples/ExampleHdfs.groovy
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.
- */
-
-import groovy.json.JsonSlurper
-import org.apache.hadoop.gateway.shell.Hadoop
-import org.apache.hadoop.gateway.shell.hdfs.Hdfs
-
-gateway = "https://localhost:8443/gateway/sample"
-username = "hue"
-password = "hue-password"
-dataFile = "README"
-
-session = Hadoop.login( gateway, username, password )
-Hdfs.rm( session ).file( "/tmp/example" ).recursive().now()
-Hdfs.put( session ).file( dataFile ).to( "/tmp/example/README" ).now()
-text = Hdfs.ls( session ).dir( "/tmp/example" ).now().string
-json = (new JsonSlurper()).parseText( text )
-println json.FileStatuses.FileStatus.pathSuffix
-text = Hdfs.get( session ).from( "/tmp/example/README" ).now().string
-println text
-Hdfs.rm( session ).file( "/tmp/example" ).recursive().now()
-session.shutdown()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleOozieWorkflow.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleOozieWorkflow.groovy b/gateway-release/home/samples/ExampleOozieWorkflow.groovy
new file mode 100644
index 0000000..ac83c13
--- /dev/null
+++ b/gateway-release/home/samples/ExampleOozieWorkflow.groovy
@@ -0,0 +1,104 @@
+/**
+ * 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.
+ */
+import com.jayway.jsonpath.JsonPath
+import org.apache.hadoop.gateway.shell.Hadoop
+import org.apache.hadoop.gateway.shell.hdfs.Hdfs
+import org.apache.hadoop.gateway.shell.workflow.Workflow
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+gateway = "https://localhost:8443/gateway/sample"
+jobTracker = "sandbox.hortonworks.com:8050"
+nameNode = "sandbox.hortonworks.com:8020"
+username = "hue"
+password = "hue-password"
+inputFile = "LICENSE"
+jarFile = "samples/hadoop-examples.jar"
+
+definition = """\
+<workflow-app xmlns="uri:oozie:workflow:0.2" name="wordcount-workflow">
+    <start to="root-node"/>
+    <action name="root-node">
+        <java>
+            <job-tracker>set-via-configuration-property</job-tracker>
+            <name-node>set-via-configuration-property</name-node>
+            <main-class>org.apache.hadoop.examples.WordCount</main-class>
+            <arg>/tmp/test/input</arg>
+            <arg>/tmp/test/output</arg>
+        </java>
+        <ok to="end"/>
+        <error to="fail"/>
+    </action>
+    <kill name="fail">
+        <message>Java failed, error message[\${wf:errorMessage(wf:lastErrorNode())}]</message>
+    </kill>
+    <end name="end"/>
+</workflow-app>
+"""
+
+configuration = """\
+<configuration>
+    <property>
+        <name>user.name</name>
+        <value>$username</value>
+    </property>
+    <property>
+        <name>nameNode</name>
+        <value>hdfs://$nameNode</value>
+    </property>
+    <property>
+        <name>jobTracker</name>
+        <value>$jobTracker</value>
+    </property>
+    <property>
+        <name>oozie.wf.application.path</name>
+        <value>hdfs://$nameNode/tmp/test</value>
+    </property>
+</configuration>
+"""
+
+session = Hadoop.login( gateway, username, password )
+
+println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
+println "Mkdir /tmp/test " + Hdfs.mkdir( session ).dir( "/tmp/test" ).now().statusCode
+
+putWorkflow = Hdfs.put(session).text( definition ).to( "/tmp/test/workflow.xml" ).later() {
+  println "Put /tmp/test/workflow.xml " + it.statusCode }
+
+putData = Hdfs.put(session).file( inputFile ).to( "/tmp/test/input/FILE" ).later() {
+  println "Put /tmp/test/input/FILE " + it.statusCode }
+
+putJar = Hdfs.put(session).file( jarFile ).to( "/tmp/test/lib/hadoop-examples.jar" ).later() {
+  println "Put /tmp/test/lib/hadoop-examples.jar " + it.statusCode }
+
+session.waitFor( putWorkflow, putData, putJar )
+
+jobId = Workflow.submit(session).text( configuration ).now().jobId
+println "Submitted job " + jobId
+
+println "Polling for completion..."
+status = "UNKNOWN";
+count = 0;
+while( status != "SUCCEEDED" && count++ < 60 ) {
+  sleep( 1000 )
+  json = Workflow.status(session).jobId( jobId ).now().string
+  status = JsonPath.read( json, "\$.status" )
+}
+println "Job status " + status;
+
+println "Shutdown " + session.shutdown( 10, SECONDS )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExamplePutFile.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExamplePutFile.groovy b/gateway-release/home/samples/ExamplePutFile.groovy
deleted file mode 100644
index 1ee6087..0000000
--- a/gateway-release/home/samples/ExamplePutFile.groovy
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.
- */
-
-import groovy.json.JsonSlurper
-import org.apache.hadoop.gateway.shell.Hadoop
-import org.apache.hadoop.gateway.shell.hdfs.Hdfs
-
-gateway = "https://localhost:8443/gateway/sample"
-username = "hue"
-password = "hue-password"
-dataFile = "README"
-
-session = Hadoop.login( gateway, username, password )
-Hdfs.rm( session ).file( "/tmp/example" ).recursive().now()
-Hdfs.put( session ).file( dataFile ).to( "/tmp/example/README" ).now()
-text = Hdfs.ls( session ).dir( "/tmp/example" ).now().string
-json = (new JsonSlurper()).parseText( text )
-println json.FileStatuses.FileStatus.pathSuffix
-session.shutdown()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleSubmitJob.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleSubmitJob.groovy b/gateway-release/home/samples/ExampleSubmitJob.groovy
deleted file mode 100644
index 6fc11d3..0000000
--- a/gateway-release/home/samples/ExampleSubmitJob.groovy
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.
- */
-import com.jayway.jsonpath.JsonPath
-import org.apache.hadoop.gateway.shell.Hadoop
-import org.apache.hadoop.gateway.shell.hdfs.Hdfs
-import org.apache.hadoop.gateway.shell.job.Job
-
-import static java.util.concurrent.TimeUnit.SECONDS
-
-gateway = "https://localhost:8443/gateway/sample"
-username = "hue"
-password = "hue-password"
-dataFile = "LICENSE"
-jarFile = "samples/hadoop-examples.jar"
-
-session = Hadoop.login( gateway, username, password )
-
-println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
-println "Create /tmp/test " + Hdfs.mkdir( session ).dir( "/tmp/test").now().statusCode
-
-putData = Hdfs.put(session).file( dataFile ).to( "/tmp/test/input/FILE" ).later() {
-  println "Put /tmp/test/input/FILE " + it.statusCode }
-
-putJar = Hdfs.put(session).file( jarFile ).to( "/tmp/test/hadoop-examples.jar" ).later() {
-  println "Put /tmp/test/hadoop-examples.jar " + it.statusCode }
-
-session.waitFor( putData, putJar )
-
-jobId = Job.submitJava(session) \
-  .jar( "/tmp/test/hadoop-examples.jar" ) \
-  .app( "wordcount" ) \
-  .input( "/tmp/test/input" ) \
-  .output( "/tmp/test/output" ) \
-  .now().jobId
-println "Submitted job " + jobId
-
-println "Polling for completion..."
-done = false
-count = 0
-while( !done && count++ < 60 ) {
-  sleep( 1000 )
-  json = Job.queryStatus(session).jobId(jobId).now().string
-  done = JsonPath.read( json, "\$.status.jobComplete" )
-}
-println "Done " + done
-
-println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
-
-println "Shutdown " + session.shutdown( 10, SECONDS )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleSubmitWorkflow.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleSubmitWorkflow.groovy b/gateway-release/home/samples/ExampleSubmitWorkflow.groovy
deleted file mode 100644
index c3e6f2e..0000000
--- a/gateway-release/home/samples/ExampleSubmitWorkflow.groovy
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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.
- */
-import com.jayway.jsonpath.JsonPath
-import org.apache.hadoop.gateway.shell.Hadoop
-import org.apache.hadoop.gateway.shell.hdfs.Hdfs
-import org.apache.hadoop.gateway.shell.workflow.Workflow
-
-import static java.util.concurrent.TimeUnit.SECONDS
-
-gateway = "https://localhost:8443/gateway/sample"
-jobTracker = "sandbox.hortonworks.com:8050"
-nameNode = "sandbox.hortonworks.com:8020"
-username = "hue"
-password = "hue-password"
-inputFile = "LICENSE"
-jarFile = "samples/hadoop-examples.jar"
-
-definition = """\
-<workflow-app xmlns="uri:oozie:workflow:0.2" name="wordcount-workflow">
-    <start to="root-node"/>
-    <action name="root-node">
-        <java>
-            <job-tracker>$jobTracker</job-tracker>
-            <name-node>hdfs://$nameNode</name-node>
-            <main-class>org.apache.hadoop.examples.WordCount</main-class>
-            <arg>/tmp/test/input</arg>
-            <arg>/tmp/test/output</arg>
-        </java>
-        <ok to="end"/>
-        <error to="fail"/>
-    </action>
-    <kill name="fail">
-        <message>Java failed, error message[\${wf:errorMessage(wf:lastErrorNode())}]</message>
-    </kill>
-    <end name="end"/>
-</workflow-app>
-"""
-
-configuration = """\
-<configuration>
-    <property>
-        <name>user.name</name>
-        <value>$username</value>
-    </property>
-    <property>
-        <name>oozie.wf.application.path</name>
-        <value>hdfs://$nameNode/tmp/test</value>
-    </property>
-</configuration>
-"""
-
-session = Hadoop.login( gateway, username, password )
-
-println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
-println "Mkdir /tmp/test " + Hdfs.mkdir( session ).dir( "/tmp/test" ).now().statusCode
-
-putWorkflow = Hdfs.put(session).text( definition ).to( "/tmp/test/workflow.xml" ).later() {
-  println "Put /tmp/test/workflow.xml " + it.statusCode }
-
-putData = Hdfs.put(session).file( inputFile ).to( "/tmp/test/input/FILE" ).later() {
-  println "Put /tmp/test/input/FILE " + it.statusCode }
-
-putJar = Hdfs.put(session).file( jarFile ).to( "/tmp/test/lib/hadoop-examples.jar" ).later() {
-  println "Put /tmp/test/lib/hadoop-examples.jar " + it.statusCode }
-
-session.waitFor( putWorkflow, putData, putJar )
-
-jobId = Workflow.submit(session).text( configuration ).now().jobId
-println "Submitted job " + jobId
-
-println "Polling for completion..."
-status = "UNKNOWN";
-count = 0;
-while( status != "SUCCEEDED" && count++ < 60 ) {
-  sleep( 1000 )
-  json = Workflow.status(session).jobId( jobId ).now().string
-  status = JsonPath.read( json, "\$.status" )
-}
-println "Job status " + status;
-
-println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
-
-println "Shutdown " + session.shutdown( 10, SECONDS )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleWebHCatJob.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleWebHCatJob.groovy b/gateway-release/home/samples/ExampleWebHCatJob.groovy
new file mode 100644
index 0000000..bd4fb56
--- /dev/null
+++ b/gateway-release/home/samples/ExampleWebHCatJob.groovy
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+import com.jayway.jsonpath.JsonPath
+import org.apache.hadoop.gateway.shell.Hadoop
+import org.apache.hadoop.gateway.shell.hdfs.Hdfs
+import org.apache.hadoop.gateway.shell.job.Job
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+gateway = "https://localhost:8443/gateway/sample"
+username = "hue"
+password = "hue-password"
+dataFile = "LICENSE"
+jarFile = "samples/hadoop-examples.jar"
+
+session = Hadoop.login( gateway, username, password )
+
+println "Delete /tmp/test " + Hdfs.rm( session ).file( "/tmp/test" ).recursive().now().statusCode
+println "Create /tmp/test " + Hdfs.mkdir( session ).dir( "/tmp/test").now().statusCode
+
+putData = Hdfs.put(session).file( dataFile ).to( "/tmp/test/input/FILE" ).later() {
+  println "Put /tmp/test/input/FILE " + it.statusCode }
+
+putJar = Hdfs.put(session).file( jarFile ).to( "/tmp/test/hadoop-examples.jar" ).later() {
+  println "Put /tmp/test/hadoop-examples.jar " + it.statusCode }
+
+session.waitFor( putData, putJar )
+
+jobId = Job.submitJava(session) \
+  .jar( "/tmp/test/hadoop-examples.jar" ) \
+  .app( "wordcount" ) \
+  .input( "/tmp/test/input" ) \
+  .output( "/tmp/test/output" ) \
+  .now().jobId
+println "Submitted job " + jobId
+
+println "Polling for completion..."
+done = false
+count = 0
+while( !done && count++ < 60 ) {
+  sleep( 1000 )
+  json = Job.queryStatus(session).jobId(jobId).now().string
+  done = JsonPath.read( json, "\$.status.jobComplete" )
+}
+println "Done " + done
+
+println "Shutdown " + session.shutdown( 10, SECONDS )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleWebHdfsGet.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleWebHdfsGet.groovy b/gateway-release/home/samples/ExampleWebHdfsGet.groovy
new file mode 100644
index 0000000..bb95b94
--- /dev/null
+++ b/gateway-release/home/samples/ExampleWebHdfsGet.groovy
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+import groovy.json.JsonSlurper
+import org.apache.hadoop.gateway.shell.Hadoop
+import org.apache.hadoop.gateway.shell.hdfs.Hdfs
+
+gateway = "https://localhost:8443/gateway/sample"
+username = "hue"
+password = "hue-password"
+dataDir = "/user/" + username + "/example"
+dataFile = "README"
+
+session = Hadoop.login( gateway, username, password )
+Hdfs.rm( session ).file( dataDir ).recursive().now()
+Hdfs.put( session ).file( dataFile ).to( dataDir + "/" + dataFile ).now()
+text = Hdfs.ls( session ).dir( dataDir ).now().string
+json = (new JsonSlurper()).parseText( text )
+println json.FileStatuses.FileStatus.pathSuffix
+text = Hdfs.get( session ).from( dataDir + "/" + dataFile ).now().string
+println text
+session.shutdown()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleWebHdfsLs.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleWebHdfsLs.groovy b/gateway-release/home/samples/ExampleWebHdfsLs.groovy
new file mode 100644
index 0000000..04e7c2d
--- /dev/null
+++ b/gateway-release/home/samples/ExampleWebHdfsLs.groovy
@@ -0,0 +1,31 @@
+/**
+ * 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.
+ */
+
+import groovy.json.JsonSlurper
+import org.apache.hadoop.gateway.shell.Hadoop
+import org.apache.hadoop.gateway.shell.hdfs.Hdfs
+
+gateway = "https://localhost:8443/gateway/sample"
+username = "hue"
+password = "hue-password"
+
+session = Hadoop.login( gateway, username, password )
+text = Hdfs.ls( session ).dir( "/" ).now().string
+json = (new JsonSlurper()).parseText( text )
+println json.FileStatuses.FileStatus.pathSuffix
+session.shutdown()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/3952c850/gateway-release/home/samples/ExampleWebHdfsPut.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleWebHdfsPut.groovy b/gateway-release/home/samples/ExampleWebHdfsPut.groovy
new file mode 100644
index 0000000..2412448
--- /dev/null
+++ b/gateway-release/home/samples/ExampleWebHdfsPut.groovy
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+import groovy.json.JsonSlurper
+import org.apache.hadoop.gateway.shell.Hadoop
+import org.apache.hadoop.gateway.shell.hdfs.Hdfs
+
+gateway = "https://localhost:8443/gateway/sample"
+username = "hue"
+password = "hue-password"
+dataDir = "/user/" + username + "/example"
+dataFile = "README"
+
+session = Hadoop.login( gateway, username, password )
+Hdfs.rm( session ).file( dataDir ).recursive().now()
+Hdfs.put( session ).file( dataFile ).to( dataDir + "/" + dataFile ).now()
+text = Hdfs.ls( session ).dir( dataDir ).now().string
+json = (new JsonSlurper()).parseText( text )
+println json.FileStatuses.FileStatus.pathSuffix
+session.shutdown()
\ No newline at end of file