Browse Source

fix(ec): use constants for default EC shard counts and resolve compiler error

rust-volume-server
Chris Lu 2 days ago
parent
commit
6efb948b44
  1. 4
      seaweed-volume/src/storage/erasure_coding/ec_volume.rs
  2. 24
      seaweed-volume/src/storage/volume.rs

4
seaweed-volume/src/storage/erasure_coding/ec_volume.rs

@ -28,8 +28,8 @@ pub struct EcVolume {
}
pub fn read_ec_shard_config(dir: &str, volume_id: VolumeId) -> (u32, u32) {
let mut data_shards = 10;
let mut parity_shards = 4;
let mut data_shards = crate::storage::erasure_coding::ec_shard::DATA_SHARDS_COUNT as u32;
let mut parity_shards = crate::storage::erasure_coding::ec_shard::PARITY_SHARDS_COUNT as u32;
let vif_path = format!("{}/{}.vif", dir, volume_id.0);
if let Ok(vif_content) = std::fs::read_to_string(&vif_path) {
if let Ok(vif_info) = serde_json::from_str::<crate::storage::volume::VifVolumeInfo>(&vif_content) {

24
seaweed-volume/src/storage/volume.rs

@ -173,13 +173,15 @@ pub struct VifEcShardConfig {
pub struct VifVolumeInfo {
#[serde(default)]
pub files: Vec<VifRemoteFile>,
#[serde(default)]
pub version: u32,
pub collection: String,
pub replica_placement: u32,
pub ttl: String,
#[serde(default, rename = "datFileSize")]
pub dat_file_size: u64,
#[serde(default, rename = "expireAtSec")]
#[serde(default)]
pub replication: String,
#[serde(default, rename = "bytesOffset")]
pub bytes_offset: u32,
#[serde(default, rename = "datFileSize", with = "string_or_i64")]
pub dat_file_size: i64,
#[serde(default, rename = "expireAtSec", with = "string_or_u64")]
pub expire_at_sec: u64,
#[serde(default, rename = "readOnly")]
pub read_only: bool,
@ -205,9 +207,8 @@ impl VifVolumeInfo {
})
.collect(),
version: pb.version,
collection: pb.collection.clone(),
replica_placement: pb.replica_placement,
ttl: pb.ttl.clone(),
replication: pb.replication.clone(),
bytes_offset: pb.bytes_offset,
dat_file_size: pb.dat_file_size,
expire_at_sec: pb.expire_at_sec,
read_only: pb.read_only,
@ -235,9 +236,8 @@ impl VifVolumeInfo {
})
.collect(),
version: self.version,
collection: self.collection.clone(),
replica_placement: self.replica_placement,
ttl: self.ttl.clone(),
replication: self.replication.clone(),
bytes_offset: self.bytes_offset,
dat_file_size: self.dat_file_size,
expire_at_sec: self.expire_at_sec,
read_only: self.read_only,

Loading…
Cancel
Save