ApplicationRepository implements com.yahoo.config.provision.Deployer { public RemoteSession getActiveSession(ApplicationId applicationId) { Tenant tenant = getTenant(applicationId); if (tenant == null) throw new IllegalArgumentException("Could not find any tenant for '" + applicationId + "'"); return getActiveSession(tenant, applicationId); } @Inject  ApplicationRepository(TenantRepository tenantRepository,
                                 HostProvisionerProvider hostProvisionerProvider,
                                 InfraDeployerProvider infraDeployerProvider,
                                 ConfigConvergenceChecker configConvergenceChecker,
                                 HttpProxy httpProxy,
                                 ConfigserverConfig configserverConfig,
                                 Orchestrator orchestrator,
                                 TesterClient testerClient,
                                 Metric metric,
                                 FlagSource flagSource); private  ApplicationRepository(TenantRepository tenantRepository,
                                  Optional<Provisioner> hostProvisioner,
                                  Optional<InfraDeployer> infraDeployer,
                                  ConfigConvergenceChecker configConvergenceChecker,
                                  HttpProxy httpProxy,
                                  ConfigserverConfig configserverConfig,
                                  Orchestrator orchestrator,
                                  LogRetriever logRetriever,
                                  Clock clock,
                                  TesterClient testerClient,
                                  Metric metric,
                                  FlagSource flagSource); Metric metric(); @Override boolean bootstrapping(); void bootstrappingDone(); PrepareResult prepare(long sessionId, PrepareParams prepareParams); PrepareResult deploy(CompressedApplicationInputStream in, PrepareParams prepareParams); PrepareResult deploy(File applicationPackage, PrepareParams prepareParams); PrepareResult deploy(File applicationPackage, PrepareParams prepareParams, DeployHandlerLogger logger); @Override Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application); @Override Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application,
                                                                                 boolean bootstrap); @Override Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application,
                                                                                 Duration timeout,
                                                                                 boolean bootstrap); @Override Optional<Instant> lastDeployTime(ApplicationId application); ApplicationId activate(Tenant tenant,
                                  long sessionId,
                                  TimeoutBudget timeoutBudget,
                                  boolean force); Transaction deactivateCurrentActivateNew(Session active, LocalSession prepared, boolean force); boolean delete(ApplicationId applicationId); HttpResponse clusterControllerStatusPage(ApplicationId applicationId, String hostName, String pathSuffix); Long getApplicationGeneration(ApplicationId applicationId); void restart(ApplicationId applicationId, HostFilter hostFilter); boolean isSuspended(ApplicationId application); HttpResponse filedistributionStatus(ApplicationId applicationId, Duration timeout); Set<String> deleteUnusedFiledistributionReferences(File fileReferencesPath, Duration keepFileReferences); Set<FileReference> getFileReferences(ApplicationId applicationId); ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, String path, LocalSession.Mode mode); Tenant getTenant(ApplicationId applicationId); Set<ApplicationId> listApplications(); Optional<String> getApplicationPackageReference(ApplicationId applicationId); List<Version> getAllVersions(ApplicationId applicationId); HttpResponse checkServiceForConfigConvergence(ApplicationId applicationId, String hostAndPort, URI uri,
                                                         Duration timeout, Optional<Version> vespaVersion); HttpResponse servicesToCheckForConfigConvergence(ApplicationId applicationId, URI uri,
                                                            Duration timeoutPerService, Optional<Version> vespaVersion); HttpResponse getLogs(ApplicationId applicationId, Optional<String> hostname, String apiParams); HttpResponse getTesterStatus(ApplicationId applicationId); HttpResponse getTesterLog(ApplicationId applicationId, Long after); HttpResponse startTests(ApplicationId applicationId, String suite, byte[] config); HttpResponse isTesterReady(ApplicationId applicationId); HttpResponse getTestReport(ApplicationId applicationId); CompletionWaiter activate(LocalSession session, Session previousActiveSession, ApplicationId applicationId, boolean force); RemoteSession getActiveSession(ApplicationId applicationId); long getSessionIdForApplication(ApplicationId applicationId); void validateThatSessionIsNotActive(Tenant tenant, long sessionId); void validateThatSessionIsPrepared(Tenant tenant, long sessionId); long createSessionFromExisting(ApplicationId applicationId,
                                          DeployLogger logger,
                                          boolean internalRedeploy,
                                          TimeoutBudget timeoutBudget); long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, InputStream in,
                              String contentType, DeployLogger logger); long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, File applicationDirectory); void deleteExpiredLocalSessions(); int deleteExpiredRemoteSessions(Duration expiryTime); int deleteExpiredRemoteSessions(Clock clock, Duration expiryTime); TenantRepository tenantRepository(); Set<TenantName> deleteUnusedTenants(Duration ttlForUnusedTenant, Instant now); void deleteTenant(TenantName tenantName); ProtonMetricsResponse getProtonMetrics(ApplicationId applicationId); DeploymentMetricsResponse getDeploymentMetrics(ApplicationId applicationId); ApplicationMetaData getMetadataFromLocalSession(Tenant tenant, long sessionId); ConfigserverConfig configserverConfig(); ApplicationId getApplicationIdForHostname(String hostname); Optional<ApplicationSet> getActiveApplicationSet(ApplicationId appId); LocalSession getActiveLocalSession(Tenant tenant, ApplicationId applicationId); Zone zone(); ActionTimer timerFor(ApplicationId id, String metricName);  }
@Test public void testThatPreviousSessionIsDeactivated() { deployApp(testAppJdiscOnly); Session firstSession = applicationRepository.getActiveSession(applicationId()); deployApp(testAppJdiscOnly); assertEquals(Session.Status.DEACTIVATE, firstSession.getStatus()); }