EricssonResearch / calvin-base

Calvin is an application environment that lets things talk to things, among other things.
Apache License 2.0
282 stars 91 forks source link

CPU and RAM deployment parameters. #85

Closed brunodonassolo closed 7 years ago

brunodonassolo commented 7 years ago

Hi @HaraldGustafsson

Here it is the first implementations to add CPU and RAM parameters as discussed in https://github.com/EricssonResearch/calvin-base/issues/83.

If you could give a look and say me your opinion so I can improve the missing points. It depends on some external tool to update the CPU/RAM available in the runtime during execution and only consider them at the initial deployment.

Regards,

Commit message:

Now it is possible to select the runtimes to run actors based on some CPU and RAM parameters.

CPU parameters:

RAM parameters:

Other values must be rounded up/down if necessary.

2 groups of parameters:

How to use:

In the deployjson file, node has at least 1000 MIPS of CPU power: {"requirements":{"snk":[{"op":"node_attr_match","kwargs":{"index":{"cpuTotal": "1000"}},"type":"+"}],

The update is done through control API, e.g. setting 50% of CPU available: curl -X POST -d '{"value": 50 }' http://192.168.0.1:5001/node/resource/cpuAvail curl -X POST -d '{"value": 50 }' http://192.168.0.1:5001/node/resource/memAvail

Internal details:

HaraldGustafsson commented 7 years ago

I will take a look at this tomorrow.

HaraldGustafsson commented 7 years ago

I merged your additions. I will likely rewrite some parts of the ResourceMonitorHelper, since I'm anyway in the process of changing the storage API towards the storage plugins (like DHT). I will expose the index and other more advanced operations directly since some storage plugins will have a better way to handle it. One of the methods I now see should handle updating index, seems like tedious to remove and then add again, also runs the risk of race conditions when not waiting between operations. I'm also developing a SQL-database storage plugin.