public void stop(String workspaceId) throws EnvironmentNotRunningException, ServerException {
  List<Instance> machinesCopy=null;
  EnvironmentHolder environmentHolder;
  try (StripedLocks.WriteLock lock=stripedLocks.acquireWriteLock(workspaceId)){
    environmentHolder=environments.get(workspaceId);
    if (environmentHolder == null || environmentHolder.status != EnvStatus.RUNNING) {
      throw new EnvironmentNotRunningException(format("Stop of not running environment of workspace with ID '%s' is not allowed.",workspaceId));
    }
    environments.remove(workspaceId);
    List<Instance> machines=environmentHolder.machines;
    if (machines != null && !machines.isEmpty()) {
      machinesCopy=new ArrayList<>(machines);
    }
  }
   if (machinesCopy != null) {
    destroyEnvironment(environmentHolder.networkId,machinesCopy);
  }
}

public void stop ( String workspaceId ) throws EnvironmentNotRunningException , ServerException { List < Instance > machinesCopy = null ; EnvironmentHolder environmentHolder ; try ( StripedLocks . WriteLock lock = stripedLocks . acquireWriteLock ( workspaceId ) ) { environmentHolder = environments . get ( workspaceId ) ; if ( environmentHolder == null || environmentHolder . status != EnvStatus . RUNNING ) { throw new EnvironmentNotRunningException ( format ( "Stop of not running environment of workspace with ID '%s' is not allowed." , workspaceId ) ) ; } environments . remove ( workspaceId ) ; List < Instance > machines = environmentHolder . machines ; if ( machines != null && ! machines . isEmpty ( ) ) { machinesCopy = new ArrayList < > ( machines ) ; } } if ( machinesCopy != null ) { destroyEnvironment ( environmentHolder . networkId , machinesCopy ) ; } }
stops running environment of specified workspace .
