-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node: Use Peapod instead of Blobovnicza tree as BlobStor sub-storage
Recently introduce Peapod component is designed to replace Blobovnicza tree. To facilitate migration to a new storage scheme, it is required to maintain compatibility with the old application configuration, while still moving to a new component. Provide `common.Copy` function which overtakes data from one sub-storage to another. On storage node startup, when Blobovnicza tree is configured for BlobStor, create new Peapod instance on the same level as Blobovnicza and migrate data into it. Filled Peapod is used as sub-storage. Signed-off-by: Leonard Lyubich <[email protected]>
- Loading branch information
1 parent
3d154bd
commit 115c649
Showing
5 changed files
with
163 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package common_test | ||
|
||
import ( | ||
"crypto/rand" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree" | ||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" | ||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/peapod" | ||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" | ||
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCopy(t *testing.T) { | ||
dir := t.TempDir() | ||
const nObjects = 100 | ||
|
||
from := blobovniczatree.NewBlobovniczaTree( | ||
blobovniczatree.WithBlobovniczaShallowWidth(2), | ||
blobovniczatree.WithBlobovniczaShallowDepth(3), | ||
blobovniczatree.WithRootPath(filepath.Join(dir, "blobovnicza")), | ||
) | ||
|
||
require.NoError(t, from.Open(false)) | ||
require.NoError(t, from.Init()) | ||
|
||
mObjs := make(map[oid.Address][]byte, nObjects) | ||
|
||
for i := 0; i < nObjects; i++ { | ||
addr := oidtest.Address() | ||
data := make([]byte, 32) | ||
rand.Read(data) | ||
mObjs[addr] = data | ||
|
||
_, err := from.Put(common.PutPrm{ | ||
Address: addr, | ||
RawData: data, | ||
}) | ||
require.NoError(t, err) | ||
} | ||
|
||
require.NoError(t, from.Close()) | ||
|
||
to := peapod.New(filepath.Join(dir, "peapod.db"), 0600) | ||
|
||
err := common.Copy(from, to) | ||
require.NoError(t, err) | ||
|
||
require.NoError(t, to.Open(true)) | ||
t.Cleanup(func() { _ = to.Close() }) | ||
|
||
_, err = to.Iterate(common.IteratePrm{ | ||
Handler: func(el common.IterationElement) error { | ||
data, ok := mObjs[el.Address] | ||
require.True(t, ok) | ||
require.Equal(t, data, el.ObjectData) | ||
return nil | ||
}, | ||
}) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters