Skip to content

Commit

Permalink
Merge pull request #79 from picodata/78-fix-replicasets
Browse files Browse the repository at this point in the history
fix: replicasets with replication_factor = 1
  • Loading branch information
DmitryTravyan authored Nov 17, 2022
2 parents cd43d00 + a52d0fa commit 794364d
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 162 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "genin"
version = "0.4.4"
version = "0.4.5"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ sudo yum install -y genin
2. If you want to install `rpm` packages directly without adding our repository.
```shell
# RHEL 8.x, CentOS 8.x, Rockylinux 8.x, recent Fedora version
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.4-1.el8.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.5-1.el8.x86_64.rpm
# RHEL 7.x, CentOS 7.x
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.4-1.el7.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.5-1.el7.x86_64.rpm
```
> **Note:** please don't forget to pick the right package for your OS version.
#### Debian, Ubuntu
We provide the `deb` Genin package for `debian`-based Linux distributions including the Ubuntu family. Use the following command to download and install the package:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.4.amd64.deb && sudo dpkg -i genin-0.4.4.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.5.amd64.deb && sudo dpkg -i genin-0.4.5.amd64.deb
```

#### MacOSX
Expand All @@ -92,8 +92,8 @@ brew install genin
Use the following command to grab and install Genin in macOS (10.10+) wihtout
homebrew:
```shell
curl -L https://binary.picodata.io/repository/raw/genin/apple/genin-0.4.4-darwin-amd64.zip -o genin-0.4.4-darwin-amd64.zip
unzip genin-0.4.4-darwin-amd64.zip -d ~/bin/
curl -L https://binary.picodata.io/repository/raw/genin/apple/genin-0.4.5-darwin-amd64.zip -o genin-0.4.5-darwin-amd64.zip
unzip genin-0.4.5-darwin-amd64.zip -d ~/bin/
```
> **Note:** The application can then be found under the `~/bin` directory.
> Make sure the directory is in your `$PATH`.
Expand All @@ -102,8 +102,8 @@ unzip genin-0.4.4-darwin-amd64.zip -d ~/bin/
#### Windows
Use the following command to grab and install Genin in Windows 7 64 bit or newer:
```shell
curl.exe -L https://binary.picodata.io/repository/raw/genin/windows/genin-0.4.4-darwin-amd64.zip -o genin-0.4.4-windows-amd64.zip
unzip.exe genin-0.4.4-windows-amd64.zip -d %HOME%/.cargo/bin/
curl.exe -L https://binary.picodata.io/repository/raw/genin/windows/genin-0.4.5-darwin-amd64.zip -o genin-0.4.5-windows-amd64.zip
unzip.exe genin-0.4.5-windows-amd64.zip -d %HOME%/.cargo/bin/
```
> **Note:** The application can then be found under the `.cargo/bin` folder inside
> your user profile folder. Make sure it is in your `%PATH%`.
Expand Down
22 changes: 11 additions & 11 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ Genin уже заранее скомпилирован под разные ар

Универсальный исполняемый файл:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.4-x86_64-musl.tar.gz
tar -xvf genin-0.4.4-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.5-x86_64-musl.tar.gz
tar -xvf genin-0.4.5-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
```
---
#### RHEL, CentOS, Rockylinux, Fedora
Expand Down Expand Up @@ -82,11 +82,11 @@ sudo yum install -y genin
2. Так же вы можете установить пакет `rpm` напрямую без добавления нашего репозитория.
RHEL 8.x, CentOS 8.x, Rockylinux 8.x, recent Fedora version
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.4-1.el8.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.5-1.el8.x86_64.rpm
```
RHEL 7.x, CentOS 7.x
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.4-1.el7.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.5-1.el7.x86_64.rpm
```
> **Note:** будьте внимательны, так как при выборе не правильной версии ос могут быть ошибки
> при установке `rpm`
Expand All @@ -113,7 +113,7 @@ sudo apt install -y genin

2. Загрузкой и установкой пакета напрямую:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.4.amd64.deb && sudo dpkg -i genin-0.4.4.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.5.amd64.deb && sudo dpkg -i genin-0.4.5.amd64.deb
```

---
Expand All @@ -138,7 +138,7 @@ sudo apt install -y genin

2. Загрузкой и установкой пакета напрямую:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.4.amd64.deb && sudo dpkg -i genin-0.4.4.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.5.amd64.deb && sudo dpkg -i genin-0.4.5.amd64.deb
```

