Search in sources :

Example 1 with RESTServerConfig

use of io.pravega.shared.rest.RESTServerConfig in project pravega by pravega.

the class Main method main.

public static void main(String[] args) {
    StatsProvider statsProvider = null;
    try {
        // 0. Initialize metrics provider
        MetricsProvider.initialize(Config.METRICS_CONFIG);
        statsProvider = MetricsProvider.getMetricsProvider();
        statsProvider.start();
        ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(Config.ZK_URL).secureConnectionToZooKeeper(Config.SECURE_ZK).trustStorePath(Config.ZK_TRUSTSTORE_FILE_PATH).trustStorePasswordPath(Config.ZK_TRUSTSTORE_PASSWORD_FILE_PATH).namespace("pravega/" + Config.CLUSTER_NAME).initialSleepInterval(Config.ZK_RETRY_SLEEP_MS).maxRetries(Config.ZK_MAX_RETRIES).sessionTimeoutMs(Config.ZK_SESSION_TIMEOUT_MS).build();
        StoreClientConfig storeClientConfig;
        if (Config.USE_PRAVEGA_TABLES) {
            storeClientConfig = StoreClientConfigImpl.withPravegaTablesClient(zkClientConfig);
        } else {
            storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
        }
        HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(Config.HOST_MONITOR_ENABLED).hostMonitorMinRebalanceInterval(Config.CLUSTER_MIN_REBALANCE_INTERVAL).containerCount(Config.HOST_STORE_CONTAINER_COUNT).hostContainerMap(HostMonitorConfigImpl.getHostContainerMap(Config.SERVICE_HOST, Config.SERVICE_PORT, Config.HOST_STORE_CONTAINER_COUNT)).build();
        TimeoutServiceConfig timeoutServiceConfig = TimeoutServiceConfig.builder().maxLeaseValue(Config.MAX_LEASE_VALUE).build();
        ControllerEventProcessorConfig eventProcessorConfig = ControllerEventProcessorConfigImpl.withDefault();
        GRPCServerConfig grpcServerConfig = Config.GRPC_SERVER_CONFIG;
        RESTServerConfig restServerConfig = RESTServerConfigImpl.builder().host(Config.REST_SERVER_IP).port(Config.REST_SERVER_PORT).tlsEnabled(Config.TLS_ENABLED).tlsProtocolVersion(Config.TLS_PROTOCOL_VERSION.toArray(new String[Config.TLS_PROTOCOL_VERSION.size()])).keyFilePath(Config.REST_KEYSTORE_FILE_PATH).keyFilePasswordPath(Config.REST_KEYSTORE_PASSWORD_FILE_PATH).build();
        ControllerServiceConfig serviceConfig = ControllerServiceConfigImpl.builder().threadPoolSize(Config.ASYNC_TASK_POOL_SIZE).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).controllerClusterListenerEnabled(true).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.of(eventProcessorConfig)).grpcServerConfig(Optional.of(grpcServerConfig)).restServerConfig(Optional.of(restServerConfig)).tlsEnabledForSegmentStore(Config.TLS_ENABLED_FOR_SEGMENT_STORE).build();
        setUncaughtExceptionHandler(Main::logUncaughtException);
        ControllerServiceMain controllerServiceMain = new ControllerServiceMain(serviceConfig);
        controllerServiceMain.startAsync();
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            onShutdown(controllerServiceMain);
        }));
        controllerServiceMain.awaitTerminated();
        log.info("Controller service exited");
        System.exit(0);
    } catch (Throwable e) {
        log.error("Controller service failed", e);
        System.exit(-1);
    } finally {
        if (statsProvider != null) {
            statsProvider.close();
        }
    }
}
Also used : ControllerEventProcessorConfig(io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig) GRPCServerConfig(io.pravega.controller.server.rpc.grpc.GRPCServerConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig) RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) StatsProvider(io.pravega.shared.metrics.StatsProvider) StoreClientConfig(io.pravega.controller.store.client.StoreClientConfig)

Example 2 with RESTServerConfig

use of io.pravega.shared.rest.RESTServerConfig in project pravega by pravega.

the class RESTServerConfigImplTests method testToStringIsSuccessfulWithTlsDisabled.

@Test
public void testToStringIsSuccessfulWithTlsDisabled() {
    RESTServerConfig config = RESTServerConfigImpl.builder().host("localhost").port(2020).authorizationEnabled(false).userPasswordFile(null).tlsEnabled(false).keyFilePath(null).keyFilePasswordPath(null).build();
    assertNotNull(config.toString());
}
Also used : RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) Test(org.junit.Test)

Example 3 with RESTServerConfig

use of io.pravega.shared.rest.RESTServerConfig in project pravega by pravega.

the class RESTServerConfigImplTests method testToStringIsSuccessfulWithAllConfigSpecified.

