use of io.pravega.controller.server.ControllerServiceConfig in project pravega by pravega.
the class ClusterListenerHealthContributorTest method setup.
@Before
public void setup() {
Host host = mock(Host.class);
Cluster cluster = mock(Cluster.class);
ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
ControllerServiceConfig serviceConfig = mock(ControllerServiceConfigImpl.class);
TaskSweeper taskSweeper = mock(TaskSweeper.class);
TxnSweeper txnSweeper = mock(TxnSweeper.class);
List<FailoverSweeper> failoverSweepers = new ArrayList<>();
failoverSweepers.add(taskSweeper);
failoverSweepers.add(txnSweeper);
doReturn(true).when(serviceConfig).isControllerClusterListenerEnabled();
clusterListener = spy(new ControllerClusterListener(host, cluster, executor, failoverSweepers));
doReturn(true).when(clusterListener).isReady();
contributor = new ClusterListenerHealthContributor("clusterlistener", clusterListener);
builder = Health.builder().name("clusterlistener");
}
use of io.pravega.controller.server.ControllerServiceConfig 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;
}
}
Aggregations