You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Tom Beerbower <tb...@hortonworks.com> on 2014/11/21 18:26:26 UTC

Review Request 28336: Provide stage resource information via REST API

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/StageResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.

> On Nov. 21, 2014, 7:21 p.m., Robert Levas wrote:
> >

Thanks for the review.


> On Nov. 21, 2014, 7:21 p.m., Robert Levas wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java, line 70
> > <https://reviews.apache.org/r/28336/diff/1/?file=772232#file772232line70>
> >
> >     This seems to be confusing since the caller sees X number of `Resources.Type` arguments that do not indicate any hierarchy, yet the implementation takes the first as the main type and the rest as the sub types. 
> >     
> >     This type of syntax seems to make better sense when all of the arguements are used the same way.  
> >     
> >     I would rather see something like `public BaseResourceDefinition(Resource.Type resourceType, Collection<Resource.Type> subTypes)` making the invocation of this constructor look like:
> >     
> >     `super(Resource.Type.Request, Arrays.asList(Resource.Type.State, Resource.Type.Task))`
> >     
> >     Which looks clearer (to me) than:
> >     
> >     `super(Resource.Type.Request, Resource.Type.State, Resource.Type.Task)`
> >     
> >     If there are no other issues and no on else cares about this, then don't let this hold up progress.

Same comment to Nate ...

Yeah, I think looking at the ctor it makes sense but looking at the call you just see a single list of types.  I got rid of StageResourceDefinition and turned it into a generic class (SimpleResourceDefinition) that also takes the singular and plural names into the ctor.  Now the call looks cleaner, I think, because the type and subtypes are broken up in the argument list.


> On Nov. 21, 2014, 7:21 p.m., Robert Levas wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java, line 908
> > <https://reviews.apache.org/r/28336/diff/1/?file=772241#file772241line908>
> >
> >     Is there any particular reason this is an _inner_ class.  Technically is it not really an inner class.  That said, I am typically a fan of the `private static (inner) class`; however this is a `protected static (inner) class` in an _implementation_ class (not a class one would expect to be used as a base class).  
> >     
> >     Might it be better to move this out to its own class?  Maybe it will be useful elsewhere?

Yeah, I don't see this ever being used outside ClusterControllerImpl.  I changed it to private.


> On Nov. 21, 2014, 7:21 p.m., Robert Levas wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java, line 294
> > <https://reviews.apache.org/r/28336/diff/1/?file=772245#file772245line294>
> >
> >     The comment here is confusing since we are counting non-`COMPLETED` statuses twice. We just don't want to doubly count the `COMPLETED` statuses twice.  
> >     
> >     It took a little digging to figure out that this is not a bug due to how the counts are used elsewhere in this class.

Good point.  I updated the comment.


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62584
-----------------------------------------------------------


On Nov. 22, 2014, 2:18 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 2:18 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Robert Levas <rl...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62584
-----------------------------------------------------------



ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java
<https://reviews.apache.org/r/28336/#comment104663>

    This seems to be confusing since the caller sees X number of `Resources.Type` arguments that do not indicate any hierarchy, yet the implementation takes the first as the main type and the rest as the sub types. 
    
    This type of syntax seems to make better sense when all of the arguements are used the same way.  
    
    I would rather see something like `public BaseResourceDefinition(Resource.Type resourceType, Collection<Resource.Type> subTypes)` making the invocation of this constructor look like:
    
    `super(Resource.Type.Request, Arrays.asList(Resource.Type.State, Resource.Type.Task))`
    
    Which looks clearer (to me) than:
    
    `super(Resource.Type.Request, Resource.Type.State, Resource.Type.Task)`
    
    If there are no other issues and no on else cares about this, then don't let this hold up progress.



ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
<https://reviews.apache.org/r/28336/#comment104670>

    Is there any particular reason this is an _inner_ class.  Technically is it not really an inner class.  That said, I am typically a fan of the `private static (inner) class`; however this is a `protected static (inner) class` in an _implementation_ class (not a class one would expect to be used as a base class).  
    
    Might it be better to move this out to its own class?  Maybe it will be useful elsewhere?



ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
<https://reviews.apache.org/r/28336/#comment104671>

    The comment here is confusing since we are counting non-`COMPLETED` statuses twice. We just don't want to doubly count the `COMPLETED` statuses twice.  
    
    It took a little digging to figure out that this is not a bug due to how the counts are used elsewhere in this class.


