Search in sources :

Example 1 with AdminConnectionListener

use of io.pravega.segmentstore.server.host.handler.AdminConnectionListener in project pravega by pravega.

the class ServiceStarter method start.

// endregion
// region Service Operation
public void start() throws Exception {
    Exceptions.checkNotClosed(this.closed, this);
    healthServiceManager = new HealthServiceManager(serviceConfig.getHealthCheckInterval());
    healthServiceManager.start();
    log.info("Initializing HealthService ...");
    MetricsConfig metricsConfig = builderConfig.getConfig(MetricsConfig::builder);
    if (metricsConfig.isEnableStatistics()) {
        log.info("Initializing metrics provider ...");
        MetricsProvider.initialize(metricsConfig);
        statsProvider = MetricsProvider.getMetricsProvider();
        statsProvider.start();
    }
    log.info("Initializing ZooKeeper Client ...");
    this.zkClient = createZKClient();
    log.info("Initializing Service Builder ...");
    this.serviceBuilder.initialize();
    log.info("Creating StreamSegmentService ...");
    StreamSegmentStore service = this.serviceBuilder.createStreamSegmentService();
    log.info("Creating TableStoreService ...");
    TableStore tableStoreService = this.serviceBuilder.createTableStoreService();
    log.info("Creating Segment Stats recorder ...");
    autoScaleMonitor = new AutoScaleMonitor(service, builderConfig.getConfig(AutoScalerConfig::builder));
    AutoScalerConfig autoScalerConfig = builderConfig.getConfig(AutoScalerConfig::builder);
    TokenVerifierImpl tokenVerifier = null;
    if (autoScalerConfig.isAuthEnabled()) {
        tokenVerifier = new TokenVerifierImpl(autoScalerConfig.getTokenSigningKey());
    }
    // Log the configuration
    log.info(serviceConfig.toString());
    log.info(autoScalerConfig.toString());
    this.listener = new PravegaConnectionListener(this.serviceConfig.isEnableTls(), this.serviceConfig.isEnableTlsReload(), this.serviceConfig.getListeningIPAddress(), this.serviceConfig.getListeningPort(), service, tableStoreService, autoScaleMonitor.getStatsRecorder(), autoScaleMonitor.getTableSegmentStatsRecorder(), tokenVerifier, this.serviceConfig.getCertFile(), this.serviceConfig.getKeyFile(), this.serviceConfig.isReplyWithStackTraceOnError(), serviceBuilder.getLowPriorityExecutor(), this.serviceConfig.getTlsProtocolVersion(), healthServiceManager);
    this.listener.startListening();
    log.info("PravegaConnectionListener started successfully.");
    if (serviceConfig.isEnableAdminGateway()) {
        this.adminListener = new AdminConnectionListener(this.serviceConfig.isEnableTls(), this.serviceConfig.isEnableTlsReload(), this.serviceConfig.getListeningIPAddress(), this.serviceConfig.getAdminGatewayPort(), service, tableStoreService, tokenVerifier, this.serviceConfig.getCertFile(), this.serviceConfig.getKeyFile(), this.serviceConfig.getTlsProtocolVersion(), healthServiceManager);
        this.adminListener.startListening();
        log.info("AdminConnectionListener started successfully.");
    }
    log.info("StreamSegmentService started.");
    healthServiceManager.register(new ZKHealthContributor(zkClient));
    healthServiceManager.register(new CacheManagerHealthContributor(serviceBuilder.getCacheManager()));
    healthServiceManager.register(new SegmentContainerRegistryHealthContributor(serviceBuilder.getSegmentContainerRegistry()));
    if (this.serviceConfig.isRestServerEnabled()) {
        log.info("Initializing RESTServer ...");
        List<Object> resources = new ArrayList<>();
        resources.add(new HealthImpl(new AuthHandlerManager(serviceConfig.getRestServerConfig()), healthServiceManager.getEndpoint()));
        MetricsProvider.getMetricsProvider().prometheusResource().ifPresent(resources::add);
        restServer = new RESTServer(serviceConfig.getRestServerConfig(), Set.copyOf(resources));
        restServer.startAsync();
        restServer.awaitRunning();
    }
}
Also used : HealthServiceManager(io.pravega.shared.health.HealthServiceManager) AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor) AdminConnectionListener(io.pravega.segmentstore.server.host.handler.AdminConnectionListener) AutoScalerConfig(io.pravega.segmentstore.server.host.stat.AutoScalerConfig) ArrayList(java.util.ArrayList) ZKHealthContributor(io.pravega.segmentstore.server.host.health.ZKHealthContributor) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) TableStore(io.pravega.segmentstore.contracts.tables.TableStore) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) HealthImpl(io.pravega.shared.health.bindings.resources.HealthImpl) SegmentContainerRegistryHealthContributor(io.pravega.segmentstore.server.host.health.SegmentContainerRegistryHealthContributor) AuthHandlerManager(io.pravega.shared.rest.security.AuthHandlerManager) CacheManagerHealthContributor(io.pravega.segmentstore.server.CacheManager.CacheManagerHealthContributor) TokenVerifierImpl(io.pravega.segmentstore.server.host.delegationtoken.TokenVerifierImpl) RESTServer(io.pravega.shared.rest.RESTServer)

Example 2 with AdminConnectionListener

use of io.pravega.segmentstore.server.host.handler.AdminConnectionListener in project pravega by pravega.

the class SetupUtils method startAllServices.

