use of io.pravega.controller.server.rest.RESTServerConfig in project pravega by pravega.
the class Main method main.
public static void main(String[] args) {
try {
// 0. Initialize metrics provider
MetricsProvider.initialize(Config.getMetricsConfig());
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(Config.ZK_URL).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 = 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).maxScaleGracePeriod(Config.MAX_SCALE_GRACE_PERIOD).build();
ControllerEventProcessorConfig eventProcessorConfig = ControllerEventProcessorConfigImpl.withDefault();
GRPCServerConfig grpcServerConfig = Config.getGRPCServerConfig();
RESTServerConfig restServerConfig = RESTServerConfigImpl.builder().host(Config.REST_SERVER_IP).port(Config.REST_SERVER_PORT).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)).build();
ControllerServiceMain controllerServiceMain = new ControllerServiceMain(serviceConfig);
controllerServiceMain.startAsync();
controllerServiceMain.awaitTerminated();
log.info("Controller service exited");
System.exit(0);
} catch (Throwable e) {
log.error("Controller service failed", e);
System.exit(-1);
}
}
use of io.pravega.controller.server.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).build();
StoreClientConfig storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(true).hostMonitorMinRebalanceInterval(Config.CLUSTER_MIN_REBALANCE_INTERVAL).containerCount(Config.HOST_STORE_CONTAINER_COUNT).build();
TimeoutServiceConfig timeoutServiceConfig = TimeoutServiceConfig.builder().maxLeaseValue(Config.MAX_LEASE_VALUE).maxScaleGracePeriod(Config.MAX_SCALE_GRACE_PERIOD).build();
ControllerEventProcessorConfig eventProcessorConfig = ControllerEventProcessorConfigImpl.withDefault();
GRPCServerConfig grpcServerConfig = GRPCServerConfigImpl.builder().port(this.controllerPorts[controllerId]).publishedRPCHost("localhost").publishedRPCPort(this.controllerPorts[controllerId]).authorizationEnabled(this.enableAuth).tlsEnabled(this.enableTls).tlsTrustStore("../config/cert.pem").tlsCertFile("../config/cert.pem").tlsKeyFile("../config/key.pem").userPasswordFile("../config/passwd").tokenSigningKey("secret").build();
RESTServerConfig restServerConfig = RESTServerConfigImpl.builder().host("0.0.0.0").port(this.restServerPort).build();
ControllerServiceConfig serviceConfig = ControllerServiceConfigImpl.builder().threadPoolSize(Config.ASYNC_TASK_POOL_SIZE).storeClientConfig(storeClientConfig).hostMonitorConfig(hostMonitorConfig).controllerClusterListenerEnabled(false).timeoutServiceConfig(timeoutServiceConfig).eventProcessorConfig(Optional.of(eventProcessorConfig)).grpcServerConfig(Optional.of(grpcServerConfig)).restServerConfig(Optional.of(restServerConfig)).build();
ControllerServiceMain controllerService = new ControllerServiceMain(serviceConfig);
controllerService.startAsync();
return controllerService;
}
Aggregations