RpcServer implements Runnable, ReloadListener, TenantListener { @Inject public RpcServer(ConfigserverConfig config, SuperModelRequestHandler superModelRequestHandler, MetricUpdaterFactory metrics, HostRegistries hostRegistries, HostLivenessTracker hostLivenessTracker, FileServer fileServer, RpcAuthorizer rpcAuthorizer, RpcRequestHandlerProvider handlerProvider) { this.superModelRequestHandler = superModelRequestHandler; metricUpdaterFactory = metrics; supervisor.setMaxOutputBufferSize(config.maxoutputbuffersize()); this.metrics = metrics.getOrCreateMetricUpdater(Collections.emptyMap()); this.hostLivenessTracker = hostLivenessTracker; BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(config.maxgetconfigclients()); int rpcWorkerThreads = (config.numRpcThreads() == 0) ? threadsToUse() : config.numRpcThreads(); executorService = new ThreadPoolExecutor(rpcWorkerThreads, rpcWorkerThreads, 0, TimeUnit.SECONDS, workQueue, ThreadFactoryFactory.getDaemonThreadFactory(THREADPOOL_NAME)); delayedConfigResponses = new DelayedConfigResponses(this, config.numDelayedResponseThreads()); spec = new Spec(null, config.rpcport()); hostRegistry = hostRegistries.getTenantHostRegistry(); this.useRequestVersion = config.useVespaVersionInRequest(); this.hostedVespa = config.hostedVespa(); this.canReturnEmptySentinelConfig = config.canReturnEmptySentinelConfig(); this.fileServer = fileServer; this.rpcAuthorizer = rpcAuthorizer; downloader = fileServer.downloader(); handlerProvider.setInstance(this); setUpHandlers(); } @Inject  RpcServer(ConfigserverConfig config, SuperModelRequestHandler superModelRequestHandler,
                     MetricUpdaterFactory metrics, HostRegistries hostRegistries,
                     HostLivenessTracker hostLivenessTracker, FileServer fileServer, RpcAuthorizer rpcAuthorizer,
                     RpcRequestHandlerProvider handlerProvider); @Override void run(); void stop(); boolean isRunning(); @Override void configActivated(ApplicationSet applicationSet); @Override void hostsUpdated(TenantName tenant, Collection<String> newHosts); @Override void verifyHostsAreAvailable(TenantName tenant, Collection<String> newHosts); @Override void applicationRemoved(ApplicationId applicationId); void respond(JRTServerConfigRequest request); ConfigResponse resolveConfig(JRTServerConfigRequest request, GetConfigContext context, Optional<Version> vespaVersion); Boolean addToRequestQueue(JRTServerConfigRequest request, boolean forceResponse, CompletionService<Boolean> completionService); @Override void onTenantDelete(TenantName tenant); @Override void onTenantsLoaded(); @Override void onTenantCreate(Tenant tenant); boolean allTenantsLoaded(); boolean isHostedVespa(); boolean canReturnEmptySentinelConfig();  }
@Test public void testRpcServer() throws IOException, SAXException, InterruptedException { try (RpcTester tester = new RpcTester(applicationId, temporaryFolder)) { ApplicationRepository applicationRepository = tester.applicationRepository(); applicationRepository.deploy(testApp, new PrepareParams.Builder().applicationId(applicationId).build()); TenantApplications applicationRepo = tester.tenant().getApplicationRepo(); ApplicationSet applicationSet = tester.tenant().getSessionRepository().ensureApplicationLoaded(applicationRepository.getActiveSession(applicationId)); applicationRepo.reloadConfig(applicationSet); testPrintStatistics(tester); testGetConfig(tester); testEnabled(tester); testApplicationNotLoadedErrorWhenAppDeleted(tester); testEmptySentinelConfigWhenAppDeletedOnHostedVespa(); } }