---
Expand All @@ -158,8 +158,8 @@ brew install genin
Для установки без помощи homebrew используйте следующие команды для загрузки и установки
Genin на macOS (10.10+):
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/osx/genin-0.4.4-x86_64-macosx.tar.gz
unzip genin-0.4.4-darwin-amd64.zip -d ~/bin/
curl -sLO https://binary.picodata.io/repository/raw/genin/osx/genin-0.4.5-x86_64-macosx.tar.gz
unzip genin-0.4.5-darwin-amd64.zip -d ~/bin/
```

---
Expand All @@ -173,8 +173,8 @@ unzip genin-0.4.4-darwin-amd64.zip -d ~/bin/
Используйте следующие команды для скачивания и установки Genin на операционных системах
Windows 7 64 и новее.
```shell
curl.exe -sLO https://binary.picodata.io/repository/raw/genin/win/genin-0.4.4-win64.zip
unzip.exe genin-0.4.4-win64.zip -d %HOME%/.cargo/bin/
curl.exe -sLO https://binary.picodata.io/repository/raw/genin/win/genin-0.4.5-win64.zip
unzip.exe genin-0.4.5-win64.zip -d %HOME%/.cargo/bin/
```
> **Note:** Genin будет распакован в директорию `.cargo/bin` которая находится в домашнем
> каталоге важего пользователя. Перед использованием приложения пожалуйста удостоверьтесь
Expand All @@ -184,7 +184,7 @@ unzip.exe genin-0.4.4-win64.zip -d %HOME%/.cargo/bin/
```
genin --version
```
Если вы видите сообщение `genin 0.4.4` значит установка прошла успешно.
Если вы видите сообщение `genin 0.4.5` значит установка прошла успешно.

---
## Руководство по использованию
Expand Down
41 changes: 0 additions & 41 deletions cluster.genin.yaml

This file was deleted.

88 changes: 0 additions & 88 deletions inventory.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions src/task/cluster/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@ impl Name {
}
}

pub fn as_replicaset_name(&self) -> Self {
if self.len() == 3 {
self.get_parent_name().clone_with_index("replicaset")
} else {
self.clone_with_index("replicaset")
}
}

pub fn as_replicaset_alias(&self) -> Self {
if self.len() == 3 {
self.get_parent_name()
} else {
self.clone()
}
}

pub fn len(&self) -> usize {
self.childrens.len()
}
Expand Down
9 changes: 2 additions & 7 deletions src/task/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,12 @@ impl<'a> TryFrom<&'a Option<Cluster>> for Inventory {
.filter(|instance| !instance.is_stateboard())
.try_for_each(|instance| {
let entry = accum
.entry(
instance
.name
.get_parent_name()
.clone_with_index("replicaset"),
)
.entry(instance.name.as_replicaset_name())
.or_insert(Child::Replicaset {
vars: ReplicasetVars {
replicaset_alias: instance
.name
.get_parent_str()
.as_replicaset_alias()
.to_string(),
failover_priority: vec![instance.name.to_string()]
.into_iter()
Expand Down
12 changes: 6 additions & 6 deletions src/task/inventory/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ all:
listen: "10.99.16.66:5001"
password: genin-app
children:
api-replicaset:
api-1-replicaset:
vars:
replicaset_alias: api
replicaset_alias: api-1
failover_priority:
- api-1
roles:
Expand Down Expand Up @@ -227,9 +227,9 @@ all:
cache-2-2: ~
cache-2-1: ~
cache-2-3: ~
router-replicaset:
router-1-replicaset:
vars:
replicaset_alias: router
replicaset_alias: router-1
failover_priority:
- router-1
roles:
Expand All @@ -238,9 +238,9 @@ all:
weight: 10
hosts:
router-1: ~
calculator-replicaset:
calculator-1-replicaset:
vars:
replicaset_alias: calculator
replicaset_alias: calculator-1
failover_priority:
- calculator-1
roles:
Expand Down

0 comments on commit 794364d

Please sign in to comment.