Distribution switch, take 2

This is alternative implementation of https://bugs.launchpad.net/openquake/+bug/1097862.

See the description and comments in the original pull request for more information: https://github.com/gem/oq-engine/pull/1001