Adjust the exception hierachy

Group the exceptions into the following groups
  * Storage
  * Jobs
  * Execution
  * Other (wrapped failure here)

This grouping makes it easier to understand where
one type of exception should be used vs using another
type of exception.

Backwards incompatible changes:
  * StorageError -> StorageFailure
  * AlreadyExists -> Duplicate
  * WrappedFailure now inherits from Exception
    and not directly from TaskFlowException since it
    wraps arbitrary other exceptions and is not
    specific to taskflow.

Cleanups:
  * JobNotFound -> NotFound
  * EmptyFlow -> Empty
  * JobAlreadyExists -> AlreadyExists
  * InvariantViolation (X)
  * ConnectionFailure (X)

Change-Id: I0e1e81b513fbbc7adb8bfaa1244993e345ab70d3
Optimize dependency links in flattening

With this change a link between two subflows caused by task dependency
does not impose execution ordering between all tasks of that subflows
any more: only provider and consumer of the dependency are now linked.
For some cases this is a major optimization, as it allows more
independent parts of the flow to be executed or reverted in parallel. It
also allows, for example, converting parts of flow into subflows without
loosing performance.

Because with this change parts of parent flow that depend on some tasks
in subflow can be executed before all tasks in the subflow are
completed, graph analyzer is changed to not stop at subflow border when
iterating subgraphs.

Change-Id: I45587a4e851febe3c43cfa7b74bdfc50f61e0279
Use same code to reset flow and parts of it

Instead of having special engine and storage method to reset
reverted flow when running it again, delegate the job to
graph action, which already does almost same thing when retrying
subgraphs.

Change-Id: Icf257cfc0fb161ab2199baa3d7c7e64664a109e7
Add timeout to WaitForOneFromTask

We should never wait forever for anything.

Change-Id: Icaa61febbf4745206abbe5bf9255c9401f341e71
SQLAlchemy requirements put in order

- require SQLAlchemy>=0.7.8 if no stricter requirement present;
- allow SQLAlhchemy 0.9.x in python 3.3 and pypy test environments.

Change-Id: I8ee29c66612e8051a26a1633c0973d0dfa048fc4
Run worker-based engine tests faster

This change reduces polling intervals for transport and proxy
from default 1 second to 0.01 second. On my machine this reduces
time needed to run WorkerBasedEngineTest almost 5 times, which,
in turn, makes testr almost twice faster.

Change-Id: I8dfe08c06234f33e838059b2f8d9d6a7c7819e06
Merge "Adjust the exception hierachy"
Merge "Run worker-based engine tests faster"
Merge "Optimize dependency links in flattening"
Merge "Use same code to reset flow and parts of it"
Merge "SQLAlchemy requirements put in order"
Persistence cleanup part one

- Convert the various functions that take a task detail into
  ones that take atom details (since this is now the generic
  type they should take).
- Don't expose the detail type strings as part of the atom
  detail api, leave those as private hidden strings and provide
  conversion functions from string<->class instead.
- Have the logbook objects contain the following new methods
  to reduce the dependence on persistence_utils to do the same.
  - to_dict() which converts the current object into a dict
  - from_dict() which converts the provided dict into a object
  - merge() which merges a incoming objects data with the current
    objects
- Have the persistence backends + storage + action engine use these
  new methods instead of there current usage.
- Don't compare to logbook.RETRY_DETAIL or logbook.TASK_DETAIL since
  python has the isinstance function just use it (ideally we should
  fix the code so that this isn't even needed, usage of isinstance
  means something is not designed/structured right).
- In storage tests we can't assume that failures will be non-lossy
  since under certain backends when a failure is stored information
  about the internally held exc_info is lost, so take this into
  account when testing by using matches() where applicable.

Change-Id: Ie8a274cfd4cb4e64e87c355dc99d466d74a4e82c
Merge "Add timeout to WaitForOneFromTask"
Should be greater or equal to zero and not greater than

Change-Id: I7897f847598133cbc1ed425847f2a708e4f6d195
Fix spelling mistake

Change-Id: Ic3ae069565f0f9e25f243eead105e1b97fe437fc
Merge "Fix spelling mistake"
tests: Discover absence of zookeeper faster

It turns out that when no zookeeper server is available for tests
python ./setup.py test spends almost half of it's running time
looking for it. This change addresses that and makes unit tests
run roughly two times faster on my zookeeperless machine:

- client starting timeout reduced from default 15 seconds to 3 seconds,
  which should be more than enough to connect to localhost;
- zookeeper availability is checked only once, on module import,
  and then saved for later re-use.

Change-Id: I11932e7cca12436cde0bcf0a20cb2adb96fbb27a
Move 'inputs and outputs' to developers docs

Change-Id: Id4385c234f78ef179c43b23d5eb93cf448059498
Merge "Move 'inputs and outputs' to developers docs"
Set logbook/flowdetail/atomdetail meta to empty dict

Instead of setting to none, and then later setting to
a dictionary just by default set it to an empty dict
which makes it more clear what the intended usage of
the meta attribute is for.

Change-Id: Ic42c423d104f369a43227c4ef4563f1f99635fa0