- Robert Levas


On Nov. 21, 2014, 12:26 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 21, 2014, 12:26 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/StageResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Robert Levas <rl...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62740
-----------------------------------------------------------

Ship it!


Ship It!

- Robert Levas


On Nov. 22, 2014, 9:18 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 9:18 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Jonathan Hurley <jh...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62801
-----------------------------------------------------------

Ship it!


Ship It!

- Jonathan Hurley


On Nov. 24, 2014, 11:21 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 24, 2014, 11:21 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/orm/dao/StageDAOTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 24, 2014, 4:21 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Changes
-------

Added StageDAOTest


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/orm/dao/StageDAOTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.

Results :

Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26:48 min
[INFO] Finished at: 2014-11-22T08:06:15-05:00
[INFO] Final Memory: 41M/485M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 24, 2014, 2:27 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.

Results :

Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26:48 min
[INFO] Finished at: 2014-11-22T08:06:15-05:00
[INFO] Final Memory: 41M/485M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.

> On Nov. 24, 2014, 1:31 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java, line 186
> > <https://reviews.apache.org/r/28336/diff/4/?file=773593#file773593line186>
> >
> >     How does this request inform the caller that pagination and sorting was used? It constructs the historyRequest, but I can't see where the response indicates that the resources are paged or sorted.

The cluster controller now calls queryForResources instead of getResources if the resource provider implements it.

So, if a resource provider is going to do its own sorting and/or paging it should implement ExtendedResourceProvider.


> On Nov. 24, 2014, 1:31 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java, line 178
> > <https://reviews.apache.org/r/28336/diff/4/?file=773594#file773594line178>
> >
> >     Same question as with the AlertHistoryResourceProvider.getResources(). It looks like only a call to queryForResources(...) would set the page/sorting info. Maybe I just missed it.

Same as AlertHistoryResourceProvider.


> On Nov. 24, 2014, 1:31 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java, lines 35-46
> > <https://reviews.apache.org/r/28336/diff/4/?file=773607#file773607line35>
> >
> >     Copy/paste error?

