TenantApplications implements RequestHandler, HostValidator<ApplicationId> { public long requireActiveSessionOf(ApplicationId applicationId) { return activeSessionOf(applicationId) .orElseThrow(() -> new IllegalArgumentException("Application '" + applicationId + "' has no active session.")); } TenantApplications(TenantName tenant, Curator curator, StripedExecutor<TenantName> zkWatcherExecutor,
                              ExecutorService zkCacheExecutor, Metrics metrics, ReloadListener reloadListener,
                              ConfigserverConfig configserverConfig, HostRegistry<ApplicationId> hostRegistry,
                              TenantFileSystemDirs tenantFileSystemDirs); static TenantApplications create(GlobalComponentRegistry componentRegistry, TenantName tenantName); List<ApplicationId> activeApplications(); boolean exists(ApplicationId id); Optional<Long> activeSessionOf(ApplicationId id); boolean hasLocalSession(long sessionId); Transaction createPutTransaction(ApplicationId applicationId, long sessionId); void createApplication(ApplicationId id); long requireActiveSessionOf(ApplicationId applicationId); CuratorTransaction createDeleteTransaction(ApplicationId applicationId); void removeUnusedApplications(); void close(); Lock lock(ApplicationId id); @Override ConfigResponse resolveConfig(ApplicationId appId, GetConfigRequest req, Optional<Version> vespaVersion); void reloadConfig(ApplicationSet applicationSet); void removeApplication(ApplicationId applicationId); void removeApplicationsExcept(Set<ApplicationId> applications); @Override Set<ConfigKey<?>> listNamedConfigs(ApplicationId appId, Optional<Version> vespaVersion, ConfigKey<?> keyToMatch, boolean recursive); @Override Set<ConfigKey<?>> listConfigs(ApplicationId appId, Optional<Version> vespaVersion, boolean recursive); @Override Set<ConfigKey<?>> allConfigsProduced(ApplicationId appId, Optional<Version> vespaVersion); @Override Set<String> allConfigIds(ApplicationId appId, Optional<Version> vespaVersion); @Override boolean hasApplication(ApplicationId appId, Optional<Version> vespaVersion); @Override ApplicationId resolveApplicationId(String hostName); @Override Set<FileReference> listFileReferences(ApplicationId applicationId); @Override void verifyHosts(ApplicationId key, Collection<String> newHosts); HostValidator<ApplicationId> getHostValidator(); ApplicationId getApplicationIdForHostName(String hostname); TenantFileSystemDirs getTenantFileSystemDirs();  }
@Test(expected = IllegalArgumentException.class) public void require_that_requesting_session_for_unknown_application_throws_exception() { TenantApplications repo = createZKAppRepo(); repo.requireActiveSessionOf(createApplicationId("nonexistent")); }