/** {@inheritDoc} */
  @Override
  public void stop() {
    Collection<SharedDeployment> copy = new HashSet<SharedDeployment>();

    synchronized (mux) {
      for (List<SharedDeployment> deps : cache.values())
        for (SharedDeployment dep : deps) {
          // Mark undeployed.
          dep.undeploy();

          copy.add(dep);
        }

      cache.clear();
    }

    for (SharedDeployment dep : copy) dep.recordUndeployed(null);

    if (log.isDebugEnabled()) log.debug(stopInfo());
  }
 /**
  * Records all undeployed tasks.
  *
  * @param nodeId Left node ID.
  * @param undeployed Undeployed deployments.
  */
 private void recordUndeployed(@Nullable UUID nodeId, Collection<SharedDeployment> undeployed) {
   if (!F.isEmpty(undeployed)) for (SharedDeployment d : undeployed) d.recordUndeployed(nodeId);
 }