本文整理汇总了Golang中dlog.Println函数的典型用法代码示例。如果您正苦于以下问题:Golang Println函数的具体用法?Golang Println怎么用?Golang Println使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Println函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bcastPrepare
func (r *Replica) bcastPrepare(replica int32, instance int32, ballot int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Prepare bcast failed:", err)
}
}()
args := &gpaxosproto.Prepare{r.Id, instance, ballot}
n := r.N - 1
//TODO: fix quorum size
if r.Thrifty {
n = r.N >> 1
}
q := r.Id
var w *bufio.Writer
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
dlog.Println("Not enough replicas alive!")
break
}
if !r.Alive[q] {
continue
}
sent++
w = r.PeerWriters[q]
w.WriteByte(gpaxosproto.PREPARE)
args.Marshal(w)
w.Flush()
}
}
示例2: handle1b
func (r *Replica) handle1b(msg *gpaxosproto.M_1b) {
if msg.Balnum != r.crtBalnum {
log.Println("1b from a different ballot")
return
}
crtbal := r.ballotArray[r.crtBalnum]
if crtbal.status != PHASE1 {
//delayed 1b
return
}
dlog.Println("msg.Cstruct: ", msg.Cstruct)
crtbal.lb.cstructs = append(crtbal.lb.cstructs, msg.Cstruct)
count := len(crtbal.lb.cstructs)
//is it sufficient to have the same initial quorum size for both fast and slow rounds?
if (r.fastRound && count == r.fastQSize) ||
(!r.fastRound && count == r.N/2+1) {
_, _, crtbal.cstruct = r.learn(true)
dlog.Println("LUB:", crtbal.cstruct)
r.bcast2a(r.crtBalnum, crtbal.cstruct, r.fastRound)
crtbal.lb.cstructs = make([][]int32, r.N)
crtbal.status = PHASE2
if r.fastRound && ALL_TO_ALL {
r.bcast2b(&gpaxosproto.M_2b{r.Id, r.crtBalnum, crtbal.cstruct, crtbal.cstruct})
}
}
}
示例3: bcastPrepare
func (r *Replica) bcastPrepare(replica int32, instance int32, ballot int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Prepare bcast failed:", err)
}
}()
args := &epaxosproto.Prepare{r.Id, replica, instance, ballot}
n := r.N - 1
if r.Thrifty {
n = r.N / 2
}
q := r.Id
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
dlog.Println("Not enough replicas alive!")
break
}
if !r.Alive[q] {
continue
}
r.SendMsg(q, r.prepareRPC, args)
sent++
}
}
示例4: tryToLearn
func (r *Replica) tryToLearn() {
var glb []int32
var conflict bool
crtbal := r.ballotArray[r.crtBalnum]
if conflict, glb, _ = r.learn(false); conflict {
log.Println("Conflict")
if r.isLeader {
r.startHigherBallot()
}
} else if glb != nil {
dlog.Println("Got GLB:", glb)
for _, cid := range glb {
dlog.Println("Committing command ", cid)
r.committed[cid] = true
crtbal.lb.committed++
if prop, present := r.commandReplies[cid]; present {
r.ReplyProposeTS(&genericsmrproto.ProposeReplyTS{TRUE, cid, state.NIL, prop.Timestamp}, prop.Reply)
delete(r.commandReplies, cid)
}
}
if r.isLeader && crtbal.lb.committed >= CMDS_PER_BALLOT {
r.startHigherBallot()
}
}
}
示例5: bcastCommit
func (r *Replica) bcastCommit(cstruct []int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Commit bcast failed:", err)
}
}()
args := &gpaxosproto.Commit{cstruct}
n := r.N - 1
q := r.Id
var w *bufio.Writer
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
break
}
if !r.Alive[q] {
continue
}
sent++
w = r.PeerWriters[q]
w.WriteByte(gpaxosproto.COMMIT)
args.Marshal(w)
w.Flush()
}
}
示例6: bcast2a
func (r *Replica) bcast2a(balnum int32, cstruct []int32, fast bool) {
defer func() {
if err := recover(); err != nil {
dlog.Println("1a bcast failed:", err)
}
}()
args := &gpaxosproto.M_2a{r.Id, balnum, cstruct}
n := r.N - 1
if r.Thrifty {
if fast {
n = r.fastQSize - 1
} else {
n = r.N >> 1
}
}
q := r.Id
var w *bufio.Writer
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
break
}
if !r.Alive[q] {
continue
}
sent++
w = r.PeerWriters[q]
w.WriteByte(gpaxosproto.M2A)
args.Marshal(w)
w.Flush()
}
}
示例7: bcastSkip
func (r *Replica) bcastSkip(startInstance int32, endInstance int32, exceptReplica int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Skip bcast failed:", err)
}
}()
sk.LeaderId = r.Id
sk.StartInstance = startInstance
sk.EndInstance = endInstance
args := &sk
//args := &menciusproto.Skip{r.Id, startInstance, endInstance}
n := r.N - 1
q := r.Id
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
break
}
if !r.Alive[q] || q == exceptReplica {
continue
}
sent++
r.SendMsgNoFlush(q, r.skipRPC, args)
}
}
示例8: bcastAccept
func (r *Replica) bcastAccept(replica int32, instance int32, ballot int32, count int32, seq int32, deps [DS]int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Accept bcast failed:", err)
}
}()
ea.LeaderId = r.Id
ea.Replica = replica
ea.Instance = instance
ea.Ballot = ballot
ea.Count = count
ea.Seq = seq
ea.Deps = deps
args := &ea
n := r.N - 1
if r.Thrifty {
n = r.N / 2
}
sent := 0
for q := 0; q < r.N-1; q++ {
if !r.Alive[r.PreferredPeerOrder[q]] {
continue
}
r.SendMsg(r.PreferredPeerOrder[q], r.acceptRPC, args)
sent++
if sent >= n {
break
}
}
}
示例9: bcastCommit
func (r *Replica) bcastCommit(replica int32, instance int32, cmds []state.Command, seq int32, deps [DS]int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Commit bcast failed:", err)
}
}()
ec.LeaderId = r.Id
ec.Replica = replica
ec.Instance = instance
ec.Command = cmds
ec.Seq = seq
ec.Deps = deps
args := &ec
ecs.LeaderId = r.Id
ecs.Replica = replica
ecs.Instance = instance
ecs.Count = int32(len(cmds))
ecs.Seq = seq
ecs.Deps = deps
argsShort := &ecs
sent := 0
for q := 0; q < r.N-1; q++ {
if !r.Alive[r.PreferredPeerOrder[q]] {
continue
}
if r.Thrifty && sent >= r.N/2 {
r.SendMsg(r.PreferredPeerOrder[q], r.commitRPC, args)
} else {
r.SendMsg(r.PreferredPeerOrder[q], r.commitShortRPC, argsShort)
sent++
}
}
}
示例10: bcastPreAccept
func (r *Replica) bcastPreAccept(replica int32, instance int32, ballot int32, cmds []state.Command, seq int32, deps [DS]int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("PreAccept bcast failed:", err)
}
}()
pa.LeaderId = r.Id
pa.Replica = replica
pa.Instance = instance
pa.Ballot = ballot
pa.Command = cmds
pa.Seq = seq
pa.Deps = deps
args := &pa
n := r.N - 1
if r.Thrifty {
n = r.N / 2
}
sent := 0
for q := 0; q < r.N-1; q++ {
if !r.Alive[r.PreferredPeerOrder[q]] {
continue
}
r.SendMsg(r.PreferredPeerOrder[q], r.preAcceptRPC, args)
sent++
if sent >= n {
break
}
}
}
示例11: bcastCommit
func (r *Replica) bcastCommit(instance int32, skip uint8, nbInstToSkip int32, command state.Command) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Commit bcast failed:", err)
}
}()
mc.LeaderId = r.Id
mc.Instance = instance
mc.Skip = skip
mc.NbInstancesToSkip = nbInstToSkip
//mc.Command = command
//args := &menciusproto.Commit{r.Id, instance, skip, nbInstToSkip, command}
args := &mc
n := r.N - 1
q := r.Id
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
break
}
if !r.Alive[q] {
continue
}
sent++
r.SendMsg(q, r.commitRPC, args)
}
}
示例12: bcastTryPreAccept
func (r *Replica) bcastTryPreAccept(replica int32, instance int32, ballot int32, cmds []state.Command, seq int32, deps [DS]int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("PreAccept bcast failed:", err)
}
}()
tpa.LeaderId = r.Id
tpa.Replica = replica
tpa.Instance = instance
tpa.Ballot = ballot
tpa.Command = cmds
tpa.Seq = seq
tpa.Deps = deps
args := &pa
for q := int32(0); q < int32(r.N); q++ {
if q == r.Id {
continue
}
if !r.Alive[q] {
continue
}
r.SendMsg(q, r.tryPreAcceptRPC, args)
}
}
示例13: bcastPrepare
func (r *Replica) bcastPrepare(instance int32, ballot int32) {
defer func() {
if err := recover(); err != nil {
dlog.Println("Prepare bcast failed:", err)
}
}()
args := &menciusproto.Prepare{r.Id, instance, ballot}
n := r.N - 1
if r.Thrifty {
n = r.N >> 1
}
q := r.Id
for sent := 0; sent < n; {
q = (q + 1) % int32(r.N)
if q == r.Id {
break
}
if !r.Alive[q] {
continue
}
sent++
r.SendMsg(q, r.prepareRPC, args)
}
}
示例14: handle2b
func (r *Replica) handle2b(msg *gpaxosproto.M_2b) {
if msg.Balnum != r.crtBalnum {
dlog.Println("2b from a different ballot")
return
}
crtbal := r.ballotArray[r.crtBalnum]
if r.isLeader && crtbal.status != PHASE2 {
log.Println("2b before its time")
return
}
crtbal.lb.cstructs[msg.ReplicaId] = msg.Cstruct
dlog.Printf("Replica %d 2b msg.Cstruct: ", msg.ReplicaId)
dlog.Println(msg.Cstruct)
dlog.Println("my cstruct:", crtbal.cstruct)
crtbal.lb.cstructs[r.Id] = crtbal.cstruct
r.tryToLearn()
}
示例15: handle2a
func (r *Replica) handle2a(msg *gpaxosproto.M_2a) {
if r.isLeader {
log.Println("Received 2a even though I am the leader")
return
}
if r.leaderId != msg.LeaderId {
log.Println("Received 2a from unrecognized leader")
return
}
if r.crtBalnum != msg.Balnum {
log.Println("Received 2a for different ballot: ", msg.Balnum)
return
}
crtbal := r.ballotArray[r.crtBalnum]
crtbal.received2a = true
crtbal.status = PHASE2
dlog.Println("old cstruct", crtbal.cstruct)
cids := make([]int32, 0)
if crtbal.cstruct == nil || len(crtbal.cstruct) == 0 {
crtbal.cstruct = msg.Cstruct
} else {
for _, ocid := range crtbal.cstruct {
present := false
for _, cid := range msg.Cstruct {
if cid == ocid {
present = true
break
}
}
if !present {
msg.Cstruct = append(msg.Cstruct, ocid)
cids = append(cids, ocid)
}
}
crtbal.cstruct = msg.Cstruct
}
if ALL_TO_ALL {
r.bcast2b(&gpaxosproto.M_2b{r.Id, r.crtBalnum, crtbal.cstruct, cids})
r.tryToLearn()
} else {
r.send2b(&gpaxosproto.M_2b{r.Id, r.crtBalnum, crtbal.cstruct, cids}, r.PeerWriters[r.leaderId])
}
}