Standard Implementation
This page describes the standard implementation of the TDBCluster interface for TDB 2.x.
Class Diagram
«interface» AutoCloseable close(): void Builder withMigrationsDirectory(Path): Builder withShardCount(int): Builder withStartupTimeout(Duration): Builder withRouterCount(int): Builder withTDB2Configuration(Tarantool3Configuration): Builder build(): TDB2ClusterImpl withReplicaCount(int): Builder «interface» Startable stop(): void getDependencies(): Set<Startable> close(): void start(): void TDB2ClusterImpl tcmContainer(): TCMContainer storages(): Map<String, TarantoolContainer<?>> nodes(): Map<String, TarantoolContainer<?>> clusterName(): String start(): void routers(): Map<String, TarantoolContainer<?>> etcdContainer(): EtcdContainer stop(): void builder(String): Builder «interface» TDBCluster clusterName(): String tcmContainer(): TCMContainer storages(): Map<String, TarantoolContainer<?>> etcdContainer(): EtcdContainer routers(): Map<String, TarantoolContainer<?>> restart(long, TimeUnit): void nodes(): Map<String, TarantoolContainer<?>> «interface» AutoCloseable close(): void Builder withMigrationsDirectory(Path): Builder withShardCount(int): Builder withStartupTimeout(Duration): Builder withRouterCount(int): Builder withTDB2Configuration(Tarantool3Configuration): Builder build(): TDB2ClusterImpl withReplicaCount(int): Builder «interface» Startable stop(): void getDependencies(): Set<Startable> close(): void start(): void TDB2ClusterImpl tcmContainer(): TCMContainer storages(): Map<String, TarantoolContainer<?>> nodes(): Map<String, TarantoolContainer<?>> clusterName(): String start(): void routers(): Map<String, TarantoolContainer<?>> etcdContainer(): EtcdContainer stop(): void builder(String): Builder «interface» TDBCluster clusterName(): String tcmContainer(): TCMContainer storages(): Map<String, TarantoolContainer<?>> etcdContainer(): EtcdContainer routers(): Map<String, TarantoolContainer<?>> restart(long, TimeUnit): void nodes(): Map<String, TarantoolContainer<?>>
The TDB2ClusterImpl class allows you to create an object managing the lifecycle of a TDB 2.x cluster, satisfying the contract of TDBCluster.
Implementation Description
Cluster Configuration
The implementation follows the following algorithm when configuring the cluster:
Calling TDB2ClusterImpl::start() Create a temporary directory for the TDB2ClusterImpl instance Generate configuration based on the passed routerCount , shardCount , replicaCount Write the configuration file based on the configuration object to a temporary directory Create and configure etcd , TCM containers Throw an exception Publish the cluster configuration via TCM to etcd Start the containers with Tarantool nodes Initialize the cluster Apply migrations Complete startup Configuration passed via Tarantool3Configuration ? no yes Successfully started? no yes Configuration transferred? no yes Containers started? no yes Cluster initialized? no yes Migrations applied? no yes Calling TDB2ClusterImpl::start() Create a temporary directory for the TDB2ClusterImpl instance Generate configuration based on the passed routerCount , shardCount , replicaCount Write the configuration file based on the configuration object to a temporary directory Create and configure etcd , TCM containers Throw an exception Publish the cluster configuration via TCM to etcd Start the containers with Tarantool nodes Initialize the cluster Apply migrations Complete startup Configuration passed via Tarantool3Configuration ? no yes Successfully started? no yes Configuration transferred? no yes Containers started? no yes Cluster initialized? no yes Migrations applied? no yes
Ensuring Mounted Data Preservation
According to the TDBCluster contract, when calling the TDBCluster::restart(...) method, the mounted data must be preserved. TDB2ClusterImpl implements this mechanism by using the TarantoolContainer::stopWithSafeMount() contract:
Calling TDB2ClusterImpl::restart(...) TDB2ClusterImpl::restart Call Tarantool3Container::stopWithSafeMount() for each Tarantool node in the cluster Wait for the specified delay Call Tarantool3Container::start() for each Tarantool node in the cluster Calling TDB2ClusterImpl::restart(...) TDB2ClusterImpl::restart Call Tarantool3Container::stopWithSafeMount() for each Tarantool node in the cluster Wait for the specified delay Call Tarantool3Container::start() for each Tarantool node in the cluster
Mounted directories are deleted only when calling the TDB2ClusterImpl::stop() method. Container configuration occurs only once during the first call to TDB2ClusterImpl::start().
Port Binding
External port binding to cluster components (containers) occurs at the TDB2ClusterImpl instance startup stage.