Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
6103fd3e
Commit
6103fd3e
authored
Jul 26, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
eab0c6e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
10 deletions
+67
-10
go/zodb/storage/fs1/fs1tools/dump.go
go/zodb/storage/fs1/fs1tools/dump.go
+59
-2
go/zodb/storage/fs1/fs1tools/main.go
go/zodb/storage/fs1/fs1tools/main.go
+1
-1
go/zodb/storage/fs1/fs1tools/tail_test.go
go/zodb/storage/fs1/fs1tools/tail_test.go
+7
-7
No files found.
go/zodb/storage/fs1/fs1tools/dump.go
View file @
6103fd3e
...
...
@@ -37,6 +37,9 @@ import (
// Dumper is interface to implement various dumping modes
type
Dumper
interface
{
// DumperName defines concise name to use in error-reporting when using this dumper.
DumperName
()
string
// DumpFileHeader dumps fh to buf
DumpFileHeader
(
buf
*
xfmt
.
Buffer
,
fh
*
fs1
.
FileHeader
)
error
...
...
@@ -54,7 +57,7 @@ type Dumper interface {
// To do so it reads file header and then iterates over all transactions in the file.
// The logic to actually output information and if needed read/process data is implemented by Dumper d.
func
Dump
(
w
io
.
Writer
,
path
string
,
dir
fs1
.
IterDir
,
d
Dumper
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s:
dump"
,
path
)
// XXX ok? XXX name
?
defer
xerr
.
Contextf
(
&
err
,
"%s:
%s"
,
path
,
d
.
DumperName
())
// XXX ok
?
it
,
f
,
err
:=
fs1
.
IterateFile
(
path
,
dir
)
if
err
!=
nil
{
...
...
@@ -128,6 +131,10 @@ type DumperFsDump struct {
ntxn
int
// current transaction record #
}
func
(
d
*
DumperFsDump
)
DumperName
()
string
{
return
"fsdump"
}
func
(
d
*
DumperFsDump
)
DumpFileHeader
(
buf
*
xfmt
.
Buffer
,
fh
*
fs1
.
FileHeader
)
error
{
return
nil
}
...
...
@@ -184,7 +191,6 @@ func (d *DumperFsDump) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
return
nil
}
// DumperFsDumpVerbose implements a very verbose dumper with output identical
// to fsdump.Dumper in zodb/py originally written by Jeremy Hylton:
//
...
...
@@ -193,6 +199,10 @@ func (d *DumperFsDump) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
type
DumperFsDumpVerbose
struct
{
}
func
(
d
*
DumperFsDumpVerbose
)
DumperName
()
string
{
return
"fsdumpv"
}
func
(
d
*
DumperFsDumpVerbose
)
DumpFileHeader
(
buf
*
xfmt
.
Buffer
,
fh
*
fs1
.
FileHeader
)
error
{
for
i
:=
0
;
i
<
60
;
i
++
{
buf
.
S
(
"*"
)
...
...
@@ -254,6 +264,49 @@ func (d *DumperFsDumpVerbose) dumpData(buf *xfmt.Buffer, it *fs1.Iter) error {
return
nil
}
const
dumpSummary
=
"dump database transactions"
func
dumpUsage
(
w
io
.
Writer
)
{
fmt
.
Fprintf
(
w
,
`Usage: fs1 dump [options] <storage>
Dump transactions from a FileStorage
<storage> is a path to FileStorage
options:
-h --help this help text.
-v verbose mode.
`
)
}
func
dumpMain
(
argv
[]
string
)
{
var
verbose
bool
flags
:=
flag
.
FlagSet
{
Usage
:
func
()
{
tailUsage
(
os
.
Stderr
)
}}
flags
.
Init
(
""
,
flag
.
ExitOnError
)
flags
.
BoolVar
(
&
verbose
,
"v"
,
verbose
,
"verbose mode"
)
flags
.
Parse
(
argv
[
1
:
])
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
var
d
Dumper
if
verbose
{
d
=
&
DumperFsDumpVerbose
{}
}
else
{
d
=
&
DumperFsDump
{}
}
err
:=
Dump
(
os
.
Stdout
,
storPath
,
fs1
.
IterForward
,
d
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
// ----------------------------------------
// DumperFsTail implements dumping with the same format as in fstail/py
...
...
@@ -266,6 +319,10 @@ type DumperFsTail struct {
data
[]
byte
// buffer for reading txn data
}
func
(
d
*
DumperFsTail
)
DumperName
()
string
{
return
"fstail"
}
func
(
d
*
DumperFsTail
)
DumpFileHeader
(
buf
*
xfmt
.
Buffer
,
fh
*
fs1
.
FileHeader
)
error
{
return
nil
}
...
...
go/zodb/storage/fs1/fs1tools/main.go
View file @
6103fd3e
...
...
@@ -23,8 +23,8 @@ package fs1tools
import
"lab.nexedi.com/kirr/neo/go/zodb/zodbtools"
var
commands
=
zodbtools
.
CommandRegistry
{
{
"dump"
,
dumpSummary
,
dumpUsage
,
dumpMain
},
{
"tail"
,
tailSummary
,
tailUsage
,
tailMain
},
// dump, dump+verbose (fsdump.py)
// + fsstats? (fsstats.py)
{
"reindex"
,
reindexSummary
,
reindexUsage
,
reindexMain
},
...
...
go/zodb/storage/fs1/fs1tools/tail_test.go
View file @
6103fd3e
...
...
@@ -49,24 +49,24 @@ func diff(a, b string) string {
return
dmp
.
DiffPrettyText
(
diffv
)
}
func
testDump
(
t
*
testing
.
T
,
name
string
,
dir
fs1
.
IterDir
,
d
Dumper
)
{
func
testDump
(
t
*
testing
.
T
,
dir
fs1
.
IterDir
,
d
Dumper
)
{
buf
:=
bytes
.
Buffer
{}
err
:=
Dump
(
&
buf
,
"../testdata/1.fs"
,
dir
,
d
)
if
err
!=
nil
{
t
.
Fatalf
(
"%s: %v"
,
name
,
err
)
t
.
Fatalf
(
"%s: %v"
,
d
.
DumperName
()
,
err
)
}
dumpOk
:=
loadFile
(
t
,
fmt
.
Sprintf
(
"testdata/1.%s.ok"
,
name
))
dumpOk
:=
loadFile
(
t
,
fmt
.
Sprintf
(
"testdata/1.%s.ok"
,
d
.
DumperName
()
))
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"%s: dump different:
\n
%v"
,
name
,
diff
(
dumpOk
,
buf
.
String
()))
t
.
Errorf
(
"%s: dump different:
\n
%v"
,
d
.
DumperName
()
,
diff
(
dumpOk
,
buf
.
String
()))
}
}
func
TestFsDump
(
t
*
testing
.
T
)
{
testDump
(
t
,
"fsdump"
,
fs1
.
IterForward
,
&
DumperFsDump
{})
}
func
TestFsDumpv
(
t
*
testing
.
T
)
{
testDump
(
t
,
"fsdumpv"
,
fs1
.
IterForward
,
&
DumperFsDumpVerbose
{})
}
func
TestFsTail
(
t
*
testing
.
T
)
{
testDump
(
t
,
"fstail"
,
fs1
.
IterBackward
,
&
DumperFsTail
{
Ntxn
:
1000000
})
}
func
TestFsDump
(
t
*
testing
.
T
)
{
testDump
(
t
,
fs1
.
IterForward
,
&
DumperFsDump
{})
}
func
TestFsDumpv
(
t
*
testing
.
T
)
{
testDump
(
t
,
fs1
.
IterForward
,
&
DumperFsDumpVerbose
{})
}
func
TestFsTail
(
t
*
testing
.
T
)
{
testDump
(
t
,
fs1
.
IterBackward
,
&
DumperFsTail
{
Ntxn
:
1000000
})
}
func
BenchmarkTail
(
b
*
testing
.
B
)
{
// FIXME small testdata/1.fs is not representative for benchmarking
...
...
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