|
|
@ -2,6 +2,7 @@ package donut |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
@ -13,9 +14,6 @@ import ( |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"encoding/gob" |
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/minio-io/minio/pkg/encoding/erasure" |
|
|
|
"github.com/minio-io/minio/pkg/encoding/erasure" |
|
|
|
"github.com/minio-io/minio/pkg/utils/split" |
|
|
|
"github.com/minio-io/minio/pkg/utils/split" |
|
|
|
) |
|
|
|
) |
|
|
@ -127,13 +125,9 @@ func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, wri |
|
|
|
for i := 0; i < totalChunks; i++ { |
|
|
|
for i := 0; i < totalChunks; i++ { |
|
|
|
encodedBytes := make([][]byte, 16) |
|
|
|
encodedBytes := make([][]byte, 16) |
|
|
|
for i, reader := range readers { |
|
|
|
for i, reader := range readers { |
|
|
|
var bytesArray []byte |
|
|
|
var bytesBuffer bytes.Buffer |
|
|
|
decoder := gob.NewDecoder(reader) |
|
|
|
io.Copy(&bytesBuffer, reader) |
|
|
|
err := decoder.Decode(&bytesArray) |
|
|
|
encodedBytes[i] = bytesBuffer.Bytes() |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
encodedBytes[i] = bytesArray |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
curBlockSize := totalLeft |
|
|
|
curBlockSize := totalLeft |
|
|
|
if blockSize < totalLeft { |
|
|
|
if blockSize < totalLeft { |
|
|
@ -185,10 +179,7 @@ func erasureGoroutine(r *io.PipeReader, eWriter erasureWriter, isClosed chan<- b |
|
|
|
totalLength = totalLength + len(chunk.Data) |
|
|
|
totalLength = totalLength + len(chunk.Data) |
|
|
|
encodedBlocks, _ := encoder.Encode(chunk.Data) |
|
|
|
encodedBlocks, _ := encoder.Encode(chunk.Data) |
|
|
|
for blockIndex, block := range encodedBlocks { |
|
|
|
for blockIndex, block := range encodedBlocks { |
|
|
|
var byteBuffer bytes.Buffer |
|
|
|
io.Copy(eWriter.writers[blockIndex], bytes.NewBuffer(block)) |
|
|
|
gobEncoder := gob.NewEncoder(&byteBuffer) |
|
|
|
|
|
|
|
gobEncoder.Encode(block) |
|
|
|
|
|
|
|
io.Copy(eWriter.writers[blockIndex], &byteBuffer) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
chunkCount = chunkCount + 1 |
|
|
|
chunkCount = chunkCount + 1 |
|
|
|