本文整理匯總了Golang中github.com/kandoo/beehive/Godeps/_workspace/src/github.com/coreos/etcd/raft/raftpb.ConfChange.NodeID方法的典型用法代碼示例。如果您正苦於以下問題:Golang ConfChange.NodeID方法的具體用法?Golang ConfChange.NodeID怎麽用?Golang ConfChange.NodeID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kandoo/beehive/Godeps/_workspace/src/github.com/coreos/etcd/raft/raftpb.ConfChange
的用法示例。
在下文中一共展示了ConfChange.NodeID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: save
func (g *group) save(rdsv readySaved) error {
glog.V(3).Infof("%v saving state", g)
if rdsv.ready.SoftState != nil && rdsv.ready.SoftState.Lead != 0 {
g.node.notifyElection(g.id)
}
// Apply snapshot to storage if it is more updated than current snapped.
if !etcdraft.IsEmptySnap(rdsv.ready.Snapshot) {
if err := g.diskStorage.SaveSnap(rdsv.ready.Snapshot); err != nil {
glog.Fatalf("err in save snapshot: %v", err)
}
g.raftStorage.ApplySnapshot(rdsv.ready.Snapshot)
glog.Infof("%v saved incoming snapshot at index %d", g,
rdsv.ready.Snapshot.Metadata.Index)
}
err := g.diskStorage.Save(rdsv.ready.HardState, rdsv.ready.Entries)
if err != nil {
glog.Fatalf("err in raft storage save: %v", err)
}
glog.V(3).Infof("%v saved state on disk", g)
g.raftStorage.Append(rdsv.ready.Entries)
glog.V(3).Infof("%v appended entries in storage", g)
// Apply config changes in the node as soon as possible
// before applying other entries in the state machine.
for _, e := range rdsv.ready.CommittedEntries {
if e.Type != raftpb.EntryConfChange {
continue
}
if e.Index <= g.saved {
continue
}
g.saved = e.Index
var cc raftpb.ConfChange
pbutil.MustUnmarshal(&cc, e.Data)
if glog.V(2) {
glog.Infof("%v applies conf change %s: %s",
g, formatConfChange(cc), formatEntry(e))
}
if err := g.validConfChange(cc); err != nil {
glog.Errorf("%v received an invalid conf change for node %v: %v",
g, cc.NodeID, err)
cc.NodeID = etcdraft.None
g.node.node.ApplyConfChange(g.id, cc)
continue
}
cch := make(chan struct{})
go func() {
g.confState = *g.node.node.ApplyConfChange(g.id, cc)
close(cch)
}()
select {
case <-g.node.done:
return ErrStopped
case <-cch:
}
}
glog.V(3).Infof("%v successfully saved ready", g)
rdsv.saved <- struct{}{}
select {
case g.applyc <- rdsv.ready:
case <-g.node.done:
}
return nil
}