コード例 #1
0
ファイル: repo_local.go プロジェクト: hanslovsky/dvid
// Create creates a new local key-value store and if it is designated for
// metadata storage (metadata = true), also stores a blank RepoManager
// into the newly created key-value store.  Any preexisting data at the
// path is retained.
func Create(path string, metadata bool, config dvid.Config) error {
	// Make the local key value store
	create := true
	kvEngine, err := local.NewKeyValueStore(path, create, config)
	if err != nil {
		return err
	}

	// Put a blank RepoManager onto the key value store.
	if err = InitMetadata(kvEngine); err != nil {
		return err
	}
	return nil
}
コード例 #2
0
ファイル: test_local.go プロジェクト: hanslovsky/dvid
// CloseReopenStore forces close of the underlying storage engine and then reopening
// the datastore.  Useful for testing metadata persistence.
func CloseReopenStore() {
	mu.Lock()
	defer mu.Unlock()
	dvid.BlockOnActiveCgo()
	if engine == nil {
		log.Fatalf("Attempted to close and reopen non-existant engine!")
	}
	engine.Close()

	var err error
	create := false
	engine, err = local.NewKeyValueStore(dbpath, create, dvid.Config{})
	if err != nil {
		log.Fatalf("Error reopening test db at %s: %v\n", dbpath, err)
	}
	if err = storage.Initialize(engine, "testdb"); err != nil {
		log.Fatalf("CloseReopenStore: bad storage.Initialize(): %v\n", err)
	}
	if err = datastore.Initialize(); err != nil {
		log.Fatalf("CloseReopenStore: can't initialize datastore management: %v\n", err)
	}
}