Search in sources :

Example 1 with TimeoutServiceConfig

use of io.pravega.controller.timeout.TimeoutServiceConfig 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 TimeoutServiceConfig

use of io.pravega.controller.timeout.TimeoutServiceConfig in project pravega by pravega.

the class ControllerServiceConfigTest method configTests.

@Test
public void configTests() {
    // Config parameters should be initialized, default values of the type are not allowed.
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> GRPCServerConfigImpl.builder().build());
    // Published host/port can be empty.
    Assert.assertNotNull(GRPCServerConfigImpl.builder().port(10).build());
    // Published host cannot be empty.
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> GRPCServerConfigImpl.builder().publishedRPCHost("").port(10).build());
    // Port should be positive integer.
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> GRPCServerConfigImpl.builder().port(-10).build());
    // Published port should be a positive integer.
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> GRPCServerConfigImpl.builder().port(10).publishedRPCHost("localhost").publishedRPCPort(-10).build());
    // Config parameters should be initialized, default values of the type are not allowed.
    AssertExtensions.assertThrows(NullPointerException.class, () -> RESTServerConfigImpl.builder().build());
    AssertExtensions.assertThrows(NullPointerException.class, () -> RESTServerConfigImpl.builder().host(null).port(10).build());
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> RESTServerConfigImpl.builder().host("").port(10).build());
    // Port should be positive integer
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> RESTServerConfigImpl.builder().host("localhost").port(-10).build());
    // Config parameters should be initialized, default values of the type are not allowed.
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> HostMonitorConfigImpl.builder().build());
    // If hostMonitorEnabled then containerMap should be non-null
    AssertExtensions.assertThrows(NullPointerException.class, () -> HostMonitorConfigImpl.builder().hostMonitorEnabled(false).hostContainerMap(null).containerCount(10).hostMonitorMinRebalanceInterval(10).build());
    // Port should be positive integer
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> HostMonitorConfigImpl.builder().hostMonitorEnabled(false).hostContainerMap(HostMonitorConfigImpl.getHostContainerMap("host", 10, 2)).hostMonitorMinRebalanceInterval(-10).build());
    // Port should be positive integer
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> HostMonitorConfigImpl.builder().hostMonitorEnabled(true).hostContainerMap(null).hostMonitorMinRebalanceInterval(-10).build());
    // Following combination is OK.
    HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(true).hostContainerMap(null).containerCount(10).hostMonitorMinRebalanceInterval(10).build();
    // Values should be specified
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> TimeoutServiceConfig.builder().build());
    // Positive values required
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> TimeoutServiceConfig.builder().maxLeaseValue(-10).build());
    TimeoutServiceConfig timeoutServiceConfig = TimeoutServiceConfig.builder().maxLeaseValue(10).build();
    AssertExtensions.assertThrows(NullPointerException.class, () -> StoreClientConfigImpl.withZKClient(null));
    AssertExtensions.assertThrows(NullPointerException.class, () -> ZKClientConfigImpl.builder().connectionString(null).build());
    // Namespace should be non-null
    AssertExtensions.assertThrows(NullPointerException.class, () -> ZKClientConfigImpl.builder().connectionString("localhost").build());
    // Sleep interval should be positive number
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> ZKClientConfigImpl.builder().connectionString("localhost").namespace("test").initialSleepInterval(-10).build());
    // max retries should be positive number
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> ZKClientConfigImpl.builder().connectionString("localhost").namespace("test").initialSleepInterval(10).maxRetries(-10).namespace("").build());
    // zk session timeout should be positive number
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> ZKClientConfigImpl.builder().connectionString("localhost").namespace("test").sessionTimeoutMs(-10).namespace("").build());
    StoreClientConfig storeClientConfig = StoreClientConfigImpl.withInMemoryClient();
    // If eventProcessor config is enabled, it should be non-null
    AssertExtensions.assertThrows(NullPointerException.class, () -> ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.of(null)).grpcServerConfig(Optional.empty()).restServerConfig(Optional.empty()).build());
    // If grpcServerConfig is present it should be non-null
    AssertExtensions.assertThrows(NullPointerException.class, () -> ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.empty()).grpcServerConfig(Optional.of(null)).restServerConfig(Optional.empty()).build());
    // If restServerConfig is present it should be non-null
    AssertExtensions.assertThrows(NullPointerException.class, () -> ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.empty()).grpcServerConfig(Optional.empty()).restServerConfig(Optional.of(null)).build());
    AssertExtensions.assertThrows(IllegalArgumentException.class, () -> ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).controllerClusterListenerEnabled(true).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.empty()).grpcServerConfig(Optional.empty()).restServerConfig(Optional.empty()).build());
}
Also used : TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) StoreClientConfig(io.pravega.controller.store.client.StoreClientConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig) Test(org.junit.Test)

Example 3 with TimeoutServiceConfig

use of io.pravega.controller.timeout.TimeoutServiceConfig in project pravega by pravega.

the class ControllerServiceMainTest method createControllerServiceConfig.

protected ControllerServiceConfig createControllerServiceConfig() {
    HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(false).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();
    return ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).controllerClusterListenerEnabled(!disableControllerCluster).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.empty()).grpcServerConfig(Optional.empty()).restServerConfig(Optional.empty()).build();
}
Also used : TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig)

Example 4 with TimeoutServiceConfig

use of io.pravega.controller.timeout.TimeoutServiceConfig in project pravega by pravega.

the class ZKBackedControllerServiceStarterTest method createControllerServiceConfigWithEventProcessors.

protected ControllerServiceConfig createControllerServiceConfigWithEventProcessors() {
    HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(false).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();
    return ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).controllerClusterListenerEnabled(false).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.of(ControllerEventProcessorConfigImpl.withDefault())).grpcServerConfig(Optional.of(GRPCServerConfigImpl.builder().port(grpcPort).authorizationEnabled(false).tlsEnabled(false).tlsProtocolVersion(SecurityConfigDefaults.TLS_PROTOCOL_VERSION).build())).restServerConfig(Optional.empty()).build();
}
Also used : TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig)

Example 5 with TimeoutServiceConfig

use of io.pravega.controller.timeout.TimeoutServiceConfig in project pravega by pravega.

the class ControllerPrometheusTest method createControllerServiceConfig.

protected ControllerServiceConfig createControllerServiceConfig() {
    HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(false).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();
    return ControllerServiceConfigImpl.builder().threadPoolSize(15).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.empty()).grpcServerConfig(Optional.of(GRPCServerConfigImpl.builder().port(grpcPort).build())).restServerConfig(Optional.of(RESTServerConfigImpl.builder().port(restPort).host("localhost").build())).build();
}
Also used : TimeoutServiceConfig(io.pravega.controller.timeout.TimeoutServiceConfig) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig)

Aggregations

HostMonitorConfig (io.pravega.controller.store.host.HostMonitorConfig)7 TimeoutServiceConfig (io.pravega.controller.timeout.TimeoutServiceConfig)7 StoreClientConfig (io.pravega.controller.store.client.StoreClientConfig)3 ControllerEventProcessorConfig (io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig)2 GRPCServerConfig (io.pravega.controller.server.rpc.grpc.GRPCServerConfig)2 ZKClientConfig (io.pravega.controller.store.client.ZKClientConfig)2 RESTServerConfig (io.pravega.shared.rest.RESTServerConfig)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)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 ZKClientConfigImpl (io.pravega.controller.store.client.impl.ZKClientConfigImpl)1 HostMonitorConfigImpl (io.pravega.controller.store.host.impl.HostMonitorConfigImpl)1