ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Beerbower" <tbeerbo...@hortonworks.com>
Subject Re: Review Request 27726: Views: Instance Data API doesn't work in threads
Date Fri, 07 Nov 2014 17:43:38 GMT

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

(Updated Nov. 7, 2014, 5:43 p.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, and Nate Cole.


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


Repository: ambari


Description
-------

Views instance data does not work when getting data in another thread through ViewContext.getInstanceData.
It returns empty Map (in the main thread it works ok).

This happens because the instance data is scoped to the current user.  The security context
is not propagated to the spawned thread so the current user is unknown when the call to getInstanceData
is made.

The solution is simply to configure the MODE_INHERITABLETHREADLOCAL strategy on the security
context holder.


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java 14e5dc8


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


Testing
-------

Used a modified ambari-views/examples phone list view to call context.getInstanceData() in
a spawned thread.  Verified that no data was returned.  Set MODE_INHERITABLETHREADLOCAL and
retested.  Verified that instance data was returned as expected.

All existing tests pass ...

Results :

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

...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23:12 min
[INFO] Finished at: 2014-11-07T09:13:56-05:00
[INFO] Final Memory: 41M/357M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message