@ -41,7 +41,8 @@ type EcVolume struct {
ecjFileAccessLock sync . Mutex
ecjFileAccessLock sync . Mutex
diskType types . DiskType
diskType types . DiskType
datFileSize int64
datFileSize int64
ExpireAtSec uint64 //ec volume destroy time, calculated from the ec volume was created
ExpireAtSec uint64 //ec volume destroy time, calculated from the ec volume was created
ECContext * ECContext // EC encoding parameters
}
}
func NewEcVolume ( diskType types . DiskType , dir string , dirIdx string , collection string , vid needle . VolumeId ) ( ev * EcVolume , err error ) {
func NewEcVolume ( diskType types . DiskType , dir string , dirIdx string , collection string , vid needle . VolumeId ) ( ev * EcVolume , err error ) {
@ -78,6 +79,9 @@ func NewEcVolume(diskType types.DiskType, dir string, dirIdx string, collection
volume_info . SaveVolumeInfo ( dataBaseFileName + ".vif" , & volume_server_pb . VolumeInfo { Version : uint32 ( ev . Version ) } )
volume_info . SaveVolumeInfo ( dataBaseFileName + ".vif" , & volume_server_pb . VolumeInfo { Version : uint32 ( ev . Version ) } )
}
}
// Initialize EC context with default configuration (Phase 1: always 10+4)
ev . ECContext = NewDefaultECContext ( collection , vid )
ev . ShardLocations = make ( map [ ShardId ] [ ] pb . ServerAddress )
ev . ShardLocations = make ( map [ ShardId ] [ ] pb . ServerAddress )
return
return
@ -260,7 +264,7 @@ func (ev *EcVolume) LocateEcShardNeedleInterval(version needle.Version, offset i
if ev . datFileSize > 0 {
if ev . datFileSize > 0 {
// To get the correct LargeBlockRowsCount
// To get the correct LargeBlockRowsCount
// use datFileSize to calculate the shardSize to match the EC encoding logic.
// use datFileSize to calculate the shardSize to match the EC encoding logic.
shardSize = ev . datFileSize / DataShardsCount
shardSize = ev . datFileSize / int64 ( ev . ECContext . DataShards )
}
}
// calculate the locations in the ec shards
// calculate the locations in the ec shards
intervals = LocateData ( ErasureCodingLargeBlockSize , ErasureCodingSmallBlockSize , shardSize , offset , types . Size ( needle . GetActualSize ( size , version ) ) )
intervals = LocateData ( ErasureCodingLargeBlockSize , ErasureCodingSmallBlockSize , shardSize , offset , types . Size ( needle . GetActualSize ( size , version ) ) )