Search in sources :

Example 1 with Server

use of io.confluent.ksql.api.server.Server in project ksql by confluentinc.

the class BasePerfRunner method setUp.

private void setUp() {
    vertx = Vertx.vertx();
    KsqlRestConfig serverConfig = createServerConfig();
    final ServerState serverState = new ServerState();
    serverState.setReady();
    server = new Server(vertx, serverConfig, endpoints, new KsqlDefaultSecurityExtension(), Optional.empty(), serverState, Optional.empty());
    server.start();
    client = createClient();
}
Also used : Server(io.confluent.ksql.api.server.Server) KsqlDefaultSecurityExtension(io.confluent.ksql.security.KsqlDefaultSecurityExtension) KsqlRestConfig(io.confluent.ksql.rest.server.KsqlRestConfig) ServerState(io.confluent.ksql.rest.server.state.ServerState)

Example 2 with Server

use of io.confluent.ksql.api.server.Server in project ksql by confluentinc.

the class AuthTest method createServer.

@Override
protected void createServer(KsqlRestConfig serverConfig) {
    server = new Server(vertx, serverConfig, testEndpoints, new KsqlSecurityExtension() {

        @Override
        public void initialize(final KsqlConfig ksqlConfig) {
        }

        @Override
        public Optional<KsqlAuthorizationProvider> getAuthorizationProvider() {
            return Optional.ofNullable(authorizationProvider);
        }

        @Override
        public Optional<KsqlUserContextProvider> getUserContextProvider() {
            return Optional.ofNullable(userContextProvider);
        }

        @Override
        public void close() {
        }
    }, Optional.ofNullable(securityHandlerPlugin), serverState, Optional.empty());
    server.start();
}
Also used : Server(io.confluent.ksql.api.server.Server) KsqlUserContextProvider(io.confluent.ksql.security.KsqlUserContextProvider) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlSecurityExtension(io.confluent.ksql.security.KsqlSecurityExtension) KsqlAuthorizationProvider(io.confluent.ksql.security.KsqlAuthorizationProvider)

Example 3 with Server

use of io.confluent.ksql.api.server.Server in project ksql by confluentinc.

the class KsqlRestApplication method startAsync.

@Override
public void startAsync() {
    log.debug("Starting the ksqlDB API server");
    this.serverMetadataResource = ServerMetadataResource.create(serviceContext, ksqlConfigNoPort);
    final StatementParser statementParser = new StatementParser(ksqlEngine);
    final Optional<KsqlAuthorizationValidator> authorizationValidator = KsqlAuthorizationValidatorFactory.create(ksqlConfigNoPort, serviceContext, securityExtension.getAuthorizationProvider());
    final Errors errorHandler = new Errors(restConfig.getConfiguredInstance(KsqlRestConfig.KSQL_SERVER_ERROR_MESSAGES, ErrorMessages.class));
    final KsqlRestConfig ksqlRestConfig = new KsqlRestConfig(ksqlConfigNoPort.originals());
    oldApiWebsocketExecutor = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(ksqlRestConfig.getInt(KsqlRestConfig.KSQL_WEBSOCKETS_NUM_THREADS), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("websockets-query-thread-%d").build()));
    this.wsQueryEndpoint = new WSQueryEndpoint(ksqlConfigNoPort, statementParser, ksqlEngine, commandStore, oldApiWebsocketExecutor, versionCheckerAgent::updateLastRequestTime, Duration.ofMillis(ksqlRestConfig.getLong(KsqlRestConfig.DISTRIBUTED_COMMAND_RESPONSE_TIMEOUT_MS_CONFIG)), authorizationValidator, errorHandler, denyListPropertyValidator, queryExecutor);
    startAsyncThreadRef.set(Thread.currentThread());
    try {
        final Endpoints endpoints = new KsqlServerEndpoints(ksqlEngine, ksqlConfigNoPort, ksqlSecurityContextProvider, ksqlResource, streamedQueryResource, serverInfoResource, heartbeatResource, clusterStatusResource, statusResource, lagReportingResource, healthCheckResource, serverMetadataResource, wsQueryEndpoint, pullQueryMetrics, queryExecutor);
        apiServer = new Server(vertx, ksqlRestConfig, endpoints, securityExtension, authenticationPlugin, serverState, pullQueryMetrics);
        apiServer.start();
        final KsqlConfig ksqlConfigWithPort = buildConfigWithPort();
        configurables.forEach(c -> c.configure(ksqlConfigWithPort));
        startKsql(ksqlConfigWithPort);
        final Properties metricsProperties = new Properties();
        metricsProperties.putAll(restConfig.getOriginals());
        versionCheckerAgent.start(KsqlModuleType.SERVER, metricsProperties);
        log.info("ksqlDB API server listening on {}", StringUtils.join(getListeners(), ", "));
        displayWelcomeMessage();
    } catch (AbortApplicationStartException e) {
        log.error("Aborting application start", e);
    } finally {
        startAsyncThreadRef.set(null);
    }
}
Also used : KsqlAuthorizationValidator(io.confluent.ksql.security.KsqlAuthorizationValidator) Server(io.confluent.ksql.api.server.Server) WSQueryEndpoint(io.confluent.ksql.rest.server.resources.streaming.WSQueryEndpoint) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Properties(java.util.Properties) ErrorMessages(io.confluent.ksql.rest.ErrorMessages) Endpoints(io.confluent.ksql.api.spi.Endpoints) MonitoredEndpoints(io.confluent.ksql.api.impl.MonitoredEndpoints) DefaultConnectServerErrors(io.confluent.ksql.rest.server.execution.DefaultConnectServerErrors) ConnectServerErrors(io.confluent.ksql.rest.server.execution.ConnectServerErrors) Errors(io.confluent.ksql.rest.Errors) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder)

Aggregations

Server (io.confluent.ksql.api.server.Server)3 KsqlConfig (io.confluent.ksql.util.KsqlConfig)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 MonitoredEndpoints (io.confluent.ksql.api.impl.MonitoredEndpoints)1 Endpoints (io.confluent.ksql.api.spi.Endpoints)1 ErrorMessages (io.confluent.ksql.rest.ErrorMessages)1 Errors (io.confluent.ksql.rest.Errors)1 KsqlRestConfig (io.confluent.ksql.rest.server.KsqlRestConfig)1 ConnectServerErrors (io.confluent.ksql.rest.server.execution.ConnectServerErrors)1 DefaultConnectServerErrors (io.confluent.ksql.rest.server.execution.DefaultConnectServerErrors)1 WSQueryEndpoint (io.confluent.ksql.rest.server.resources.streaming.WSQueryEndpoint)1 ServerState (io.confluent.ksql.rest.server.state.ServerState)1 KsqlAuthorizationProvider (io.confluent.ksql.security.KsqlAuthorizationProvider)1 KsqlAuthorizationValidator (io.confluent.ksql.security.KsqlAuthorizationValidator)1 KsqlDefaultSecurityExtension (io.confluent.ksql.security.KsqlDefaultSecurityExtension)1 KsqlSecurityExtension (io.confluent.ksql.security.KsqlSecurityExtension)1 KsqlUserContextProvider (io.confluent.ksql.security.KsqlUserContextProvider)1 Properties (java.util.Properties)1