Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
44226853
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
44226853
编写于
6月 21, 2017
作者:
H
Helin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
put InMemStore into master package
上级
fd893755
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
50 deletion
+31
-50
go/cmd/master/master.go
go/cmd/master/master.go
+1
-22
go/master/client_internal_test.go
go/master/client_internal_test.go
+1
-14
go/master/client_test.go
go/master/client_test.go
+1
-14
go/master/inmem_store.go
go/master/inmem_store.go
+28
-0
未找到文件。
go/cmd/master/master.go
浏览文件 @
44226853
...
@@ -6,7 +6,6 @@ import (
...
@@ -6,7 +6,6 @@ import (
"net/rpc"
"net/rpc"
"strconv"
"strconv"
"strings"
"strings"
"sync"
"time"
"time"
"github.com/namsral/flag"
"github.com/namsral/flag"
...
@@ -15,26 +14,6 @@ import (
...
@@ -15,26 +14,6 @@ import (
"github.com/PaddlePaddle/Paddle/go/master"
"github.com/PaddlePaddle/Paddle/go/master"
)
)
type
inMemStore
struct
{
mu
sync
.
Mutex
buf
[]
byte
}
func
(
m
*
inMemStore
)
Save
(
b
[]
byte
)
error
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
m
.
buf
=
b
return
nil
}
func
(
m
*
inMemStore
)
Load
()
([]
byte
,
error
)
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
return
m
.
buf
,
nil
}
func
main
()
{
func
main
()
{
port
:=
flag
.
Int
(
"port"
,
8080
,
"port of the master server."
)
port
:=
flag
.
Int
(
"port"
,
8080
,
"port of the master server."
)
...
@@ -58,7 +37,7 @@ func main() {
...
@@ -58,7 +37,7 @@ func main() {
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
}
else
{
}
else
{
store
=
&
i
nMemStore
{}
store
=
&
master
.
I
nMemStore
{}
}
}
s
,
err
:=
master
.
NewService
(
store
,
*
chunkPerTask
,
*
taskTimeoutDur
,
*
taskTimeoutMax
)
s
,
err
:=
master
.
NewService
(
store
,
*
chunkPerTask
,
*
taskTimeoutDur
,
*
taskTimeoutMax
)
...
...
go/master/client_internal_test.go
浏览文件 @
44226853
...
@@ -32,19 +32,6 @@ func (a TestAddresser) Address() string {
...
@@ -32,19 +32,6 @@ func (a TestAddresser) Address() string {
return
string
(
a
)
return
string
(
a
)
}
}
type
myStore
struct
{
buf
[]
byte
}
func
(
m
*
myStore
)
Save
(
b
[]
byte
)
error
{
m
.
buf
=
b
return
nil
}
func
(
m
*
myStore
)
Load
()
([]
byte
,
error
)
{
return
m
.
buf
,
nil
}
func
TestGetFinishTask
(
t
*
testing
.
T
)
{
func
TestGetFinishTask
(
t
*
testing
.
T
)
{
const
path
=
"/tmp/master_client_test_0"
const
path
=
"/tmp/master_client_test_0"
...
@@ -60,7 +47,7 @@ func TestGetFinishTask(t *testing.T) {
...
@@ -60,7 +47,7 @@ func TestGetFinishTask(t *testing.T) {
}
}
go
func
(
l
net
.
Listener
)
{
go
func
(
l
net
.
Listener
)
{
s
,
err
:=
NewService
(
&
my
Store
{},
chunkPerTask
,
time
.
Second
,
1
)
s
,
err
:=
NewService
(
&
InMem
Store
{},
chunkPerTask
,
time
.
Second
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
...
go/master/client_test.go
浏览文件 @
44226853
...
@@ -15,19 +15,6 @@ import (
...
@@ -15,19 +15,6 @@ import (
"github.com/PaddlePaddle/recordio"
"github.com/PaddlePaddle/recordio"
)
)
type
myStore
struct
{
buf
[]
byte
}
func
(
m
*
myStore
)
Save
(
b
[]
byte
)
error
{
m
.
buf
=
b
return
nil
}
func
(
m
*
myStore
)
Load
()
([]
byte
,
error
)
{
return
m
.
buf
,
nil
}
func
TestNextRecord
(
t
*
testing
.
T
)
{
func
TestNextRecord
(
t
*
testing
.
T
)
{
const
(
const
(
path
=
"/tmp/master_client_TestFull"
path
=
"/tmp/master_client_TestFull"
...
@@ -46,7 +33,7 @@ func TestNextRecord(t *testing.T) {
...
@@ -46,7 +33,7 @@ func TestNextRecord(t *testing.T) {
}
}
go
func
(
l
net
.
Listener
)
{
go
func
(
l
net
.
Listener
)
{
s
,
err
:=
master
.
NewService
(
&
m
y
Store
{},
10
,
time
.
Second
,
1
)
s
,
err
:=
master
.
NewService
(
&
m
aster
.
InMem
Store
{},
10
,
time
.
Second
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
...
go/master/inmem_store.go
0 → 100644
浏览文件 @
44226853
package
master
import
"sync"
// InMemStore is an in memory implementation of Store interface.
//
// It does not tolerate the fault that casues the program to crash.
type
InMemStore
struct
{
mu
sync
.
Mutex
buf
[]
byte
}
// Save saves the state into the in-memory store.
func
(
m
*
InMemStore
)
Save
(
state
[]
byte
)
error
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
m
.
buf
=
state
return
nil
}
// Load loads the state from the in-memory store.
func
(
m
*
InMemStore
)
Load
()
([]
byte
,
error
)
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
return
m
.
buf
,
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录