Atlas camp

506 views

Published on

Published in: Art & Photos, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
506
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Atlas camp

  1. 1. Reloadable Plugins Why Do I Care? How does Reloadability Work? How do I make sure my plugin is reloadable? How do I test this? Common Patterns
  2. 2. Why do I care? <ul><li>UPM means plugins can be uploaded </li><ul><li>If yours needs a JIRA restart it's at a disadvantage </li></ul></ul>
  3. 3. How does Reloadability work? <ul><li>OSGi magic - </li><ul><li>Classes loaded by delegated bundle classloader
  4. 4. When you reload a plugin the classloader is redelegated
  5. 5. However classloader can only be GC'd if there are no GC roots holding it </li></ul></ul>
  6. 6. So how do you hold onto the classloader root <ul><li>You started a thread that holds onto a class in your classloader
  7. 7. You have a strong reference you are not releasing, probably in a cache
  8. 8. You are abusing ThreadLocals
  9. 9. You have done some fancy footwork to get a static in another classloader </li></ul>
  10. 10. Holding onto resources <ul><li>Intention here to use HttpClient to keep a cache
  11. 11. Solution is to close resources in a Plugin Disabled event
  12. 12. General form of these slides – demo the problem, then show the solution </li></ul>
  13. 13. Keeping Strong References <ul><li>Show a cache using a map
  14. 14. Solution is to use Supplier, or a map of WeakReferences etc. </li></ul>
  15. 15. ThreadLocal abuse <ul><li>You can't really rely on ThreadLocals being GC'd properly </li><ul><li>Often returned to thread pool, so can hang onto references </li></ul></ul>
  16. 16. Statics <ul><li>Avoid them, if you can
  17. 17. Make sure they are in private packages
  18. 18. Avoid the temptation of using statics in other plugins – you are tiesd to their lifecycle now </li></ul>
  19. 19. How to test <ul><li>You nee dto see if the classloader is being GC'd on a reload </li><ul><li>Use a profiler
  20. 20. Instrument your code
  21. 21. Take heap dumps and use MAT (or JHAT or any heap analyzer) </li></ul><li>Will use YourKit here to show how </li></ul>
  22. 22. Common Pattern <ul><li>I avoid InitializingBean </li><ul><li>Be careful with constructor not to leak this
  23. 23. So use of inner clases to avoid leaking this </li></ul><li>Implement DisposableBean
  24. 24. Register as a listener for PluginEvents
  25. 25. This will all be code based </li></ul>

×