// region Tests that verify the toString() method.
// Note: It might seem odd that we are unit testing the toString() method of the code under test. The reason we are
// doing that is that the method is hand-rolled and there is a bit of logic there that isn't entirely unlikely to fail.
@Test
public void testToStringIsSuccessfulWithAllConfigSpecified() {
    RESTServerConfig config = RESTServerConfigImpl.builder().host("localhost").port(2020).authorizationEnabled(true).userPasswordFile("/passwd").tlsEnabled(true).tlsProtocolVersion(SecurityConfigDefaults.TLS_PROTOCOL_VERSION).keyFilePath("/rest.keystore.jks").keyFilePasswordPath("/keystore.jks.passwd").build();
    assertNotNull(config.toString());
}
Also used : RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) Test(org.junit.Test)

Example 4 with RESTServerConfig

use of io.pravega.shared.rest.RESTServerConfig in project pravega by pravega.

the class RESTAuthHelperTest method init.

@Before
public void init() {
    RESTServerConfig config = RESTServerConfigImpl.builder().host("localhost").port(TestUtils.getAvailableListenPort()).authorizationEnabled(true).userPasswordFile("passwd").tlsEnabled(false).build();
    AuthHandlerManager authManager = new AuthHandlerManager(config);
    authManager.registerHandler(new FakeAuthHandler());
    authHelper = new RESTAuthHelper(authManager);
}
Also used : RESTAuthHelper(io.pravega.shared.rest.security.RESTAuthHelper) AuthHandlerManager(io.pravega.shared.rest.security.AuthHandlerManager) FakeAuthHandler(io.pravega.auth.FakeAuthHandler) RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) Before(org.junit.Before)

Example 5 with RESTServerConfig

use of io.pravega.shared.rest.RESTServerConfig in project pravega by pravega.

the class InProcPravegaCluster method startLocalController.