/**
 * Start all pravega related services required for the test deployment.
 *
 * @param numThreads the number of threads for the internal client threadpool.
 * @param enableAuth set to enale authentication
 * @param enableTls set to enable tls
 * @throws Exception on any errors.
 */
public void startAllServices(Integer numThreads, boolean enableAuth, boolean enableTls) throws Exception {
    if (!this.started.compareAndSet(false, true)) {
        log.warn("Services already started, not attempting to start again");
        return;
    }
    if (enableAuth) {
        clientConfigBuilder = clientConfigBuilder.credentials(new DefaultCredentials(SecurityConfigDefaults.AUTH_ADMIN_PASSWORD, SecurityConfigDefaults.AUTH_ADMIN_USERNAME));
    }
    if (enableTls) {
        clientConfigBuilder = clientConfigBuilder.trustStore(pathToConfig() + SecurityConfigDefaults.TLS_CA_CERT_FILE_NAME).controllerURI(URI.create("tls://localhost:" + controllerRPCPort)).validateHostName(false);
    } else {
        clientConfigBuilder = clientConfigBuilder.controllerURI(URI.create("tcp://localhost:" + controllerRPCPort));
    }
    this.executor = ExecutorServiceHelpers.newScheduledThreadPool(2, "Controller pool");
    this.controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(getClientConfig()).build(), executor);
    this.clientFactory = new ClientFactoryImpl(scope, controller, getClientConfig());
    // Start zookeeper.
    this.zkTestServer = new TestingServerStarter().start();
    this.zkTestServer.start();
    // Start Pravega Service.
    this.serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    this.serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    TableStore tableStore = serviceBuilder.createTableStoreService();
    this.server = new PravegaConnectionListener(enableTls, false, "localhost", servicePort, store, tableStore, SegmentStatsRecorder.noOp(), TableSegmentStatsRecorder.noOp(), new PassingTokenVerifier(), pathToConfig() + SecurityConfigDefaults.TLS_SERVER_CERT_FILE_NAME, pathToConfig() + SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_FILE_NAME, true, serviceBuilder.getLowPriorityExecutor(), SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
    this.server.startListening();
    log.info("Started Pravega Service");
    this.adminListener = new AdminConnectionListener(enableTls, false, "localhost", adminPort, store, tableStore, new PassingTokenVerifier(), pathToConfig() + SecurityConfigDefaults.TLS_SERVER_CERT_FILE_NAME, pathToConfig() + SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_FILE_NAME, SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
    this.adminListener.startListening();
    log.info("AdminConnectionListener started successfully.");
    // Start Controller.
    this.controllerWrapper = new ControllerWrapper(this.zkTestServer.getConnectString(), false, true, controllerRPCPort, "localhost", servicePort, Config.HOST_STORE_CONTAINER_COUNT, controllerRESTPort, enableAuth, pathToConfig() + SecurityConfigDefaults.AUTH_HANDLER_INPUT_FILE_NAME, "secret", true, 600, enableTls, SecurityConfigDefaults.TLS_PROTOCOL_VERSION, pathToConfig() + SecurityConfigDefaults.TLS_SERVER_CERT_FILE_NAME, pathToConfig() + SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_FILE_NAME, pathToConfig() + SecurityConfigDefaults.TLS_SERVER_KEYSTORE_NAME, pathToConfig() + SecurityConfigDefaults.TLS_PASSWORD_FILE_NAME);
    this.controllerWrapper.awaitRunning();
    this.controllerWrapper.getController().createScope(scope).get();
    log.info("Initialized Pravega Controller");
}
Also used : DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) TestingServerStarter(io.pravega.test.common.TestingServerStarter) AdminConnectionListener(io.pravega.segmentstore.server.host.handler.AdminConnectionListener) PassingTokenVerifier(io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier) ControllerImpl(io.pravega.client.control.impl.ControllerImpl) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) TableStore(io.pravega.segmentstore.contracts.tables.TableStore)

Aggregations

StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)2 TableStore (io.pravega.segmentstore.contracts.tables.TableStore)2 AdminConnectionListener (io.pravega.segmentstore.server.host.handler.AdminConnectionListener)2 PravegaConnectionListener (io.pravega.segmentstore.server.host.handler.PravegaConnectionListener)2 ControllerImpl (io.pravega.client.control.impl.ControllerImpl)1 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)1 CacheManagerHealthContributor (io.pravega.segmentstore.server.CacheManager.CacheManagerHealthContributor)1 PassingTokenVerifier (io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier)1 TokenVerifierImpl (io.pravega.segmentstore.server.host.delegationtoken.TokenVerifierImpl)1 SegmentContainerRegistryHealthContributor (io.pravega.segmentstore.server.host.health.SegmentContainerRegistryHealthContributor)1 ZKHealthContributor (io.pravega.segmentstore.server.host.health.ZKHealthContributor)1 AutoScaleMonitor (io.pravega.segmentstore.server.host.stat.AutoScaleMonitor)1 AutoScalerConfig (io.pravega.segmentstore.server.host.stat.AutoScalerConfig)1 HealthServiceManager (io.pravega.shared.health.HealthServiceManager)1 HealthImpl (io.pravega.shared.health.bindings.resources.HealthImpl)1 MetricsConfig (io.pravega.shared.metrics.MetricsConfig)1 RESTServer (io.pravega.shared.rest.RESTServer)1 AuthHandlerManager (io.pravega.shared.rest.security.AuthHandlerManager)1 DefaultCredentials (io.pravega.shared.security.auth.DefaultCredentials)1 TestingServerStarter (io.pravega.test.common.TestingServerStarter)1