本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.Server.ValidateTabletPidNode方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.ValidateTabletPidNode方法的具体用法?Golang Server.ValidateTabletPidNode怎么用?Golang Server.ValidateTabletPidNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/topo.Server
的用法示例。
在下文中一共展示了Server.ValidateTabletPidNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CheckPid
func CheckPid(t *testing.T, ts topo.Server) {
cell := getLocalCell(t, ts)
tablet := &topo.Tablet{
Cell: cell,
Uid: 1,
Parent: topo.TabletAlias{},
Addr: "localhost:3333",
Keyspace: "test_keyspace",
Type: topo.TYPE_MASTER,
State: topo.STATE_READ_WRITE,
KeyRange: newKeyRange("-10"),
}
if err := ts.CreateTablet(tablet); err != nil {
t.Fatalf("CreateTablet: %v", err)
}
tabletAlias := topo.TabletAlias{Cell: cell, Uid: 1}
done := make(chan struct{}, 1)
if err := ts.CreateTabletPidNode(tabletAlias, "contents", done); err != nil {
t.Errorf("ts.CreateTabletPidNode: %v", err)
}
if err := ts.ValidateTabletPidNode(tabletAlias); err != nil {
t.Errorf("ts.ValidateTabletPidNode: %v", err)
}
close(done)
}
示例2: CheckPid
func CheckPid(t *testing.T, ts topo.Server) {
cell := getLocalCell(t, ts)
tablet := &topo.Tablet{
Alias: topo.TabletAlias{Cell: cell, Uid: 1},
Hostname: "localhost",
Portmap: map[string]int{
"vt": 3333,
},
Parent: topo.TabletAlias{},
Keyspace: "test_keyspace",
Type: topo.TYPE_MASTER,
State: topo.STATE_READ_WRITE,
KeyRange: newKeyRange("-10"),
}
if err := ts.CreateTablet(tablet); err != nil {
t.Fatalf("CreateTablet: %v", err)
}
tabletAlias := topo.TabletAlias{Cell: cell, Uid: 1}
done := make(chan struct{}, 1)
if err := ts.CreateTabletPidNode(tabletAlias, "contents", done); err != nil {
t.Errorf("ts.CreateTabletPidNode: %v", err)
}
// wait for up to 30 seconds for the pid to appear
timeout := 30
for {
err := ts.ValidateTabletPidNode(tabletAlias)
if err == nil {
// exists, we're good
break
}
timeout -= 1
if timeout == 0 {
t.Fatalf("ts.ValidateTabletPidNode: %v", err)
}
t.Logf("Waiting for ValidateTabletPidNode to succeed %v/30", timeout)
time.Sleep(time.Second)
}
close(done)
}