cloudstack/engine/storage
Rohit Yadav 3ee8d83621 CLOUDSTACK-10136: Fix RemoteHostEndPoint thread growth
This fixes the following:
- Unchecked thread growth in RemoteEndHostEndPoint
- Potential NPE while finding EP for a storage/scope

Unbounded thread growth can be reproduced with following findings:
- Every unreachable template would produce 6 new threads (in a single
ScheduledExecutorService instance) spaced by 10 seconds
- Every reachable template url without the template would produce 1 new
thread (and one ScheduledExecutorService instance), it errors out quickly without
causing more thread growth.
- Every valid url will produce upto 10 threads as the same ep (endpoint
instance) will be reused to query upload/download (async callback)
progresses.

Every RemoteHostEndPoint instances creates its own
ScheduledExecutorService instance which is why in the jstack dump, we
see several threads that share the prefix RemoteHostEndPoint-{1..10}
(given poolsize is defined as 10, it uses suffixes 1-10).

This fixes the discovered thread leakage with following notes:
- Instead of ScheduledExecutorService instance, a cached pool could be
used instead and was implemented, and with `static` scope to be reused
among other future RemoteHostEndPoint instances.
- It was not clear why we would want to wait when we've Answers returned
from the remote EP, and therefore a scheduled/delayed Runnable was
not required at all for processing answers. ScheduledExecutorService
was therefore not really required, moved to ExecutorService instead.
- Another benefit of using a cached pool is that it will shutdown
threads if they are not used in 60 seconds, and they get re-used for
future runnable submissions.
- Caveat: the executor service is still unbounded, however, the use-case
that this method is used for short jobs to check upload/download
progresses fits the case here.
- Refactored CmdRunner to not use/reference objects from parent class.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2017-11-10 22:04:09 +05:30
..
cache Updating pom.xml version numbers for release 4.11.0.0-SNAPSHOT 2017-07-12 12:09:38 +05:30
datamotion This feature separates the snapshot creation on primary and its backing up on secondary. 2017-10-04 14:39:03 +05:30
image CLOUDSTACK-9998: Prometheus Exporter for CloudStack (#2287) 2017-10-11 17:24:22 +05:30
integration-test CE-110 remove duplicate-unused functionality 2017-08-25 08:57:51 +02:00
resources/META-INF/cloudstack CLOUDSTACK-9456: Update Spring version in maven poms 2016-12-16 21:21:20 +05:30
snapshot CLOUDSTACK-10012: Migrate to Embedded Jetty 2017-11-03 23:57:25 +05:30
src/org/apache/cloudstack/storage CLOUDSTACK-10136: Fix RemoteHostEndPoint thread growth 2017-11-10 22:04:09 +05:30
test/org/apache/cloudstack rats: licenses added 2015-07-07 13:48:20 +02:00
volume Updating pom.xml version numbers for release 4.11.0.0-SNAPSHOT 2017-07-12 12:09:38 +05:30
pom.xml Updating pom.xml version numbers for release 4.11.0.0-SNAPSHOT 2017-07-12 12:09:38 +05:30
storage.ucls Cleanup of Xen and XenServer terms. Cloned xen plugin creating a xenserver plugin, then removed xen plugin 2014-06-07 04:50:23 -04:00