private ControllerServiceMain startLocalController(int controllerId) {
    ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkUrl).namespace("pravega/" + clusterName).initialSleepInterval(2000).maxRetries(1).sessionTimeoutMs(10 * 1000).secureConnectionToZooKeeper(this.secureZK).trustStorePath(jksTrustFile).trustStorePasswordPath(keyPasswordFile).build();
    StoreClientConfig storeClientConfig = StoreClientConfigImpl.withPravegaTablesClient(zkClientConfig);
    HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(true).containerCount(containerCount).hostMonitorMinRebalanceInterval(1).build();
    TimeoutServiceConfig timeoutServiceConfig = TimeoutServiceConfig.builder().maxLeaseValue(Config.MAX_LEASE_VALUE).build();
    ControllerEventProcessorConfig eventProcessorConfig = ControllerEventProcessorConfigImpl.withDefaultBuilder().shutdownTimeout(Duration.ofMillis(100)).build();
    GRPCServerConfig grpcServerConfig = GRPCServerConfigImpl.builder().port(this.controllerPorts[controllerId]).publishedRPCHost("localhost").publishedRPCPort(this.controllerPorts[controllerId]).authorizationEnabled(this.enableAuth).tlsEnabled(this.enableTls).tlsProtocolVersion(this.tlsProtocolVersion).tlsTrustStore(this.certFile).tlsCertFile(this.certFile).tlsKeyFile(this.keyFile).userPasswordFile(this.passwdFile).tokenSigningKey("secret").accessTokenTTLInSeconds(600).replyWithStackTraceOnError(false).requestTracingEnabled(true).build();
    RESTServerConfig restServerConfig = null;
    if (this.enableRestServer) {
        restServerConfig = RESTServerConfigImpl.builder().host("0.0.0.0").port(this.restServerPort).tlsEnabled(this.enableTls).tlsProtocolVersion(this.tlsProtocolVersion).keyFilePath(this.jksKeyFile).keyFilePasswordPath(this.keyPasswordFile).build();
    }
    ControllerServiceConfig serviceConfig = ControllerServiceConfigImpl.builder().threadPoolSize(Runtime.getRuntime().availableProcessors()).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).controllerClusterListenerEnabled(false).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.of(eventProcessorConfig)).grpcServerConfig(Optional.of(grpcServerConfig)).restServerConfig(Optional.ofNullable(restServerConfig)).shutdownTimeout(Duration.ofMillis(100)).build();
    ControllerServiceMain controllerService = new ControllerServiceMain(serviceConfig);
    try {
        controllerService.startAsync().awaitRunning();
        return controllerService;
    } catch (Throwable ex) {
        Callbacks.invokeSafely(controllerService::close, ex2 -> log.error("Unable to clean up controller startup.", ex2));
        throw ex;
    }
}
Also used : ControllerEventProcessorConfig(io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig) Arrays(java.util.Arrays) ZooKeeperServiceRunner(io.pravega.segmentstore.storage.impl.bookkeeper.ZooKeeperServiceRunner) ZKClientConfigImpl(io.pravega.controller.store.client.impl.ZKClientConfigImpl) Cleanup(lombok.Cleanup) ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) RESTServerConfigImpl(io.pravega.shared.rest.impl.RESTServerConfigImpl) ControllerServiceConfigImpl(io.pravega.controller.server.impl.ControllerServiceConfigImpl) StoreClientConfigImpl(io.pravega.controller.store.client.impl.StoreClientConfigImpl) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig) Duration(java.time.Duration) ToString(lombok.ToString) URI(java.net.URI) ServiceStarter(io.pravega.segmentstore.server.host.ServiceStarter) AutoScalerConfig(io.pravega.segmentstore.server.host.stat.AutoScalerConfig) Synchronized(lombok.Synchronized) DurableLogConfig(io.pravega.segmentstore.server.logs.DurableLogConfig) UUID(java.util.UUID) GuardedBy(javax.annotation.concurrent.GuardedBy) Collectors(java.util.stream.Collectors) Slf4j(lombok.extern.slf4j.Slf4j) CuratorFramework(org.apache.curator.framework.CuratorFramework) Builder(lombok.Builder) Config(io.pravega.controller.util.Config) RetryPolicy(org.apache.curator.RetryPolicy) StorageLayoutType(io.pravega.segmentstore.storage.StorageLayoutType) Optional(java.util.Optional) ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) GRPCServerConfig(io.pravega.controller.server.rpc.grpc.GRPCServerConfig) StoreClientConfig(io.pravega.controller.store.client.StoreClientConfig) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) ControllerServiceConfig(io.pravega.controller.server.ControllerServiceConfig) ZKTLSUtils(io.pravega.common.security.ZKTLSUtils) ServiceConfig(io.pravega.segmentstore.server.store.ServiceConfig) GRPCServerConfigImpl(io.pravega.controller.server.rpc.grpc.impl.GRPCServerConfigImpl) TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) Strings(com.google.common.base.Strings) ControllerEventProcessorConfigImpl(io.pravega.controller.server.eventProcessor.impl.ControllerEventProcessorConfigImpl) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) TLSProtocolVersion(io.pravega.common.security.TLSProtocolVersion) HostMonitorConfigImpl(io.pravega.controller.store.host.impl.HostMonitorConfigImpl) Callbacks(io.pravega.common.function.Callbacks) ControllerEventProcessorConfig(io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig) IOException(java.io.IOException) ControllerServiceMain(io.pravega.controller.server.ControllerServiceMain) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) Credentials(io.pravega.shared.security.auth.Credentials) Preconditions(com.google.common.base.Preconditions) TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) GRPCServerConfig(io.pravega.controller.server.rpc.grpc.GRPCServerConfig) StoreClientConfig(io.pravega.controller.store.client.StoreClientConfig) ControllerServiceConfig(io.pravega.controller.server.ControllerServiceConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig) RESTServerConfig(io.pravega.shared.rest.RESTServerConfig) ControllerServiceMain(io.pravega.controller.server.ControllerServiceMain)

Aggregations

RESTServerConfig (io.pravega.shared.rest.RESTServerConfig)5 ControllerEventProcessorConfig (io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig)2 GRPCServerConfig (io.pravega.controller.server.rpc.grpc.GRPCServerConfig)2 StoreClientConfig (io.pravega.controller.store.client.StoreClientConfig)2 ZKClientConfig (io.pravega.controller.store.client.ZKClientConfig)2 HostMonitorConfig (io.pravega.controller.store.host.HostMonitorConfig)2 TimeoutServiceConfig (io.pravega.controller.timeout.TimeoutServiceConfig)2 Test (org.junit.Test)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 FakeAuthHandler (io.pravega.auth.FakeAuthHandler)1 Callbacks (io.pravega.common.function.Callbacks)1 TLSProtocolVersion (io.pravega.common.security.TLSProtocolVersion)1 ZKTLSUtils (io.pravega.common.security.ZKTLSUtils)1 ControllerServiceConfig (io.pravega.controller.server.ControllerServiceConfig)1 ControllerServiceMain (io.pravega.controller.server.ControllerServiceMain)1 ControllerEventProcessorConfigImpl (io.pravega.controller.server.eventProcessor.impl.ControllerEventProcessorConfigImpl)1 ControllerServiceConfigImpl (io.pravega.controller.server.impl.ControllerServiceConfigImpl)1 GRPCServerConfigImpl (io.pravega.controller.server.rpc.grpc.impl.GRPCServerConfigImpl)1 StoreClientConfigImpl (io.pravega.controller.store.client.impl.StoreClientConfigImpl)1