Yikes! Good catch.  Obviously I used AlertHistoryEntity_ as the template.  I'm a little surprised that the JPA mapping works with it like that, but it looks like the type information isn't actually being used.  The mapping works fine when I run the code.  Should getPredicateMapping include the entity type info?  ...

      public static Map<String, List<? extends SingularAttribute<StageEntity, ?>>> getPredicateMapping() {
        Map<String, List<? extends SingularAttribute<StageEntity, ?>>> mapping = new HashMap<String, List<? extends SingularAttribute<StageEntity, ?>>>();

The same would apply to AlertHistoryEntity_.


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62762
-----------------------------------------------------------


On Nov. 22, 2014, 2:18 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 2:18 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.

> On Nov. 24, 2014, 1:31 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java, lines 35-46
> > <https://reviews.apache.org/r/28336/diff/4/?file=773607#file773607line35>
> >
> >     Copy/paste error?
> 
> Tom Beerbower wrote:
>     Yikes! Good catch.  Obviously I used AlertHistoryEntity_ as the template.  I'm a little surprised that the JPA mapping works with it like that, but it looks like the type information isn't actually being used.  The mapping works fine when I run the code.  Should getPredicateMapping include the entity type info?  ...
>     
>           public static Map<String, List<? extends SingularAttribute<StageEntity, ?>>> getPredicateMapping() {
>             Map<String, List<? extends SingularAttribute<StageEntity, ?>>> mapping = new HashMap<String, List<? extends SingularAttribute<StageEntity, ?>>>();
>     
>     The same would apply to AlertHistoryEntity_.
> 
> Jonathan Hurley wrote:
>     I would have expected a failure as well; odd that it doesn't. Yes, I'd say the type information would be good to have to catch other copy/paste errors. Actually, are you sure that the JPA code is being invoked correctly for the StageResourceProvider? I found that when I was writing the alert JPA stuff, there was post-processing happening by the cluster controller which would sort and paginate my results again (hence the methods that tell the controller not to do that). But associated with this was a bug that I had where my DAO was not properly using the sort/page info given to it by the resource provider, but it was being hidden by the double-processing.
>     
>     I wrote a few methods in AlertsDAOTest which specifically exercise the JPA code directly (```testAlertHistoryPredicate()``` and ```testAlertHistoryPagination()``` and ```testAlertHistorySorting()```). This way I knew I was getting a paged/sorted result set from JPA correctly before it even hit my resource provider. Should StageDAO have some of these tests too?

Yeah, I'm sure its working.  I can manually test and the stage resources get populated properly.  I will look at your tests and try to do the same for StageDAO.  Thanks.


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62762
-----------------------------------------------------------


On Nov. 24, 2014, 2:27 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 24, 2014, 2:27 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.

> On Nov. 24, 2014, 1:31 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java, lines 35-46
> > <https://reviews.apache.org/r/28336/diff/4/?file=773607#file773607line35>
> >
> >     Copy/paste error?
> 
> Tom Beerbower wrote:
>     Yikes! Good catch.  Obviously I used AlertHistoryEntity_ as the template.  I'm a little surprised that the JPA mapping works with it like that, but it looks like the type information isn't actually being used.  The mapping works fine when I run the code.  Should getPredicateMapping include the entity type info?  ...
>     
>           public static Map<String, List<? extends SingularAttribute<StageEntity, ?>>> getPredicateMapping() {
>             Map<String, List<? extends SingularAttribute<StageEntity, ?>>> mapping = new HashMap<String, List<? extends SingularAttribute<StageEntity, ?>>>();
>     
>     The same would apply to AlertHistoryEntity_.
> 
> Jonathan Hurley wrote:
>     I would have expected a failure as well; odd that it doesn't. Yes, I'd say the type information would be good to have to catch other copy/paste errors. Actually, are you sure that the JPA code is being invoked correctly for the StageResourceProvider? I found that when I was writing the alert JPA stuff, there was post-processing happening by the cluster controller which would sort and paginate my results again (hence the methods that tell the controller not to do that). But associated with this was a bug that I had where my DAO was not properly using the sort/page info given to it by the resource provider, but it was being hidden by the double-processing.
>     
>     I wrote a few methods in AlertsDAOTest which specifically exercise the JPA code directly (```testAlertHistoryPredicate()``` and ```testAlertHistoryPagination()``` and ```testAlertHistorySorting()```). This way I knew I was getting a paged/sorted result set from JPA correctly before it even hit my resource provider. Should StageDAO have some of these tests too?
> 
> Tom Beerbower wrote:
>     Yeah, I'm sure its working.  I can manually test and the stage resources get populated properly.  I will look at your tests and try to do the same for StageDAO.  Thanks.

Added StageDAOTest


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62762
-----------------------------------------------------------


On Nov. 24, 2014, 4:21 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 24, 2014, 4:21 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/orm/dao/StageDAOTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Jonathan Hurley <jh...@hortonworks.com>.

> On Nov. 24, 2014, 8:31 a.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java, line 186
> > <https://reviews.apache.org/r/28336/diff/4/?file=773593#file773593line186>
> >
> >     How does this request inform the caller that pagination and sorting was used? It constructs the historyRequest, but I can't see where the response indicates that the resources are paged or sorted.
> 
> Tom Beerbower wrote:
>     The cluster controller now calls queryForResources instead of getResources if the resource provider implements it.
>     
>     So, if a resource provider is going to do its own sorting and/or paging it should implement ExtendedResourceProvider.

Thanks for the explanation. Nice!


> On Nov. 24, 2014, 8:31 a.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java, lines 35-46
> > <https://reviews.apache.org/r/28336/diff/4/?file=773607#file773607line35>
> >
> >     Copy/paste error?
> 
> Tom Beerbower wrote:
>     Yikes! Good catch.  Obviously I used AlertHistoryEntity_ as the template.  I'm a little surprised that the JPA mapping works with it like that, but it looks like the type information isn't actually being used.  The mapping works fine when I run the code.  Should getPredicateMapping include the entity type info?  ...
>     
>           public static Map<String, List<? extends SingularAttribute<StageEntity, ?>>> getPredicateMapping() {
>             Map<String, List<? extends SingularAttribute<StageEntity, ?>>> mapping = new HashMap<String, List<? extends SingularAttribute<StageEntity, ?>>>();
>     
>     The same would apply to AlertHistoryEntity_.

I would have expected a failure as well; odd that it doesn't. Yes, I'd say the type information would be good to have to catch other copy/paste errors. Actually, are you sure that the JPA code is being invoked correctly for the StageResourceProvider? I found that when I was writing the alert JPA stuff, there was post-processing happening by the cluster controller which would sort and paginate my results again (hence the methods that tell the controller not to do that). But associated with this was a bug that I had where my DAO was not properly using the sort/page info given to it by the resource provider, but it was being hidden by the double-processing.

I wrote a few methods in AlertsDAOTest which specifically exercise the JPA code directly (```testAlertHistoryPredicate()``` and ```testAlertHistoryPagination()``` and ```testAlertHistorySorting()```). This way I knew I was getting a paged/sorted result set from JPA correctly before it even hit my resource provider. Should StageDAO have some of these tests too?


- Jonathan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62762
-----------------------------------------------------------


On Nov. 24, 2014, 9:27 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 24, 2014, 9:27 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Jonathan Hurley <jh...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62762
-----------------------------------------------------------



ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java
<https://reviews.apache.org/r/28336/#comment104848>

    How does this request inform the caller that pagination and sorting was used? It constructs the historyRequest, but I can't see where the response indicates that the resources are paged or sorted.



ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java
<https://reviews.apache.org/r/28336/#comment104849>

    Same question as with the AlertHistoryResourceProvider.getResources(). It looks like only a call to queryForResources(...) would set the page/sorting info. Maybe I just missed it.



ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java
<https://reviews.apache.org/r/28336/#comment104847>

    Copy/paste error?


- Jonathan Hurley


On Nov. 22, 2014, 9:18 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 9:18 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Nate Cole <nc...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62736
-----------------------------------------------------------

Ship it!


Ship It!

- Nate Cole


On Nov. 22, 2014, 9:18 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 9:18 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 22, 2014, 2:18 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.

Results :

Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26:48 min
[INFO] Finished at: 2014-11-22T08:06:15-05:00
[INFO] Final Memory: 41M/485M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 22, 2014, 1:59 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing (updated)
-------

New unit tests added.

Results :

Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26:48 min
[INFO] Finished at: 2014-11-22T08:06:15-05:00
[INFO] Final Memory: 41M/485M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 22, 2014, 1:58 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Nate Cole <nc...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62730
-----------------------------------------------------------

Ship it!


Ship It!

- Nate Cole


On Nov. 22, 2014, 8:48 a.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 8:48 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/
-----------------------------------------------------------

(Updated Nov. 22, 2014, 1:48 p.m.)


Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.


Bugs: AMBARI-8163
    https://issues.apache.org/jira/browse/AMBARI-8163


Repository: ambari


Description
-------

Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 

*NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.

If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   

To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  

The following properties should be returned for each {{stage}}:

* stage_id
* request_id
* cluster_id
* request_context 
** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
* start_time
* end_time
* progress_percent
* status

It is expected that the resources would be queried using:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
{code}

Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:

{code}
GET  /api/v1/clusters/{clusterid}/requests/{requestid}
{code}

See {{request}} and {{task}} resource for examples.


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
  ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
  ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
  ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 

Diff: https://reviews.apache.org/r/28336/diff/


Testing
-------

New unit tests added.


Thanks,

Tom Beerbower


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Tom Beerbower <tb...@hortonworks.com>.

> On Nov. 21, 2014, 10:40 p.m., Nate Cole wrote:
> >

Thanks for the review.


> On Nov. 21, 2014, 10:40 p.m., Nate Cole wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/api/resources/StageResourceDefinition.java, lines 41-43
> > <https://reviews.apache.org/r/28336/diff/1/?file=772235#file772235line41>
> >
> >     Should be "stage"?

Doh!  Thanks for catching that.  I don't even know if the singular name is actually used.


> On Nov. 21, 2014, 10:40 p.m., Nate Cole wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java, line 70
> > <https://reviews.apache.org/r/28336/diff/1/?file=772232#file772232line70>
> >
> >     I didn't even think this was a valid construct.  It's weird! :)  I don't have any issues with it, but you'd have to look at the ctor to know what to correctly provide.

Yeah, I think looking at the ctor it makes sense but looking at the call you just see a single list of types.  I got rid of StageResourceDefinition and turned it into a generic class (SimpleResourceDefinition) that also takes the singular and plural names into the ctor.  Now the call looks cleaner, I think, because the type and subtypes are broken up in the argument list.


- Tom


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62668
-----------------------------------------------------------


On Nov. 22, 2014, 1:59 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 22, 2014, 1:59 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/SimpleResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/api/resources/SimpleResourceDefinitionTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> Results :
> 
> Tests run: 2288, Failures: 0, Errors: 0, Skipped: 14
> 
> 
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 26:48 min
> [INFO] Finished at: 2014-11-22T08:06:15-05:00
> [INFO] Final Memory: 41M/485M
> [INFO] ------------------------------------------------------------------------
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>


Re: Review Request 28336: Provide stage resource information via REST API

Posted by Nate Cole <nc...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28336/#review62668
-----------------------------------------------------------



ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java
<https://reviews.apache.org/r/28336/#comment104735>

    I didn't even think this was a valid construct.  It's weird! :)  I don't have any issues with it, but you'd have to look at the ctor to know what to correctly provide.



ambari-server/src/main/java/org/apache/ambari/server/api/resources/StageResourceDefinition.java
<https://reviews.apache.org/r/28336/#comment104736>

    Should be "stage"?


- Nate Cole


On Nov. 21, 2014, 12:26 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28336/
> -----------------------------------------------------------
> 
> (Updated Nov. 21, 2014, 12:26 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, John Speidel, Nate Cole, and Robert Levas.
> 
> 
> Bugs: AMBARI-8163
>     https://issues.apache.org/jira/browse/AMBARI-8163
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Currently, it is possible to query Ambari (via the REST API) for details about _asynchronous_ requests and their related tasks. This useful when trying to obtain progress information.  However, some information necessary for the UI to indicate meaningful progress is not available.  This information is related to the stages that are generated. 
> 
> *NOTE:* Each _asynchronous_ request is broken down into 1 or more stages and each stage contains 1 or more tasks.
> 
> If stage information was available via the REST API, it would be possible for the caller (maybe a UI) to track high-level tasks (at the {{stage}} level) rather than each lower-level unit of work (at the {{task}} level).   
> 
> To allow for this, a new API resource (and associated handler) needs to be created.  The resource should be read-only (like {{requests}} and {{tasks}}), and should provide information stored in the {{stage}} table from the Ambari database.  
> 
> The following properties should be returned for each {{stage}}:
> 
> * stage_id
> * request_id
> * cluster_id
> * request_context 
> ** _This should probably be renamed to something more appropriate, like stage_context, stage_name, or etc..._
> * start_time
> * end_time
> * progress_percent
> * status
> 
> It is expected that the resources would be queried using:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}/stages
> {code}
> 
> Also, some subset of the stage data should be provided when querying for details about a specific {{request}}, like in:
> 
> {code}
> GET  /api/v1/clusters/{clusterid}/requests/{requestid}
> {code}
> 
> See {{request}} and {{task}} resource for examples.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java a1c4882 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java a5a7234 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/RequestResourceDefinition.java 291b01a 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ba3f32f 
>   ambari-server/src/main/java/org/apache/ambari/server/api/resources/StageResourceDefinition.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java fc1b515 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/StageService.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java ade8d9c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertHistoryResourceProvider.java 409aace 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertNoticeResourceProvider.java 956f710 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java ec40c4f 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java d0ce1cf 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/QueryResponseImpl.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestImpl.java 9b98737 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java 35ea680 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ExtendedResourceProvider.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/QueryResponse.java PRE-CREATION 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java 92c5db5 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b71b43c 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java 3e2111e 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java 900dbeb 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity_.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java cfb2efb 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/QueryResponseImplTest.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/28336/diff/
> 
> 
> Testing
> -------
> 
> New unit tests added.
> 
> 
> Thanks,
> 
> Tom Beerbower
> 
>