use of io.pravega.controller.store.client.ZKClientConfig in project pravega by pravega.
the class ZKControllerServiceMainTest method setup.
@Override
public void setup() {
try {
zkServer = new TestingServerStarter().start();
} catch (Exception e) {
log.error("Error starting test zk server");
Assert.fail("Error starting test zk server");
}
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkServer.getConnectString()).initialSleepInterval(500).maxRetries(10).sessionTimeoutMs(10 * 1000).namespace("pravega/" + UUID.randomUUID()).build();
storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
}
use of io.pravega.controller.store.client.ZKClientConfig 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();
}
}
}
use of io.pravega.controller.store.client.ZKClientConfig in project pravega by pravega.
the class HostStoreTest method zkHostStoreTests.
@Test(timeout = 10000L)
public void zkHostStoreTests() throws Exception {
@Cleanup TestingServer zkTestServer = new TestingServerStarter().start();
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkTestServer.getConnectString()).initialSleepInterval(2000).maxRetries(1).sessionTimeoutMs(10 * 1000).namespace("hostStoreTest/" + UUID.randomUUID()).build();
StoreClientConfig storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
@Cleanup StoreClient storeClient = StoreClientFactory.createStoreClient(storeClientConfig);
HostMonitorConfig hostMonitorConfig = HostMonitorConfigImpl.builder().hostMonitorEnabled(true).hostMonitorMinRebalanceInterval(10).containerCount(containerCount).build();
// Update host store map.
Map<Host, Set<Integer>> hostContainerMap = HostMonitorConfigImpl.getHostContainerMap(host, controllerPort, containerCount);
// Create ZK based host store.
HostControllerStore hostStore = HostStoreFactory.createStore(hostMonitorConfig, storeClient);
CompletableFuture<Void> latch1 = new CompletableFuture<>();
CompletableFuture<Void> latch2 = new CompletableFuture<>();
((ZKHostStore) hostStore).addListener(() -> {
// wait for the second operation to complete (related to updateHostContainersMap()).
if (latch1.isDone()) {
latch2.complete(null);
}
latch1.complete(null);
});
hostStore.updateHostContainersMap(hostContainerMap);
latch1.join();
latch2.join();
validateStore(hostStore);
// verify that a new hostStore is initialized with map set by previous host store.
HostControllerStore hostStore2 = HostStoreFactory.createStore(hostMonitorConfig, storeClient);
Map<Host, Set<Integer>> map = hostStore2.getHostContainersMap();
assertEquals(hostContainerMap, map);
}
use of io.pravega.controller.store.client.ZKClientConfig in project pravega by pravega.
the class ZkBasedControllerServiceMainTest method setup.
@Override
public void setup() throws Exception {
zkServer = new TestingServerStarter().start();
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkServer.getConnectString()).initialSleepInterval(500).maxRetries(1).sessionTimeoutMs(1000).namespace("pravega/" + UUID.randomUUID()).build();
storeClientConfig = getStoreConfig(zkClientConfig);
}
use of io.pravega.controller.store.client.ZKClientConfig in project pravega by pravega.
the class ZKControllerServiceStarterTest method setup.
@Override
public void setup() {
try {
zkServer = new TestingServerStarter().start();
} catch (Exception e) {
log.error("Error starting test zk server");
Assert.fail("Error starting test zk server");
}
ZKClientConfig zkClientConfig = ZKClientConfigImpl.builder().connectionString(zkServer.getConnectString()).initialSleepInterval(500).maxRetries(10).namespace("pravega/" + UUID.randomUUID()).sessionTimeoutMs(10 * 1000).build();
storeClientConfig = StoreClientConfigImpl.withZKClient(zkClientConfig);
storeClient = StoreClientFactory.createStoreClient(storeClientConfig);
Assert.assertNotNull(storeClient);
}
Aggregations