Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
e0b19d5d
Commit
e0b19d5d
authored
Jul 31, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c91c63be
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
51 deletions
+79
-51
go/neo/neotools/master.go
go/neo/neotools/master.go
+4
-5
go/neo/neotools/storage.go
go/neo/neotools/storage.go
+9
-10
go/zodb/storage/fs1/fs1tools/dump.go
go/zodb/storage/fs1/fs1tools/dump.go
+5
-5
go/zodb/storage/fs1/fs1tools/index.go
go/zodb/storage/fs1/fs1tools/index.go
+5
-5
go/zodb/zodbtools/catobj.go
go/zodb/zodbtools/catobj.go
+6
-7
go/zodb/zodbtools/driver.go
go/zodb/zodbtools/driver.go
+43
-10
go/zodb/zodbtools/dump.go
go/zodb/zodbtools/dump.go
+4
-5
go/zodb/zodbtools/info.go
go/zodb/zodbtools/info.go
+3
-4
No files found.
go/neo/neotools/master.go
View file @
e0b19d5d
...
...
@@ -24,12 +24,12 @@ import (
"context"
"flag"
"fmt"
"log"
"io"
"os"
"lab.nexedi.com/kirr/neo/go/neo/server"
"lab.nexedi.com/kirr/neo/go/xcommon/xnet"
zt
"lab.nexedi.com/kirr/neo/go/zodb/zodbtools"
)
const
masterSummary
=
"run master node"
...
...
@@ -56,14 +56,13 @@ func masterMain(argv []string) {
if
*
cluster
==
""
{
// XXX vvv -> die or log.Fatalf ?
log
.
Fatal
(
os
.
Stderr
,
"cluster name must be provided"
)
os
.
Exit
(
2
)
zt
.
Fatal
(
"cluster name must be provided"
)
}
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
net
:=
xnet
.
NetPlain
(
"tcp"
)
// TODO + TLS; not only "tcp" ?
...
...
@@ -81,6 +80,6 @@ func masterMain(argv []string) {
err
:=
masterSrv
.
Run
(
ctx
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
go/neo/neotools/storage.go
View file @
e0b19d5d
...
...
@@ -24,14 +24,14 @@ import (
"context"
"flag"
"fmt"
"log"
"io"
"os"
"strings"
"lab.nexedi.com/kirr/neo/go/neo/server"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
"lab.nexedi.com/kirr/neo/go/xcommon/xnet"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
zt
"lab.nexedi.com/kirr/neo/go/zodb/zodbtools"
)
const
storageSummary
=
"run storage node"
...
...
@@ -54,19 +54,18 @@ func storageMain(argv []string) {
flags
.
Parse
(
argv
[
1
:
])
if
*
cluster
==
""
{
// XXX vvv -> die or log.Fatalf ?
log
.
Fatal
(
os
.
Stderr
,
"cluster name must be provided"
)
os
.
Exit
(
2
)
// XXX vvv -> die or Fatalf ?
zt
.
Fatal
(
os
.
Stderr
,
"cluster name must be provided"
)
}
masterv
:=
strings
.
Split
(
*
masters
,
","
)
if
len
(
masterv
)
==
0
{
fmt
.
Fprintf
(
os
.
Stderr
,
"master list must be provided"
)
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
if
len
(
masterv
)
>
1
{
fmt
.
Fprintf
(
os
.
Stderr
,
"BUG neo/go POC currently supports only 1 master"
)
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
master
:=
masterv
[
0
]
...
...
@@ -74,13 +73,13 @@ func storageMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
// XXX hack to use existing zodb storage for data
zstor
,
err
:=
fs1
.
Open
(
context
.
Background
(),
argv
[
0
])
// XXX context.Background -> ?
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
net
:=
xnet
.
NetPlain
(
"tcp"
)
// TODO + TLS; not only "tcp" ?
...
...
@@ -98,6 +97,6 @@ func storageMain(argv []string) {
err
=
storSrv
.
Run
(
ctx
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
go/zodb/storage/fs1/fs1tools/dump.go
View file @
e0b19d5d
...
...
@@ -25,11 +25,11 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
zt
"lab.nexedi.com/kirr/neo/go/zodb/zodbtools"
"lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/go123/xerr"
...
...
@@ -313,7 +313,7 @@ func dumpMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
...
...
@@ -326,7 +326,7 @@ func dumpMain(argv []string) {
err
:=
Dump
(
os
.
Stdout
,
storPath
,
fs1
.
IterForward
,
d
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
...
...
@@ -411,12 +411,12 @@ func tailMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
err
:=
Dump
(
os
.
Stdout
,
storPath
,
fs1
.
IterBackward
,
&
DumperFsTail
{
Ntxn
:
ntxn
})
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
go/zodb/storage/fs1/fs1tools/index.go
View file @
e0b19d5d
...
...
@@ -25,9 +25,9 @@ import (
"fmt"
"io"
"os"
"log"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
zt
"lab.nexedi.com/kirr/neo/go/zodb/zodbtools"
)
// Reindex rebuilds index for FileStorage file @ path
...
...
@@ -69,13 +69,13 @@ func reindexMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
err
:=
Reindex
(
context
.
Background
(),
storPath
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
...
...
@@ -122,12 +122,12 @@ func verifyIdxMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
zt
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
err
:=
VerifyIndexFor
(
context
.
Background
(),
storPath
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
zt
.
Fatal
(
err
)
}
}
go/zodb/zodbtools/catobj.go
View file @
e0b19d5d
...
...
@@ -25,7 +25,6 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"lab.nexedi.com/kirr/neo/go/zodb"
...
...
@@ -97,31 +96,31 @@ func catobjMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
2
{
flags
.
Usage
()
os
.
Exit
(
2
)
Exit
(
2
)
}
storUrl
:=
argv
[
0
]
if
hashOnly
&&
raw
{
log
.
Fatal
(
"-hashonly & -raw are incompatible"
)
Fatal
(
"-hashonly & -raw are incompatible"
)
}
xidv
:=
[]
zodb
.
Xid
{}
for
_
,
arg
:=
range
argv
[
1
:
]
{
xid
,
err
:=
zodb
.
ParseXid
(
arg
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
// XXX recheck
Fatal
(
err
)
// XXX recheck
}
xidv
=
append
(
xidv
,
xid
)
}
if
raw
&&
len
(
xidv
)
>
1
{
log
.
Fatal
(
"only 1 object allowed with -raw"
)
Fatal
(
"only 1 object allowed with -raw"
)
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
// TODO defer stor.Close()
...
...
@@ -136,7 +135,7 @@ func catobjMain(argv []string) {
for
_
,
xid
:=
range
xidv
{
err
=
catobj
(
xid
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
}
}
go/zodb/zodbtools/driver.go
View file @
e0b19d5d
...
...
@@ -81,8 +81,41 @@ type MainProg struct {
HelpTopics
HelpRegistry
// provided help topics
}
// Exit is like os.Exit but makes sure deferred functions are run.
// Exit should be called from main goroutine.
func
Exit
(
code
int
)
{
panic
(
&
programExit
{
code
})
}
// Fatal is like log.Fatal but makes sure deferred functions are run.
// Fatal should be called from main goroutine.
func
Fatal
(
v
...
interface
{})
{
log
.
Print
(
v
...
)
Exit
(
1
)
}
// programExit is thrown when Exit or Fatal are called
type
programExit
struct
{
code
int
}
// Main is the main entry point for the program. Call it from main.
func
(
prog
*
MainProg
)
Main
()
{
// handle exit throw-requests
defer
func
()
{
r
:=
recover
()
if
e
,
_
:=
r
.
(
*
programExit
);
e
!=
nil
{
os
.
Exit
(
e
.
code
)
}
if
r
!=
nil
{
panic
(
r
)
}
}()
prog
.
main
()
}
func
(
prog
*
MainProg
)
main
()
{
flag
.
Usage
=
prog
.
usage
cpuprofile
:=
flag
.
String
(
"cpuprofile"
,
""
,
"write cpu profile to `file`"
)
memprofile
:=
flag
.
String
(
"memprofile"
,
""
,
"write memory profile to `file`"
)
...
...
@@ -91,7 +124,7 @@ func (prog *MainProg) Main() {
if
len
(
argv
)
==
0
{
prog
.
usage
()
os
.
Exit
(
2
)
Exit
(
2
)
}
command
:=
argv
[
0
]
...
...
@@ -100,10 +133,10 @@ func (prog *MainProg) Main() {
if
*
cpuprofile
!=
""
{
f
,
err
:=
os
.
Create
(
*
cpuprofile
)
if
err
!=
nil
{
log
.
Fatal
(
"could not create CPU profile: "
,
err
)
Fatal
(
"could not create CPU profile: "
,
err
)
}
if
err
:=
pprof
.
StartCPUProfile
(
f
);
err
!=
nil
{
log
.
Fatal
(
"could not start CPU profile: "
,
err
)
Fatal
(
"could not start CPU profile: "
,
err
)
}
defer
pprof
.
StopCPUProfile
()
}
...
...
@@ -112,11 +145,11 @@ func (prog *MainProg) Main() {
if
*
memprofile
!=
""
{
f
,
err
:=
os
.
Create
(
*
memprofile
)
if
err
!=
nil
{
log
.
Fatal
(
"could not create memory profile: "
,
err
)
Fatal
(
"could not create memory profile: "
,
err
)
}
runtime
.
GC
()
// get up-to-date statistics
if
err
:=
pprof
.
WriteHeapProfile
(
f
);
err
!=
nil
{
log
.
Fatal
(
"could not write memory profile: "
,
err
)
Fatal
(
"could not write memory profile: "
,
err
)
}
f
.
Close
()
}
...
...
@@ -134,7 +167,7 @@ func (prog *MainProg) Main() {
if
cmd
==
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: unknown subcommand
\"
%s
\"\n
"
,
prog
.
Name
,
command
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Run '%s help' for usage.
\n
"
,
prog
.
Name
)
os
.
Exit
(
2
)
Exit
(
2
)
}
cmd
.
Main
(
argv
)
...
...
@@ -201,7 +234,7 @@ Use "%s help [topic]" for more information about that topic.
func
(
prog
*
MainProg
)
help
(
argv
[]
string
)
{
if
len
(
argv
)
<
2
{
// help topic ...
prog
.
usage
()
os
.
Exit
(
2
)
Exit
(
2
)
}
topic
:=
argv
[
1
]
...
...
@@ -210,17 +243,17 @@ func (prog *MainProg) help(argv []string) {
command
:=
prog
.
Commands
.
Lookup
(
topic
)
if
command
!=
nil
{
command
.
Usage
(
os
.
Stdout
)
os
.
Exit
(
0
)
Exit
(
0
)
}
helpTopic
:=
prog
.
helpTopics
()
.
Lookup
(
topic
)
if
helpTopic
!=
nil
{
fmt
.
Println
(
helpTopic
.
Text
)
os
.
Exit
(
0
)
Exit
(
0
)
}
fmt
.
Fprintf
(
os
.
Stderr
,
"Unknown help topic `%s`. Run '%s help'.
\n
"
,
topic
,
prog
.
Name
)
os
.
Exit
(
2
)
Exit
(
2
)
}
// helpTopics returns provided help topics augmented with help on common topics
...
...
go/zodb/zodbtools/dump.go
View file @
e0b19d5d
...
...
@@ -44,7 +44,6 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"lab.nexedi.com/kirr/go123/xfmt"
...
...
@@ -235,7 +234,7 @@ func dumpMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
Exit
(
2
)
}
storUrl
:=
argv
[
0
]
...
...
@@ -245,17 +244,17 @@ func dumpMain(argv []string) {
tidMin
,
tidMax
,
err
:=
zodb
.
ParseTidRange
(
tidRange
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
// XXX recheck
Fatal
(
err
)
// XXX recheck
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
// TODO defer stor.Close()
err
=
Dump
(
os
.
Stdout
,
stor
,
tidMin
,
tidMax
,
hashOnly
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
}
go/zodb/zodbtools/info.go
View file @
e0b19d5d
...
...
@@ -26,7 +26,6 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"lab.nexedi.com/kirr/neo/go/zodb"
...
...
@@ -112,17 +111,17 @@ func infoMain(argv []string) {
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
Exit
(
2
)
}
storUrl
:=
argv
[
0
]
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
err
=
Info
(
os
.
Stdout
,
stor
,
argv
[
1
:
])
if
err
!=
nil
{
log
.
Fatal
(
err
)
Fatal
(
err
)
}
}
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