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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
d3713e72
Commit
d3713e72
authored
Aug 11, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
946500ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
24 deletions
+36
-24
go/neo/pkt.go
go/neo/pkt.go
+1
-1
go/neo/proto-str.go
go/neo/proto-str.go
+19
-1
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+7
-1
go/neo/server/master.go
go/neo/server/master.go
+3
-7
go/neo/server/storage.go
go/neo/server/storage.go
+3
-1
go/xcommon/log/log.go
go/xcommon/log/log.go
+3
-13
No files found.
go/neo/pkt.go
View file @
d3713e72
...
@@ -80,7 +80,7 @@ func (pkt *PktBuf) String() string {
...
@@ -80,7 +80,7 @@ func (pkt *PktBuf) String() string {
s
+=
fmt
.
Sprintf
(
" (%s) %v; #%d [%d]: % x"
,
msgType
,
err
,
msgLen
,
len
(
data
),
data
)
s
+=
fmt
.
Sprintf
(
" (%s) %v; #%d [%d]: % x"
,
msgType
,
err
,
msgLen
,
len
(
data
),
data
)
}
}
s
+=
fmt
.
Sprintf
(
" %s %
+v"
,
msgType
.
Name
(),
msg
)
s
+=
fmt
.
Sprintf
(
" %s %
v"
,
msgType
.
Name
(),
msg
)
// XXX or %+v better?
if
n
<
len
(
data
)
{
if
n
<
len
(
data
)
{
tail
:=
data
[
n
:
]
tail
:=
data
[
n
:
]
...
...
go/neo/proto-str.go
View file @
d3713e72
...
@@ -22,8 +22,9 @@ func (e *Error) Error() string {
...
@@ -22,8 +22,9 @@ func (e *Error) Error() string {
const
nodeTypeChar
=
"MSCA4567"
// keep in sync with NodeType constants
const
nodeTypeChar
=
"MSCA4567"
// keep in sync with NodeType constants
// String returns string representation of a node uuid.
// It returns ex 'S1', 'M2', ...
func
(
nodeUUID
NodeUUID
)
String
()
string
{
func
(
nodeUUID
NodeUUID
)
String
()
string
{
// return ex 'S1', 'M2', ...
if
nodeUUID
==
0
{
if
nodeUUID
==
0
{
return
"?0"
return
"?0"
}
}
...
@@ -45,6 +46,23 @@ func (nodeUUID NodeUUID) String() string {
...
@@ -45,6 +46,23 @@ func (nodeUUID NodeUUID) String() string {
return
s
return
s
}
}
// XXX place ok?
// XXX test
func
UUID
(
typ
NodeType
,
num
int32
)
NodeUUID
{
temp
:=
uint32
(
0
)
if
num
<
0
{
temp
=
1
num
=
-
num
}
if
num
>>
24
!=
0
{
panic
(
"node number out of range"
)
}
uuid
:=
temp
<<
(
7
+
3
*
8
)
|
uint32
(
typ
)
<<
(
4
+
3
*
8
)
|
uint32
(
num
)
return
NodeUUID
(
uuid
)
}
// ----------------------------------------
// ----------------------------------------
// Addr converts network address string into NEO Address
// Addr converts network address string into NEO Address
...
...
go/neo/server/cluster_test.go
View file @
d3713e72
...
@@ -225,7 +225,13 @@ func TestMasterStorage(t *testing.T) {
...
@@ -225,7 +225,13 @@ func TestMasterStorage(t *testing.T) {
IdTimestamp
:
0
,
IdTimestamp
:
0
,
}))
}))
// XXX ... M adjust nodetab...
// XXX ... M adjust nodetab...
tc
.
Expect
(
conntx
(
"m:1"
,
"s:1"
,
1
,
&
neo
.
AcceptIdentification
{}))
// XXX
tc
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
neo
.
AcceptIdentification
{
NodeType
:
neo
.
MASTER
,
MyNodeUUID
:
neo
.
UUID
(
neo
.
MASTER
,
1
),
NumPartitions
:
1
,
NumReplicas
:
1
,
YourNodeUUID
:
neo
.
UUID
(
neo
.
STORAGE
,
1
),
}))
...
...
go/neo/server/master.go
View file @
d3713e72
...
@@ -166,7 +166,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
...
@@ -166,7 +166,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
defer
wg
.
Done
()
defer
wg
.
Done
()
// XXX dup in storage
// XXX dup in storage
for
serveCtx
.
Err
()
!
=
nil
{
for
serveCtx
.
Err
()
=
=
nil
{
conn
,
idReq
,
err
:=
l
.
Accept
()
conn
,
idReq
,
err
:=
l
.
Accept
()
if
err
!=
nil
{
if
err
!=
nil
{
// TODO log / throttle
// TODO log / throttle
...
@@ -925,12 +925,8 @@ func (m *Master) accept(ctx context.Context, conn *neo.Conn, resp neo.Msg) error
...
@@ -925,12 +925,8 @@ func (m *Master) accept(ctx context.Context, conn *neo.Conn, resp neo.Msg) error
// XXX it is bad idea for master to assign uuid to coming node
// XXX it is bad idea for master to assign uuid to coming node
// -> better nodes generate really unique UUID themselves and always show with them
// -> better nodes generate really unique UUID themselves and always show with them
func
(
m
*
Master
)
allocUUID
(
nodeType
neo
.
NodeType
)
neo
.
NodeUUID
{
func
(
m
*
Master
)
allocUUID
(
nodeType
neo
.
NodeType
)
neo
.
NodeUUID
{
// see NodeUUID & NodeUUID.String for details
for
num
:=
int32
(
1
);
num
<
1
<<
24
;
num
++
{
// XXX better to keep this code near to ^^^ (e.g. attached to NodeType)
uuid
:=
neo
.
UUID
(
nodeType
,
num
)
// XXX but since whole uuid assign idea is not good - let's keep it dirty here
typ
:=
int
(
nodeType
&
7
)
<<
(
24
+
4
)
// note temp=0
for
num
:=
1
;
num
<
1
<<
24
;
num
++
{
uuid
:=
neo
.
NodeUUID
(
typ
|
num
)
if
m
.
nodeTab
.
Get
(
uuid
)
==
nil
{
if
m
.
nodeTab
.
Get
(
uuid
)
==
nil
{
return
uuid
return
uuid
}
}
...
...
go/neo/server/storage.go
View file @
d3713e72
...
@@ -93,6 +93,8 @@ func (stor *Storage) Run(ctx context.Context) error {
...
@@ -93,6 +93,8 @@ func (stor *Storage) Run(ctx context.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
// XXX err ctx
return
err
// XXX err ctx
}
}
defer
runningf
(
&
ctx
,
"storage(%v)"
,
l
.
Addr
())(
&
err
)
log
.
Infof
(
ctx
,
"serving on %s ..."
,
l
.
Addr
())
log
.
Infof
(
ctx
,
"serving on %s ..."
,
l
.
Addr
())
// start serving incoming connections
// start serving incoming connections
...
@@ -103,7 +105,7 @@ func (stor *Storage) Run(ctx context.Context) error {
...
@@ -103,7 +105,7 @@ func (stor *Storage) Run(ctx context.Context) error {
defer
wg
.
Done
()
defer
wg
.
Done
()
// XXX dup from master
// XXX dup from master
for
serveCtx
.
Err
()
!
=
nil
{
for
serveCtx
.
Err
()
=
=
nil
{
conn
,
idReq
,
err
:=
l
.
Accept
()
conn
,
idReq
,
err
:=
l
.
Accept
()
if
err
!=
nil
{
if
err
!=
nil
{
// TODO log / throttle
// TODO log / throttle
...
...
go/xcommon/log/log.go
View file @
d3713e72
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
// Package log provides logging with severity levels and tasks integration
// Package log provides logging with severity levels and tasks integration
//
//
// XXX inspired by cockrach
// XXX inspired by cockrach
// XXX just use cockroach/util/log directly?
package
log
package
log
import
(
import
(
...
@@ -31,17 +32,6 @@ import (
...
@@ -31,17 +32,6 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/task"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
)
)
/*
// taskPrefix returns prefix associated to current operational task stack to put to logs
func taskPrefix(ctx context.Context) string {
s := task.Current(ctx).String()
if s != "" {
s += ": "
}
return s
}
*/
// withTask prepends string describing current operational task stack to argv and returns it
// withTask prepends string describing current operational task stack to argv and returns it
// handy to use this way:
// handy to use this way:
//
//
...
@@ -57,7 +47,7 @@ func withTask(ctx context.Context, argv ...interface{}) []interface{} {
...
@@ -57,7 +47,7 @@ func withTask(ctx context.Context, argv ...interface{}) []interface{} {
}
}
if
len
(
argv
)
!=
0
{
if
len
(
argv
)
!=
0
{
task
+=
":"
task
+=
":
"
}
}
return
append
([]
interface
{}{
task
},
argv
...
)
return
append
([]
interface
{}{
task
},
argv
...
)
...
@@ -99,4 +89,4 @@ func Errorf(ctx context.Context, format string, argv ...interface{}) {
...
@@ -99,4 +89,4 @@ func Errorf(ctx context.Context, format string, argv ...interface{}) {
}
}
// TODO Warningf,
Errorf,
...
// TODO Warningf, ...
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