[#153] selector: Add VU synchronization in 'Oneshot' mode
All checks were successful
All checks were successful
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
f539da7d89
commit
104aa5ef96
2 changed files with 10 additions and 1 deletions
|
@ -3,6 +3,7 @@ package registry
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
@ -23,6 +24,8 @@ type ObjSelector struct {
|
||||||
filter *ObjFilter
|
filter *ObjFilter
|
||||||
cacheSize int
|
cacheSize int
|
||||||
kind SelectorKind
|
kind SelectorKind
|
||||||
|
// Sync synchronizes VU used for deletion.
|
||||||
|
Sync sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// objectSelectCache is the default maximum size of a batch to select from DB.
|
// objectSelectCache is the default maximum size of a batch to select from DB.
|
||||||
|
@ -44,8 +47,8 @@ func NewObjSelector(registry *ObjRegistry, selectionSize int, kind SelectorKind,
|
||||||
objChan: make(chan *ObjectInfo, selectionSize*2),
|
objChan: make(chan *ObjectInfo, selectionSize*2),
|
||||||
cacheSize: selectionSize,
|
cacheSize: selectionSize,
|
||||||
kind: kind,
|
kind: kind,
|
||||||
|
Sync: sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
go objSelector.selectLoop()
|
go objSelector.selectLoop()
|
||||||
|
|
||||||
return objSelector
|
return objSelector
|
||||||
|
|
|
@ -132,6 +132,10 @@ export function setup() {
|
||||||
const start_timestamp = Date.now()
|
const start_timestamp = Date.now()
|
||||||
console.log(
|
console.log(
|
||||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||||
|
|
||||||
|
if (delete_vu_count > 0){
|
||||||
|
obj_to_delete_selector.sync.add(delete_vu_count)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function teardown(data) {
|
export function teardown(data) {
|
||||||
|
@ -204,6 +208,8 @@ export function obj_delete() {
|
||||||
const obj = obj_to_delete_selector.nextObject();
|
const obj = obj_to_delete_selector.nextObject();
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
if (obj_to_delete_exit_on_null) {
|
if (obj_to_delete_exit_on_null) {
|
||||||
|
obj_to_delete_selector.sync.done()
|
||||||
|
obj_to_delete_selector.sync.wait()
|
||||||
exec.test.abort("No more objects to select");
|
exec.test.abort("No more objects to select");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue