Add replication configuration documentation for Java client and HDFS client

Chris Lu committed 2025-11-27 09:57:22 -08:00
1 parent b5fbcde15e
commit 39eb204c6b
2 files changed
+56

No files matched your search

+29
@@ -81,7 +81,36 @@ Both reads and writes are working fine.
<!-- [direct|publicUrl|filerProxy] -->
<value>direct</value>
</property>
<property>
<name>fs.seaweed.replication</name>
<value>002</value>
</property>
</configuration>
# Replication Configuration
SeaweedFS supports configurable replication for data durability. You can set the replication level using the `fs.seaweed.replication` property in `core-site.xml`.
SeaweedFS uses a 3-digit replication string format: (data center)(rack)(volume server) copies.
**Examples:**
- `000` or empty: Use default replication (usually 1 copy)
- `001`: 1 additional copy (2 total copies)
- `002`: 2 additional copies (3 total copies)
- `010`: 1 data center + 1 rack copy (3 total copies)
- `020`: 2 rack copies (3 total copies)
If `fs.seaweed.replication` is not set, SeaweedFS will use the HDFS `dfs.replication` parameter and convert it to the SeaweedFS format.
**Configuration:**
```xml
<property>
<name>fs.seaweed.replication</name>
<value>002</value>
</property>
```
You can also set replication programmatically when creating files, though this is less common for HDFS-compatible usage.
```
# Deploy the SeaweedFS HDFS client jar
```
+27
@@ -61,6 +61,33 @@ When starting filer, `weed filer -port=8888`, the port 8888 is default http port
// next, you can use seaweedOutputStream as a normal OutputStream
```
## Write File with Replication
You can specify replication level when writing files. SeaweedFS uses a replication string format: a 3-digit string representing (data center)(rack)(volume server) copies.
```
FilerClient filerClient = new FilerClient("localhost", 18888);
// Create output stream with replication (e.g., "001" = 1 copy, "002" = 2 copies, "010" = 1 data center + 1 rack copy, etc.)
SeaweedOutputStream seaweedOutputStream = new SeaweedOutputStream(filerClient, "/test/"+filename, "002");
// next, you can use seaweedOutputStream as a normal OutputStream
```
Or set replication after creation:
```
FilerClient filerClient = new FilerClient("localhost", 18888);
SeaweedOutputStream seaweedOutputStream = new SeaweedOutputStream(filerClient, "/test/"+filename);
seaweedOutputStream.setReplication("002"); // Set 2 copies replication
// next, you can use seaweedOutputStream as a normal OutputStream
```
Common replication values:
- `"000"` or `""` (empty string): Use default replication (usually 1 copy)
- `"001"`: 1 additional copy (2 total)
- `"002"`: 2 additional copies (3 total)
- `"010"`: 1 data center + 1 rack copy (3 total)
- `"020"`: 2 rack copies (3 total)
## Watch file changes
This API streams meta data changes.