add callbacks before and after cluster operations. Refactoring

some common logic into TaskService to make sure the before and
after hooks are isolated to a single class.