class SessionPreparer {

    public PrepareResult prepare(HostValidator<ApplicationId> hostValidator, DeployLogger logger, PrepareParams params,
                                 Optional<ApplicationSet> currentActiveApplicationSet, Path tenantPath,
                                 Instant now, File serverDbSessionDir, ApplicationPackage applicationPackage,
                                 SessionZooKeeperClient sessionZooKeeperClient) {
        Preparation preparation = new Preparation(hostValidator, logger, params, currentActiveApplicationSet,
                                                  tenantPath, serverDbSessionDir, applicationPackage, sessionZooKeeperClient);

        preparation.preprocess();
        var distributedApplicationPackage = preparation.distributeApplicationPackage();
        try {
            AllocatedHosts allocatedHosts = preparation.buildModels(now);
            preparation.makeResult(allocatedHosts);
            if ( ! params.isDryRun()) {
                preparation.writeStateZK(distributedApplicationPackage);
                preparation.writeEndpointCertificateMetadataZK();
                preparation.writeContainerEndpointsZK();
                preparation.writeApplicationRoles();
                preparation.distribute();
            }
            log.log(Level.FINE, () -> "time used " + params.getTimeoutBudget().timesUsed() +
                    " : " + params.getApplicationId());
            return preparation.result();
        }
        catch (IllegalArgumentException e) {
            throw new InvalidApplicationException("Invalid application package", e);
        }
    }

    @Inject public  SessionPreparer(ModelFactoryRegistry modelFactoryRegistry,
                           FileDistributionFactory fileDistributionFactory,
                           HostProvisionerProvider hostProvisionerProvider,
                           PermanentApplicationPackage permanentApplicationPackage,
                           ConfigserverConfig configserverConfig,
                           ConfigDefinitionRepo configDefinitionRepo,
                           Curator curator,
                           Zone zone,
                           FlagSource flagSource,
                           SecretStore secretStore);

}