private DirectoryService initDirectoryService(
      InstanceLayout instanceLayout,
      DirectoryServiceBean directoryServiceBean,
      CacheService cacheService)
      throws Exception {
    LOG.info("Initializing the DirectoryService...");

    long startTime = System.currentTimeMillis();

    DirectoryService directoryService =
        ServiceBuilder.createDirectoryService(directoryServiceBean, instanceLayout, schemaManager);

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    directoryService.setSchemaPartition(schemaPartition);

    directoryService.addPartition(configPartition);

    // Store the default directories
    directoryService.setInstanceLayout(instanceLayout);
    directoryService.setCacheService(cacheService);
    directoryService.startup();

    if (isConfigPartitionFirstExtraction) {
      LOG.info(
          "begining to update config partition LDIF files after modifying manadatory attributes");

      // disable writes to the disk upon every modification to improve performance
      configPartition.setEnableRewriting(false);

      // perform updates
      updateMandatoryOpAttributes(configPartition, directoryService);

      // enable writes to disk, this will save the partition data first if found dirty
      configPartition.setEnableRewriting(true);

      LOG.info("config partition data was successfully updated");
    }

    if (isSchemaPartitionFirstExtraction) {
      LOG.info(
          "begining to update schema partition LDIF files after modifying manadatory attributes");

      updateMandatoryOpAttributes(schemaLdifPartition, directoryService);

      LOG.info("schema partition data was successfully updated");
    }

    LOG.info(
        "DirectoryService initialized in {} milliseconds",
        (System.currentTimeMillis() - startTime));

    return directoryService;
  }
  /**
   * initializes a LDIF partition for configuration
   *
   * @param instanceLayout the instance layout
   * @throws Exception in case of any issues while extracting the schema
   */
  private void initConfigPartition(InstanceLayout instanceLayout) throws Exception {
    File confFile =
        new File(instanceLayout.getConfDirectory(), LdifConfigExtractor.LDIF_CONFIG_FILE);

    if (confFile.exists()) {
      LOG.info("config partition already exists, skipping default config extraction");
    } else {
      LdifConfigExtractor.extractSingleFileConfig(
          instanceLayout.getConfDirectory(), LdifConfigExtractor.LDIF_CONFIG_FILE, true);
      isConfigPartitionFirstExtraction = true;
    }

    configPartition = new SingleFileLdifPartition(schemaManager);
    configPartition.setId("config");
    configPartition.setPartitionPath(confFile.toURI());
    configPartition.setSuffixDn(new Dn(schemaManager, "ou=config"));
    configPartition.setSchemaManager(schemaManager);

    configPartition.initialize();
  }