Search in sources :

Example 1 with ZKClientConfig

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);
}
Also used : ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) TestingServerStarter(io.pravega.test.common.TestingServerStarter) IOException(java.io.IOException)

Example 2 with 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();
        }
    }
}
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 3 with ZKClientConfig

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);
}
Also used : TestingServer(org.apache.curator.test.TestingServer) StoreClient(io.pravega.controller.store.client.StoreClient) Set(java.util.Set) TestingServerStarter(io.pravega.test.common.TestingServerStarter) Host(io.pravega.common.cluster.Host) Cleanup(lombok.Cleanup) HostMonitorConfig(io.pravega.controller.store.host.HostMonitorConfig) CompletableFuture(java.util.concurrent.CompletableFuture) ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) StoreClientConfig(io.pravega.controller.store.client.StoreClientConfig) ZKHostStore(io.pravega.controller.store.host.ZKHostStore) Test(org.junit.Test)

Example 4 with ZKClientConfig

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);
}
Also used : ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) TestingServerStarter(io.pravega.test.common.TestingServerStarter)

Example 5 with 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);
}
Also used : ZKClientConfig(io.pravega.controller.store.client.ZKClientConfig) TestingServerStarter(io.pravega.test.common.TestingServerStarter) IOException(java.io.IOException)

Aggregations

ZKClientConfig (io.pravega.controller.store.client.ZKClientConfig)9 TestingServerStarter (io.pravega.test.common.TestingServerStarter)5 StoreClientConfig (io.pravega.controller.store.client.StoreClientConfig)3 HostMonitorConfig (io.pravega.controller.store.host.HostMonitorConfig)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 ControllerEventProcessorConfig (io.pravega.controller.server.eventProcessor.ControllerEventProcessorConfig)2 GRPCServerConfig (io.pravega.controller.server.rpc.grpc.GRPCServerConfig)2 TimeoutServiceConfig (io.pravega.controller.timeout.TimeoutServiceConfig)2 RESTServerConfig (io.pravega.shared.rest.RESTServerConfig)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 Host (io.pravega.common.cluster.Host)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