Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
5454a41c
Commit
5454a41c
authored
Jun 27, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c2e53f66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
4 deletions
+62
-4
wcfs/wcfs.go
wcfs/wcfs.go
+34
-3
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+28
-1
No files found.
wcfs/wcfs.go
View file @
5454a41c
...
...
@@ -242,15 +242,35 @@ package main
// tell the kernel it is fully responsible for invalidating pagecache.
import
(
"context"
"flag"
"log"
"os"
"github.com/hanwen/go-fuse/fuse/nodefs"
"lab.nexedi.com/kirr/neo/go/zodb"
)
// option to prevent starting if wcfs was already started ?
// option to automatically exit/unmount if there are no requests for some t (UC: autospawned from join)
// BigFileRoot represents "/bigfile"
type
BigFileRoot
struct
{
nodefs
.
Node
zstor
zodb
.
IStorage
}
func
NewBigFileRoot
(
zstor
zodb
.
IStorage
)
*
BigFileRoot
{
return
&
BigFileRoot
{
Node
:
nodefs
.
NewDefaultNode
(),
zstor
:
zstor
,
}
}
// XXX option to prevent starting if wcfs was already started ?
// XXX option to automatically exit/unmount if there are no requests for some t
// (UC: autospawned from join)
func
main
()
{
log
.
SetPrefix
(
"wcfs: "
)
...
...
@@ -263,6 +283,16 @@ func main() {
zurl
:=
flag
.
Args
()[
0
]
mntpt
:=
flag
.
Args
()[
1
]
// open zodb storage
ctx
:=
context
.
Background
()
// XXX + timeout?
zstor
,
err
:=
zodb
.
OpenStorage
(
ctx
,
zurl
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
defer
zstor
.
Close
()
// mount root
opts
:=
nodefs
.
NewOptions
()
opts
.
Debug
=
*
debug
...
...
@@ -275,7 +305,8 @@ func main() {
// add entries to /
mkfile
(
root
,
".wcfs"
,
NewStaticFile
([]
byte
(
zurl
)))
//mkdir(root, "bigfile", ...
)
mkdir
(
root
,
"bigfile"
,
NewBigFileRoot
(
zstor
)
)
// serve client requests
server
.
Serve
()
// XXX Serve returns no eror
}
wcfs/wcfs_test.py
View file @
5454a41c
...
...
@@ -19,8 +19,10 @@
# See https://www.nexedi.com/licensing for rationale and options.
from
wendelin.lib.testing
import
getTestDB
from
wendelin.bigfile.file_zodb
import
ZBigFile
from
wendelin.bigfile.tests.test_filezodb
import
blksize
from
wendelin
import
wcfs
from
golang
import
go
,
cha
n
import
transactio
n
import
os
,
os
.
path
,
subprocess
from
pytest
import
raises
...
...
@@ -77,6 +79,7 @@ def test_join():
wc
=
wcfs
.
_start
(
zurl
)
assert
wc
.
mountpoint
==
testmntpt
assert
readfile
(
wc
.
mountpoint
+
"/.wcfs"
)
==
zurl
assert
os
.
path
.
isdir
(
wc
.
mountpoint
+
"/bigfile"
)
wc2
=
wcfs
.
join
(
zurl
,
autostart
=
False
)
assert
wc2
.
mountpoint
==
wc
.
mountpoint
...
...
@@ -93,5 +96,29 @@ def test_join_autostart():
wc
=
wcfs
.
join
(
zurl
,
autostart
=
True
)
assert
wc
.
mountpoint
==
testmntpt
assert
readfile
(
wc
.
mountpoint
+
"/.wcfs"
)
==
zurl
assert
os
.
path
.
isdir
(
wc
.
mountpoint
+
"/bigfile"
)
wc
.
close
()
# XXX parametrize zblk0, zblk1
# XXX select !wcfs mode so that we prepare data through !wcfs path.
def
_test_bigfile_empty
():
root
=
testdb
.
dbopen
()
root
[
'zfile'
]
=
f
=
ZBigFile
(
blksize
)
transaction
.
commit
()
root
[
'aaa'
]
=
'bbb'
transaction
.
commit
()
wc
=
wcfs
.
join
(
testzurl
,
autostart
=
True
)
os
.
mkdir
(
"%s/bigfile/%s"
%
(
wc
.
mountpoint
,
f
.
_p_oid
.
encode
(
'hex'
)))
# XXX size(head/data) = 0
# XXX mtime(head/data) ~= last txn that changed bigdile
# XXX head/at = last txn of whole db
# XXX non-BigFile - rejected
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment