示例#1
0
func (this *TxResultHandler) Process(session *netlib.Session, data interface{}) error {
	logger.Trace("TxResultHandler.Process")
	if tr, ok := data.(*protocol.TransactResult); ok {
		if !transact.ProcessTransResult(transact.TransNodeID(tr.GetMyTId()), transact.TransNodeID(tr.GetChildTId()), int(tr.GetRetCode()), tr.GetCustomData()) {
			return errors.New("TxResultHandler error, tid=" + strconv.FormatInt(tr.GetMyTId(), 16))
		}
	}
	return nil
}
示例#2
0
func (this *TxCtrlCmdHandler) Process(session *netlib.Session, data interface{}) error {
	logger.Trace("TxCtrlCmdHandler.Process")
	if txcmd, ok := data.(*protocol.TransactCtrlCmd); ok {
		if !transact.ProcessTransCmd(transact.TransNodeID(txcmd.GetTId()), transact.TransCmd(txcmd.GetCmd())) {
			return errors.New("TxCtrlCmdHandler error, tid=" + strconv.FormatInt(txcmd.GetTId(), 16) + " cmd=" + strconv.Itoa(int(txcmd.GetCmd())))
		}
	}
	return nil
}
示例#3
0
func (this *TxStartHandler) Process(session *netlib.Session, data interface{}) error {
	logger.Trace("TxStartHandler.Process")
	if ts, ok := data.(*protocol.TransactStart); ok {
		netptnp := ts.GetParenTNP()
		if netptnp == nil {
			return nil
		}
		netmtnp := ts.GetMyTNP()
		if netmtnp == nil {
			return nil
		}

		ptnp := &transact.TransNodeParam{
			TId:        transact.TransNodeID(netptnp.GetTransNodeID()),
			Tt:         transact.TransType(netptnp.GetTransType()),
			Ot:         transact.TransOwnerType(netptnp.GetOwnerType()),
			Tct:        transact.TransactCommitPolicy(netptnp.GetTransCommitType()),
			Oid:        int(netptnp.GetOwnerID()),
			SkeletonID: int(netptnp.GetSkeletonID()),
			LevelNo:    int(netptnp.GetLevelNo()),
			AreaID:     int(netptnp.GetAreaID()),
			TimeOut:    time.Duration(netptnp.GetTimeOut()),
		}
		mtnp := &transact.TransNodeParam{
			TId:        transact.TransNodeID(netmtnp.GetTransNodeID()),
			Tt:         transact.TransType(netmtnp.GetTransType()),
			Ot:         transact.TransOwnerType(netmtnp.GetOwnerType()),
			Tct:        transact.TransactCommitPolicy(netmtnp.GetTransCommitType()),
			Oid:        int(netmtnp.GetOwnerID()),
			SkeletonID: int(netmtnp.GetSkeletonID()),
			LevelNo:    int(netmtnp.GetLevelNo()),
			AreaID:     int(netmtnp.GetAreaID()),
			TimeOut:    time.Duration(netmtnp.GetTimeOut()),
		}

		if !transact.ProcessTransStart(ptnp, mtnp, ts.GetCustomData(), mtnp.TimeOut) {
			return errors.New("TxStartHandler error, tid=" + strconv.FormatInt(netmtnp.GetTransNodeID(), 16))
		}
	}
	return nil
}