[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-8266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14332069#comment-14332069
 ] 

Marcus Sorensen commented on CLOUDSTACK-8266:
---------------------------------------------

Unfortunately, I wrote it for a third party as a plugin, and they maintain the 
rights to the code. However, looking at just publicly available code, you can 
basically reimplement/copy the StatsCollector class, e.g.:

@Component
public class WorkloadManager extends ManagerBase implements 
ComponentMethodInterceptable {

And implement the start method required by ComponentMethodInterceptable. They 
in turn call an init method, but you can just implement that code in start if 
you want. Look at the init method to see how to schedule the running of a class 
on interval via the 'ScheduledExecutorService _executor':

_executor.scheduleWithFixedDelay(new WorkloadMonitor(), 15000L, 
autoScaleStatsInterval, TimeUnit.MILLISECONDS);

And also how to fetch config parametrs that will be used as tunables for the 
algorithm:

workloadActionCpuThreshold = 
NumbersUtil.parseInt(configs.get("workload.action.cpu.threshold"), 90);

You may want to look up the zones (via DataCenterDao?) and schedule one thread 
per zone or something like that. The scheduled class should do something like 
look up all enabled clusters, then go through each cluster and look at the 
enabled hosts. You can fetch the stats for each host via 
StatsCollector.getInstance().getHostStats(hostid).

Of course, you could also just add a few lines to init within StatsCollector 
itself to schedule your class, as was done with the AutoScaleMonitor, but I'm 
not sure there's any reason why these services all need to be stuffed into 
StatsCollector itself. It's relatively easy to set up a standalone service and 
still fetch what data you need from StatsCollector.

That's sort of the general way to get a service functioning, but the algorithm 
would need to be ironed out a bit more when workign on the functional spec.

> Automatic workload Management in the clusters Managed by CloudStack for 
> efficient host Management.
> --------------------------------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-8266
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8266
>             Project: CloudStack
>          Issue Type: New Feature
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Hypervisor Controller, Management Server
>    Affects Versions: 4.5.0
>         Environment: Java, Linux, Hypervisor
>            Reporter: Rajesh Battala
>              Labels: gsoc2015
>             Fix For: 4.5.0
>
>
> CloudStack manages hypervisor hosts as clusters. It will deploy the vm's to 
> ensure proper hosts capacity are used max. 
> Due to some operations by user on vm's like stop/migrate/destroy hosts usage 
> in the clusters will be in inefficient state. 
> To solve this issue we can have a new Manager who will regularly checks host 
> capacity and implement Server Consolidtion by taking the actions: 
> 1. Live migrate the vm's if possible along with storage. Migrate them such 
> that hosts are fully utilized. 
> 2. After redistributing the vm's Shutdown the hosts which are empty. 
> 3. When load is getting increased,power-on the hosts remotely by WOL(Wake On 
> Lan) mechanisam.
> This idea is discussed and presented in Collab Conference 2014.
> Here is the youtube link
> https://www.youtube.com/watch?v=hJKdZcSpGNQ



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to