From 1e3697e17ae7d18e4095f509a9441c12136c9c91 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 28 Jul 2023 12:48:07 -0700 Subject: [PATCH 1/2] fix replica assignment example --- .../docs/architecture/replica-assignment.md | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/content/docs/architecture/replica-assignment.md b/content/docs/architecture/replica-assignment.md index ca90475b..c78cb81f 100644 --- a/content/docs/architecture/replica-assignment.md +++ b/content/docs/architecture/replica-assignment.md @@ -31,9 +31,9 @@ The algorithm uses a **round-robin**, **gap-enabled** distribution assignment. In a cluster with **4** SPUs, a topic created with: -| Replicas | Partitions | -|:------------:|:-------------:| -| **3** | **15** | +| Replicas | Partitions | +| :------: | :--------: | +| **3** | **15** | The algorithm generates the following replica distribution: @@ -110,9 +110,9 @@ The algorithm has the following 3 stages: On a cluster with **12** SPUs evenly distributed across **4** racks, a topic created with: -| Replicas | Partitions | -|:------------:|:-------------:| -| **4** | **12** | +| Replicas | Partitions | +| :------: | :--------: | +| **4** | **12** | The **3-stage** algorithm generates the following distribution: @@ -164,9 +164,9 @@ On a cluster with **6** SPUs unevenly distributed across **3** racks: For a topic created with: -| Replicas | Partitions | -|:------------:|:-------------:| -| **3** | **6** | +| Replicas | Partitions | +| :------: | :--------: | +| **3** | **6** | The **3-stage** algorithm generates the following distribution: @@ -219,17 +219,15 @@ _Validate-only_ flag is available to verify a replica assignment file without ap **Replica assignment file** defines a **replica map** in JSON format. A replica map with 2 partitions and 3 replicas is defined as follows: ```json -{ - "partitions": [{ - "id": 0, - "replicas": [0, 1, 2] - }, - { - "id": 1, - "replicas": [1, 2, 0] - } - ] +[{ + "id": 0, + "replicas": [0, 1, 2] +}, +{ + "id": 1, + "replicas": [1, 2, 0] } +] ``` The **replica map** definition meet the following criteria: From a56c6619580bf0bea12b4e83b536d7d56a9fc7d5 Mon Sep 17 00:00:00 2001 From: Sehyo Chang Date: Fri, 28 Jul 2023 13:22:04 -0700 Subject: [PATCH 2/2] add replica assignment section --- content/cli/commands/topic.md | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/content/cli/commands/topic.md b/content/cli/commands/topic.md index e3fd6add..51b55fe4 100644 --- a/content/cli/commands/topic.md +++ b/content/cli/commands/topic.md @@ -64,6 +64,47 @@ topic "my-topic" created In this example, the topic `my-topic` will be created with compression type `gzip`. +### replication assignment + +By default, Fluvio will automatically assign replicas to SPUs. However, you can manually assign replicas to SPUs by using the `--replica-assignment` flag. + +Please refer to following [replica]({{}}) sections for detail of replica assignment. + +Note that in order to replication assignment to work, you need to have at least 2 SPUs in your cluster. + +Example usage: + +In this example, we assign first replica to SPU 0, second replica to SPU 1. +First we create replica assignment file `replica.json`. +```json +[ + { + "id": 0, + "replicas": [ + 0, + 1 + ] + } +] +``` +The `replicas` fields correspond to the SPU ids. You can get SPU ids by running `fluvio cluster spu list`. + +Then we create topic with replica assignment file. +```bash +$ fluvio topic create my-topic --replica-assignment replica.json +topic "my-topic" created +``` + +Use partition commands to show that topic has been created with replica assignment. + +```bash + + $ fluvio partition list + TOPIC PARTITION LEADER REPLICAS RESOLUTION SIZE HW LEO LRS FOLLOWER OFFSETS + my-topic 0 0 [1] Online 0 B 0 0 0 0 [ReplicaStatus { spu: 1, hw: -1, leo: -1 }] + +``` + ## `fluvio topic list` This command shows you all the existing topics in your cluster, as well as some basic