From 39eb204c6b77ebf123996009dd8f8727defca5ca Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 27 Nov 2025 09:57:22 -0800 Subject: [PATCH] Add replication configuration documentation for Java client and HDFS client --- Hadoop-Compatible-File-System.md | 29 +++++++++++++++++++++++++++++ SeaweedFS-Java-Client.md | 27 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/Hadoop-Compatible-File-System.md b/Hadoop-Compatible-File-System.md index fb2c5d8..ddcb776 100644 --- a/Hadoop-Compatible-File-System.md +++ b/Hadoop-Compatible-File-System.md @@ -81,7 +81,36 @@ Both reads and writes are working fine. direct + + fs.seaweed.replication + 002 + + +# 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 + + fs.seaweed.replication + 002 + +``` + +You can also set replication programmatically when creating files, though this is less common for HDFS-compatible usage. ``` # Deploy the SeaweedFS HDFS client jar ``` diff --git a/SeaweedFS-Java-Client.md b/SeaweedFS-Java-Client.md index 73a7c1b..3defdb0 100644 --- a/SeaweedFS-Java-Client.md +++ b/SeaweedFS-Java-Client.md @@ -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.