protected void populateStackDB(Mpack mpack) throws IOException, ResourceAlreadyExistsException {
    String stackName = mpack.getName();
    String stackVersion = mpack.getVersion();
    StackEntity stackEntity = stackDAO.find(stackName, stackVersion);
    if (stackEntity == null) {
      LOG.info("Adding stack {}-{} to the database", stackName, stackVersion);
      stackEntity = new StackEntity();
      stackEntity.setStackName(stackName);
      stackEntity.setStackVersion(stackVersion);
      stackEntity.setMpackId(mpack.getResourceId());
      stackDAO.create(stackEntity);
    } else {
      String message = "Stack " + stackName + "-" + stackVersion + " already exists";
      LOG.error(message);
      throw new ResourceAlreadyExistsException(message);
    }
  }
Makes an entry or updates the entry in the stack table to establish a link between the mpack and the
associated stack

@param mpack
@throws IOException
ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java