@Override
  public void removeDeploymentGroup(final String name) throws DeploymentGroupDoesNotExistException {
    log.info("removing deployment-group: name={}", name);
    final ZooKeeperClient client = provider.get("removeDeploymentGroup");
    try {
      client.ensurePath(Paths.configDeploymentGroups());
      client.ensurePath(Paths.statusDeploymentGroups());
      client.ensurePath(Paths.statusDeploymentGroupTasks());

      final List<ZooKeeperOperation> operations = Lists.newArrayList();

      final List<String> paths = ImmutableList.of(
          Paths.configDeploymentGroup(name),
          Paths.statusDeploymentGroup(name),
          Paths.statusDeploymentGroupHosts(name),
          Paths.statusDeploymentGroupRemovedHosts(name),
          Paths.statusDeploymentGroupTasks(name)
      );

      // For each deployment group path:
      //
      // * If it exists: delete it.
      // * If it doesn't exist, add and delete it in the same transaction. This is a round-about
      //   way of ensuring that it wasn't created when we commit the transaction.
      //
      // This is particularly important for /status/deployment-group-tasks/[group-name], which
      // might exist if a rolling-update is in progress. To avoid inconsistent state we make sure
      // it's deleted if it does exist.
      //
      // Having /status/deployment-group-tasks/[group-name] for removed groups around will cause
      // DGs to become slower and spam logs with errors so we want to avoid it.
      for (final String path : paths) {
        if (client.exists(path) == null) {
          operations.add(create(path));
        }
      }
      for (final String path : Lists.reverse(paths)) {
        operations.add(delete(path));
      }

      client.transaction(operations);
    } catch (final NoNodeException e) {
      throw new DeploymentGroupDoesNotExistException(name);
    } catch (final KeeperException e) {
      throw new HeliosRuntimeException("removing deployment-group " + name + " failed", e);
    }
  }
@ Override public void removeDeploymentGroup ( final String name ) throws DeploymentGroupDoesNotExistException { log . info ( "removing deployment-group: name={}" , name ) ; final ZooKeeperClient client = provider . get ( "removeDeploymentGroup" ) ; try { client . ensurePath ( Paths . configDeploymentGroups ( ) ) ; client . ensurePath ( Paths . statusDeploymentGroups ( ) ) ; client . ensurePath ( Paths . statusDeploymentGroupTasks ( ) ) ; final List < ZooKeeperOperation > operations = Lists . newArrayList ( ) ; final List < String > paths = ImmutableList . of ( Paths . configDeploymentGroup ( name ) , Paths . statusDeploymentGroup ( name ) , Paths . statusDeploymentGroupHosts ( name ) , Paths . statusDeploymentGroupRemovedHosts ( name ) , Paths . statusDeploymentGroupTasks ( name ) ) ; for ( final String path : paths ) { if ( client . exists ( path ) == null ) { operations . add ( create ( path ) ) ; } } for ( final String path : Lists . reverse ( paths ) ) { operations . add ( delete ( path ) ) ; } client . transaction ( operations ) ; } catch ( final NoNodeException e ) { throw new DeploymentGroupDoesNotExistException ( name ) ; } catch ( final KeeperException e ) { throw new HeliosRuntimeException ( "removing deployment-group " + name + " failed" , e ) ; } }
Remove a deployment group.

<p>If successful, all ZK nodes associated with the DG will be deleted. Specifically these
nodes are guaranteed to be non-existent after a successful remove (not all of them might exist
before, though):
<ul>
<li>/config/deployment-groups/[group-name]</li>
<li>/status/deployment-groups/[group-name]</li>
<li>/status/deployment-groups/[group-name]/hosts</li>
<li>/status/deployment-groups/[group-name]/removed</li>
<li>/status/deployment-group-tasks/[group-name]</li>
</ul>
If the operation fails no ZK nodes will be removed.

@throws DeploymentGroupDoesNotExistException If the DG does not exist.