ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject git commit: AMBARI-6218 - favorite view example clean-up + doc (Jeff Sposetti via tbeerbower)
Date Mon, 23 Jun 2014 13:05:00 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 8da3c7cbd -> 4b7d557f5


AMBARI-6218 - favorite view example clean-up + doc (Jeff Sposetti via tbeerbower)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4b7d557f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4b7d557f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4b7d557f

Branch: refs/heads/branch-1.6.1
Commit: 4b7d557f50384a7d2708472f80fb08d2eed2fa81
Parents: 8da3c7c
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Mon Jun 23 09:04:03 2014 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Mon Jun 23 09:04:44 2014 -0400

----------------------------------------------------------------------
 ambari-views/docs/index.md                      | 22 +++---
 .../examples/favorite-view/docs/index.md        | 76 ++++++++++++++++++++
 .../favorite-view/src/main/resources/view.xml   |  7 +-
 3 files changed, 92 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4b7d557f/ambari-views/docs/index.md
----------------------------------------------------------------------
diff --git a/ambari-views/docs/index.md b/ambari-views/docs/index.md
index 4963b4c..479bc86 100644
--- a/ambari-views/docs/index.md
+++ b/ambari-views/docs/index.md
@@ -313,9 +313,12 @@ For example …
       }
 
 ###Persistence
-#####Application Data
-The application data map is a simple method for view application code to store key/value
pairs for a view instance.  

The application data map is different than the view instance
properties that are specified to instantiate the view.  The application data map may contain
any arbitrary string values that the view needs to persist and may be updated or queried at
any point during the life of the view instance by the application logic. 

The view context
contains methods to put and get values from the application data map.
-
      /**
+
+The application data map is different than the view instance properties that are specified
to instantiate the view.  The application data map may contain any arbitrary string values
that the view needs to persist and may be updated or queried at any point during the life
of the view instance by the application logic. 
+
+The view context contains methods to put and get values from the application data map.
+
+      /**
        * Save an instance data value for the given key.
        *
        * @param key    the key
@@ -344,17 +347,20 @@ The application data map is a simple method for view application code
to store k
        *
        * @param key  the key
        */
-      public void removeInstanceData(String key);
+
 #####DataStore
-The data store allows view instances to save JavaBean entities in the Ambari database.

The
view components may acquire a data store instance through the injected view context.  The
view context exposes a data store object … 
-
      /**
+The data store allows view instances to save JavaBean entities in the Ambari database.
+
+The view components may acquire a data store instance through the injected view context.
 The view context exposes a data store object … 
+
+      /**
        * Get a data store for view persistence entities.
        *
        * @return a data store
        */
       public DataStore getDataStore();
 
-The DataStore object exposes a simple interface for persisting view entities.  The basic
CRUD operations are supported …  
+The DataStore object exposes a simple interface for persisting view entities.  The basic
CRUD operations are supported …  
 
       /**
        * Save the given entity to persistent storage.  The entity must be declared as an
@@ -822,4 +828,4 @@ So, to access the UI of the above Files view the user would browse to
…
 
 
 
-![image](ui.png)
\ No newline at end of file
+![image](ui.png)

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b7d557f/ambari-views/examples/favorite-view/docs/index.md
----------------------------------------------------------------------
diff --git a/ambari-views/examples/favorite-view/docs/index.md b/ambari-views/examples/favorite-view/docs/index.md
index a3990d7..bc8b627 100644
--- a/ambari-views/examples/favorite-view/docs/index.md
+++ b/ambari-views/examples/favorite-view/docs/index.md
@@ -25,3 +25,79 @@ Package
 -----
 All views are packaged as a view archive. The view archive contains the configuration
 file and various optional components of the view.
+
+#####view.xml
+
+The view.xml file is the only required file for a view archive.  The view.xml is the configuration
that describes the view and view instances for Ambari.
+The view.xml for this example defines two required parameters for configuring a view instance:
what.is.the.question and i.do.not.know. The view also
+defines a single resource that exposes a REST service at the /favorite end point.
+
+    <view>
+      <name>FAVORITE</name>
+      <label>Favorite</label>
+      <version>1.0.0</version>
+      <parameter>
+        <name>what.is.the.question</name>
+        <description>Ask a question</description>
+        <required>true</required>
+      </parameter>
+      <parameter>
+        <name>i.do.not.know</name>
+        <description>If you do not know</description>
+        <required>true</required>
+      </parameter>
+      <resource>
+        <name>favorite</name>
+        <service-class>org.apache.ambari.view.favorite.FavoriteService</service-class>
+      </resource>
+    </view>
+
+Build
+-----
+
+The view can be built as a maven project.
+
+    cd ambari-views/examples/favorite-view
+    mvn clean package
+
+The build will produce the view archive.
+
+    ambari-views/examples/favorite-view/target/favorite-view-1.0.0.jar
+
+Place the view archive on the Ambari Server and restart to deploy.    
+
+    cp favorite-view-1.0.0.jar /var/lib/ambari-server/resources/views/
+    ambari-server restart
+    
+Create View Instance
+-----
+
+With the view deployed, create an instance of the view to be used by Ambari users.
+
+    POST
+    /api/v1/views/FAVORITE/versions/1.0.0/instances/FAVCOLOR
+    
+    [ {
+      "ViewInstanceInfo" : {
+        "label" : "Colors",
+        "description" : "Choose your favorite color",
+        "properties" : {
+          "what.is.the.question" : "What is your favorite color?",
+          "i.do.not.know" : "green"
+        }
+      }
+    } ]
+
+Access the view service end point:
+
+    /api/v1/views/FAVORITE/versions/1.0.0/instances/FAVCOLOR/resources/favorite
+
+To get the favorite color:
+
+    GET
+    /api/v1/views/FAVORITE/versions/1.0.0/instances/FAVCOLOR/resources/favorite/item
+
+To set the favorite color:
+
+    POST
+    /api/v1/views/FAVORITE/versions/1.0.0/instances/FAVCOLOR/resources/favorite/item/blue

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b7d557f/ambari-views/examples/favorite-view/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/ambari-views/examples/favorite-view/src/main/resources/view.xml b/ambari-views/examples/favorite-view/src/main/resources/view.xml
index f289536..abd09dd 100644
--- a/ambari-views/examples/favorite-view/src/main/resources/view.xml
+++ b/ambari-views/examples/favorite-view/src/main/resources/view.xml
@@ -17,8 +17,7 @@
 <view>
   <name>FAVORITE</name>
   <label>Favorite</label>
-  <version>0.1.0</version>
-
+  <version>1.0.0</version>
   <parameter>
     <name>what.is.the.question</name>
     <description>Ask a question</description>
@@ -29,10 +28,8 @@
     <description>If you do not know</description>
     <required>true</required>
   </parameter>
-
   <resource>
     <name>favorite</name>
-    <service-class>org.apache.ambari.view.examples.FavoriteService</service-class>
+    <service-class>org.apache.ambari.view.favorite.FavoriteService</service-class>
   </resource>
-
 </view>


Mime
View raw message