/**
   * Close all interpreter instances in this group for the session
   *
   * @param sessionId
   */
  public void close(String sessionId) {
    LOGGER.info("Close interpreter group " + getId() + " for session: " + sessionId);
    List<Interpreter> intpForSession = this.get(sessionId);
    close(intpForSession);

    if (remoteInterpreterProcess != null) {
      remoteInterpreterProcess.dereference();
      if (remoteInterpreterProcess.referenceCount() <= 0) {
        remoteInterpreterProcess = null;
        allInterpreterGroups.remove(id);
      }
    }
  }
  /** Close all interpreter instances in this group */
  public void close() {
    LOGGER.info("Close interpreter group " + getId());
    List<Interpreter> intpToClose = new LinkedList<>();
    for (List<Interpreter> intpGroupForSession : this.values()) {
      intpToClose.addAll(intpGroupForSession);
    }
    close(intpToClose);

    // make sure remote interpreter process terminates
    if (remoteInterpreterProcess != null) {
      while (remoteInterpreterProcess.referenceCount() > 0) {
        remoteInterpreterProcess.dereference();
      }
      remoteInterpreterProcess = null;
    }
    allInterpreterGroups.remove(id);
  }