當前位置: 首頁>>代碼示例>>Golang>>正文


Golang server.Log函數代碼示例

本文整理匯總了Golang中goshawkdb/io/server.Log函數的典型用法代碼示例。如果您正苦於以下問題:Golang Log函數的具體用法?Golang Log怎麽用?Golang Log使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Log函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: maybeStartRoll

func (fo *frameOpen) maybeStartRoll() {
	if !fo.rollActive && fo.currentState == fo && fo.child == nil && fo.writes.Len() == 0 && fo.v.positions != nil &&
		(fo.reads.Len() > fo.uncommittedReads || (len(fo.frameTxnClock.Clock) > fo.frameTxnActions.Len() && fo.parent == nil && fo.reads.Len() == 0 && len(fo.learntFutureReads) == 0)) {
		fo.rollActive = true
		ctxn, varPosMap := fo.createRollClientTxn()
		go func() {
			server.Log(fo.frame, "Starting roll")
			outcome, err := fo.v.vm.RunClientTransaction(ctxn, varPosMap, true)
			ow := ""
			if outcome != nil {
				ow = fmt.Sprint(outcome.Which())
				if outcome.Which() == msgs.OUTCOME_ABORT {
					ow += fmt.Sprintf("-%v", outcome.Abort().Which())
				}
			}
			// fmt.Printf("r%v ", ow)
			server.Log(fo.frame, "Roll finished: outcome", ow, "; err:", err)
			if outcome == nil || outcome.Which() != msgs.OUTCOME_COMMIT {
				fo.v.applyToVar(func() {
					fo.rollActive = false
					if outcome != nil {
						fo.maybeScheduleRoll()
					}
				})
			}
		}()
	} else {
		fo.maybeScheduleRoll()
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:30,代碼來源:frame.go

示例2: TopologyChange

func (sts *SimpleTxnSubmitter) TopologyChange(topology *server.Topology, servers map[common.RMId]paxos.Connection) {
	if topology != nil {
		server.Log("TM setting topology to", topology)
		sts.topology = topology
		sts.resolver = ch.NewResolver(sts.rng, topology.AllRMs)
		sts.hashCache.SetResolverDesiredLen(sts.resolver, topology.AllRMs.NonEmptyLen())
		if topology.RootVarUUId != nil {
			sts.hashCache.AddPosition(topology.RootVarUUId, topology.RootPositions)
		}

		if !topology.Equal(server.BlankTopology) && sts.bufferedSubmissions != nil {
			funcs := sts.bufferedSubmissions
			sts.bufferedSubmissions = nil
			for _, fun := range funcs {
				fun()
			}
		}
	}
	if servers != nil {
		sts.disabledHashCodes = make(map[common.RMId]server.EmptyStruct, len(sts.topology.AllRMs))
		for _, rmId := range sts.topology.AllRMs {
			if _, found := servers[rmId]; !found {
				sts.disabledHashCodes[rmId] = server.EmptyStructVal
			}
		}
		sts.connections = servers
		server.Log("TM disabled hash codes", sts.disabledHashCodes)
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:29,代碼來源:simpletxnsubmitter.go

示例3: start

func (awtd *acceptorWriteToDisk) start() {
	outcome := awtd.outcome
	outcomeCap := (*msgs.Outcome)(outcome)
	awtd.sendToAll = awtd.sendToAll || outcomeCap.Which() == msgs.OUTCOME_COMMIT
	sendToAll := awtd.sendToAll
	stateSeg := capn.NewBuffer(nil)
	state := msgs.NewRootAcceptorState(stateSeg)
	state.SetTxn(*awtd.ballotAccumulator.Txn)
	state.SetOutcome(*outcomeCap)
	state.SetSendToAll(awtd.sendToAll)
	state.SetInstances(awtd.ballotAccumulator.AddInstancesToSeg(stateSeg))

	data := server.SegToBytes(stateSeg)

	// to ensure correct order of writes, schedule the write from
	// the current go-routine...
	server.Log(awtd.txnId, "Writing 2B to disk...")
	future := awtd.acceptorManager.Disk.ReadWriteTransaction(false, func(rwtxn *mdbs.RWTxn) (interface{}, error) {
		return nil, rwtxn.Put(db.DB.BallotOutcomes, awtd.txnId[:], data, 0)
	})
	go func() {
		// ... but process the result in a new go-routine to avoid blocking the executor.
		if _, err := future.ResultError(); err != nil {
			log.Printf("Error: %v Acceptor Write error: %v", awtd.txnId, err)
			return
		}
		server.Log(awtd.txnId, "Writing 2B to disk...done.")
		awtd.acceptorManager.Exe.Enqueue(func() { awtd.writeDone(outcome, sendToAll) })
	}()
}
開發者ID:chang290,項目名稱:server,代碼行數:30,代碼來源:acceptor.go

示例4: TxnSubmissionAbortReceived

// from network
func (pm *ProposerManager) TxnSubmissionAbortReceived(sender common.RMId, txnId *common.TxnId) {
	if proposer, found := pm.proposers[*txnId]; found {
		server.Log(txnId, "TSA received from", sender, "(proposer found)")
		proposer.Abort()
	} else {
		server.Log(txnId, "TSA received from", sender, "(ignored)")
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:9,代碼來源:proposermanager.go

示例5: TxnGloballyCompleteReceived

// from network
func (pm *ProposerManager) TxnGloballyCompleteReceived(sender common.RMId, txnId *common.TxnId) {
	if proposer, found := pm.proposers[*txnId]; found {
		server.Log(txnId, "TGC received from", sender, "(proposer found)")
		proposer.TxnGloballyCompleteReceived(sender)
	} else {
		server.Log(txnId, "TGC received from", sender, "(ignored)")
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:9,代碼來源:proposermanager.go

示例6: ReceiveTxn

func (v *Var) ReceiveTxn(action *localAction) {
	server.Log(v.UUId, "ReceiveTxn", action)
	isRead, isWrite := action.IsRead(), action.IsWrite()

	if isRead && action.Retry {
		if voted := v.curFrame.ReadRetry(action); !voted {
			v.AddWriteSubscriber(action.Id,
				func(v *Var, value []byte, refs *msgs.VarIdPos_List, newtxn *Txn) {
					if voted := v.curFrame.ReadRetry(action); voted {
						v.RemoveWriteSubscriber(action.Id)
					}
				})
		}
		return
	}

	switch {
	case isRead && isWrite:
		v.curFrame.AddReadWrite(action)
	case isRead:
		v.curFrame.AddRead(action)
	default:
		v.curFrame.AddWrite(action)
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:25,代碼來源:var.go

示例7: VarFromData

func VarFromData(data []byte, exe *dispatcher.Executor, disk *mdbs.MDBServer, vm *VarManager) (*Var, error) {
	seg, _, err := capn.ReadFromMemoryZeroCopy(data)
	if err != nil {
		return nil, err
	}
	varCap := msgs.ReadRootVar(seg)

	v := newVar(common.MakeVarUUId(varCap.Id()), exe, disk, vm)
	positions := varCap.Positions()
	if positions.Len() != 0 {
		v.positions = (*common.Positions)(&positions)
	}

	writeTxnId := common.MakeTxnId(varCap.WriteTxnId())
	writeTxnClock := VectorClockFromCap(varCap.WriteTxnClock())
	writesClock := VectorClockFromCap(varCap.WritesClock())
	server.Log(v.UUId, "Restored", writeTxnId)

	if result, err := disk.ReadonlyTransaction(func(rtxn *mdbs.RTxn) (interface{}, error) {
		return db.ReadTxnFromDisk(rtxn, writeTxnId)
	}).ResultError(); err == nil {
		if result == nil || result.(*msgs.Txn) == nil {
			panic(fmt.Sprintf("%v Unable to find txn %v on disk (%v)", v.UUId, writeTxnId, result))
		}
		actions := result.(*msgs.Txn).Actions()
		v.curFrame = NewFrame(nil, v, writeTxnId, &actions, writeTxnClock, writesClock)
		v.curFrameOnDisk = v.curFrame
	} else {
		return nil, err
	}

	v.varCap = &varCap

	return v, nil
}
開發者ID:chang290,項目名稱:server,代碼行數:35,代碼來源:var.go

示例8: TxnLocallyComplete

func (palc *proposerAwaitLocallyComplete) TxnLocallyComplete() {
	if palc.currentState == palc && !palc.callbackInvoked {
		server.Log(palc.txnId, "Txn locally completed")
		palc.callbackInvoked = true
		palc.maybeWriteToDisk()
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:7,代碼來源:proposer.go

示例9: AddReadWrite

func (fo *frameOpen) AddReadWrite(action *localAction) {
	txn := action.Txn
	server.Log(fo.frame, "AddReadWrite", txn, action.readVsn)
	switch {
	case fo.currentState != fo:
		panic(fmt.Sprintf("%v AddReadWrite called for %v with frame in state %v", fo.v, txn, fo.currentState))
	case fo.writeVoteClock != nil || fo.writes.Len() != 0 || (fo.maxUncommittedRead != nil && action.LessThan(fo.maxUncommittedRead)) || fo.frameTxnActions == nil || len(fo.learntFutureReads) != 0 || (!action.IsRoll() && fo.isLocked()):
		action.VoteDeadlock(fo.frameTxnClock)
	case !fo.frameTxnId.Equal(action.readVsn):
		action.VoteBadRead(fo.frameTxnClock, fo.frameTxnId, fo.frameTxnActions)
		fo.v.maybeMakeInactive()
	case fo.writes.Get(action) == nil:
		fo.rwPresent = true
		fo.uncommittedWrites++
		action.frame = fo.frame
		if fo.uncommittedReads == 0 {
			fo.writes.Insert(action, uncommitted)
			fo.calculateWriteVoteClock()
			if !action.VoteCommit(fo.writeVoteClock) {
				fo.ReadWriteAborted(action, true)
			}
		} else {
			fo.writes.Insert(action, postponed)
		}
	default:
		panic(fmt.Sprintf("%v AddReadWrite called for known txn %v", fo.frame, txn))
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:28,代碼來源:frame.go

示例10: AddRead

func (fo *frameOpen) AddRead(action *localAction) {
	txn := action.Txn
	server.Log(fo.frame, "AddRead", txn, action.readVsn)
	switch {
	case fo.currentState != fo:
		panic(fmt.Sprintf("%v AddRead called for %v with frame in state %v", fo.v, txn, fo.currentState))
	case fo.writeVoteClock != nil || (fo.writes.Len() != 0 && fo.writes.First().Key.LessThan(action)) || fo.frameTxnActions == nil || fo.isLocked():
		// We could have learnt a write at this point but we're still fine to accept smaller reads.
		action.VoteDeadlock(fo.frameTxnClock)
	case !fo.frameTxnId.Equal(action.readVsn):
		action.VoteBadRead(fo.frameTxnClock, fo.frameTxnId, fo.frameTxnActions)
		fo.v.maybeMakeInactive()
	case fo.reads.Get(action) == nil:
		fo.uncommittedReads++
		fo.reads.Insert(action, uncommitted)
		if fo.maxUncommittedRead == nil || fo.maxUncommittedRead.LessThan(action) {
			fo.maxUncommittedRead = action
		}
		action.frame = fo.frame
		if !action.VoteCommit(fo.readVoteClock) {
			fo.ReadAborted(action)
		}
	default:
		panic(fmt.Sprintf("%v AddRead called for known txn %v", fo.frame, txn))
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:26,代碼來源:frame.go

示例11: AddWrite

func (fo *frameOpen) AddWrite(action *localAction) {
	txn := action.Txn
	server.Log(fo.frame, "AddWrite", txn)
	cid := txn.Id.ClientId()
	_, found := fo.clientWrites[cid]
	switch {
	case fo.currentState != fo:
		panic(fmt.Sprintf("%v AddWrite called for %v with frame in state %v", fo.v, txn, fo.currentState))
	case fo.rwPresent || (fo.maxUncommittedRead != nil && action.LessThan(fo.maxUncommittedRead)) || found || len(fo.learntFutureReads) != 0 || fo.isLocked():
		action.VoteDeadlock(fo.frameTxnClock)
	case fo.writes.Get(action) == nil:
		fo.uncommittedWrites++
		fo.clientWrites[cid] = server.EmptyStructVal
		action.frame = fo.frame
		if fo.uncommittedReads == 0 {
			fo.writes.Insert(action, uncommitted)
			fo.calculateWriteVoteClock()
			if !action.VoteCommit(fo.writeVoteClock) {
				fo.WriteAborted(action, true)
			}
		} else {
			fo.writes.Insert(action, postponed)
		}
	default:
		panic(fmt.Sprintf("%v AddWrite called for known txn %v", fo.frame, txn))
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:27,代碼來源:frame.go

示例12: OneATxnVotesReceived

func (am *AcceptorManager) OneATxnVotesReceived(sender common.RMId, txnId *common.TxnId, oneATxnVotes *msgs.OneATxnVotes) {
	instanceRMId := common.RMId(oneATxnVotes.RmId())
	server.Log(txnId, "1A received from", sender, "; instance:", instanceRMId)
	instId := instanceId([instanceIdLen]byte{})
	instIdSlice := instId[:]
	copy(instIdSlice, txnId[:])
	binary.BigEndian.PutUint32(instIdSlice[common.KeyLen:], uint32(instanceRMId))

	replySeg := capn.NewBuffer(nil)
	msg := msgs.NewRootMessage(replySeg)
	oneBTxnVotes := msgs.NewOneBTxnVotes(replySeg)
	msg.SetOneBTxnVotes(oneBTxnVotes)
	oneBTxnVotes.SetRmId(oneATxnVotes.RmId())
	oneBTxnVotes.SetTxnId(oneATxnVotes.TxnId())

	proposals := oneATxnVotes.Proposals()
	promises := msgs.NewTxnVotePromiseList(replySeg, proposals.Len())
	oneBTxnVotes.SetPromises(promises)
	for idx, l := 0, proposals.Len(); idx < l; idx++ {
		proposal := proposals.At(idx)
		vUUId := common.MakeVarUUId(proposal.VarId())
		copy(instIdSlice[common.KeyLen+4:], vUUId[:])
		promise := promises.At(idx)
		promise.SetVarId(vUUId[:])
		am.ensureInstance(txnId, &instId, vUUId).OneATxnVotesReceived(&proposal, &promise)
	}

	NewOneShotSender(server.SegToBytes(replySeg), am.ConnectionManager, sender)
}
開發者ID:chang290,項目名稱:server,代碼行數:29,代碼來源:acceptormanager.go

示例13: newTwoBTxnVotesSender

func newTwoBTxnVotesSender(outcome *msgs.Outcome, txnId *common.TxnId, submitter common.RMId, recipients ...common.RMId) *twoBTxnVotesSender {
	submitterSeg := capn.NewBuffer(nil)
	submitterMsg := msgs.NewRootMessage(submitterSeg)
	submitterMsg.SetSubmissionOutcome(*outcome)

	if outcome.Which() == msgs.OUTCOME_ABORT {
		abort := outcome.Abort()
		abort.SetResubmit() // nuke out the updates as proposers don't need them.
	}

	seg := capn.NewBuffer(nil)
	msg := msgs.NewRootMessage(seg)
	twoB := msgs.NewTwoBTxnVotes(seg)
	msg.SetTwoBTxnVotes(twoB)
	twoB.SetOutcome(*outcome)

	server.Log(txnId, "Sending 2B to", recipients)

	return &twoBTxnVotesSender{
		msg:          server.SegToBytes(seg),
		recipients:   recipients,
		submitterMsg: server.SegToBytes(submitterSeg),
		submitter:    submitter,
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:25,代碼來源:acceptor.go

示例14: Abort

func (pab *proposerAwaitBallots) Abort() {
	if pab.currentState == pab && !pab.allAcceptorsAgreed {
		server.Log(pab.txnId, "Proposer Aborting")
		txnCap := pab.txn.TxnCap
		alloc := AllocForRMId(txnCap, pab.proposerManager.RMId)
		ballots := MakeAbortBallots(txnCap, alloc)
		pab.TxnBallotsComplete(ballots...)
	}
}
開發者ID:chang290,項目名稱:server,代碼行數:9,代碼來源:proposer.go

示例15: DescendentOnDisk

func (fc *frameClosed) DescendentOnDisk() bool {
	if !fc.onDisk {
		server.Log(fc.frame, "DescendentOnDisk")
		fc.onDisk = true
		fc.MaybeCompleteTxns()
		return true
	}
	return false
}
開發者ID:chang290,項目名稱:server,代碼行數:9,代碼來源:frame.go


注:本文中的goshawkdb/io/server.Log函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。