Change-Id: I687dbe101da773b6a069f9909e0eb6ca9c410fc3
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
import (
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
import (
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+ "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-func (c *Control) rmrSend(desc string, subs *Subscription, trans *Transaction, payload []byte, payloadLen int) (err error) {
+func (c *Control) rmrSend(desc string, subs *Subscription, trans *Transaction, payload *packer.PackedData) (err error) {
params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = trans.GetMtype()
params.SubId = int(subs.GetSubId())
params.Xid = ""
params.Meid = subs.GetMeid()
params.Src = ""
params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = trans.GetMtype()
params.SubId = int(subs.GetSubId())
params.Xid = ""
params.Meid = subs.GetMeid()
params.Src = ""
- params.PayloadLen = payloadLen
- params.Payload = payload
+ params.PayloadLen = len(payload.Buf)
+ params.Payload = payload.Buf
params.Mbuf = nil
return c.rmrSendRaw(desc, params)
}
params.Mbuf = nil
return c.rmrSendRaw(desc, params)
}
-func (c *Control) rmrReplyToSender(desc string, subs *Subscription, trans *Transaction, mType int, payload []byte, payloadLen int) (err error) {
+func (c *Control) rmrReplyToSender(desc string, subs *Subscription, trans *Transaction, mType int, payload *packer.PackedData) (err error) {
params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = mType
params.SubId = int(subs.GetSubId())
params.Xid = trans.GetXid()
params.Meid = trans.GetMeid()
params.Src = ""
params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = mType
params.SubId = int(subs.GetSubId())
params.Xid = trans.GetXid()
params.Meid = trans.GetMeid()
params.Src = ""
- params.PayloadLen = payloadLen
- params.Payload = payload
+ params.PayloadLen = len(payload.Buf)
+ params.Payload = payload.Buf
params.Mbuf = nil
return c.rmrSendRaw(desc, params)
params.Mbuf = nil
return c.rmrSendRaw(desc, params)
//
// This is intermediate solution while improving message handling
//
//
// This is intermediate solution while improving message handling
//
- packedData, err := c.e2ap.PackSubscriptionRequest(trans.SubReqMsg)
+ trans.Payload, err = c.e2ap.PackSubscriptionRequest(trans.SubReqMsg)
if err != nil {
xapp.Logger.Error("SubReq: %s for trans %s", err.Error(), trans)
subs.Release()
if err != nil {
xapp.Logger.Error("SubReq: %s for trans %s", err.Error(), trans)
subs.Release()
- //Optimize and store packed message to be sent (for retransmission). Again owned by subscription?
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
-
- c.rmrSend("SubReq: SubReq to E2T", subs, trans, trans.Payload, trans.PayloadLen)
+ c.rmrSend("SubReq: SubReq to E2T", subs, trans, trans.Payload)
c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
xapp.Logger.Debug("SubReq: Debugging trans table = %v", c.tracker.transactionXappTable)
c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
xapp.Logger.Debug("SubReq: Debugging trans table = %v", c.tracker.transactionXappTable)
- packedData, err := c.e2ap.PackSubscriptionResponse(trans.SubRespMsg)
+ trans.Payload, err = c.e2ap.PackSubscriptionResponse(trans.SubRespMsg)
if err != nil {
xapp.Logger.Error("SubResp: %s for trans %s", err.Error(), trans)
trans.Release()
return
}
if err != nil {
xapp.Logger.Error("SubResp: %s for trans %s", err.Error(), trans)
trans.Release()
return
}
- //Optimize and store packed message to be sent.
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
-
subs.Confirmed()
trans.Release()
subs.Confirmed()
trans.Release()
- c.rmrReplyToSender("SubResp: SubResp to xapp", subs, trans, 12011, trans.Payload, trans.PayloadLen)
+ c.rmrReplyToSender("SubResp: SubResp to xapp", subs, trans, 12011, trans.Payload)
- packedData, err := c.e2ap.PackSubscriptionFailure(trans.SubFailMsg)
+ trans.Payload, err = c.e2ap.PackSubscriptionFailure(trans.SubFailMsg)
- //Optimize and store packed message to be sent.
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
- c.rmrReplyToSender("SubFail: SubFail to xapp", subs, trans, 12012, trans.Payload, trans.PayloadLen)
+ c.rmrReplyToSender("SubFail: SubFail to xapp", subs, trans, 12012, trans.Payload)
time.Sleep(3 * time.Second)
} else {
//TODO error handling improvement
time.Sleep(3 * time.Second)
} else {
//TODO error handling improvement
- c.rmrSend("SubReq timeout: SubReq to E2T", subs, trans, trans.Payload, trans.PayloadLen)
+ c.rmrSend("SubReq timeout: SubReq to E2T", subs, trans, trans.Payload)
tryCount++
c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionRequestTimer)
tryCount++
c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionRequestTimer)
deltrans.SubDelReqMsg.RequestId.Id = trans.SubReqMsg.RequestId.Id
deltrans.SubDelReqMsg.RequestId.Seq = uint32(subs.GetSubId())
deltrans.SubDelReqMsg.FunctionId = trans.SubReqMsg.FunctionId
deltrans.SubDelReqMsg.RequestId.Id = trans.SubReqMsg.RequestId.Id
deltrans.SubDelReqMsg.RequestId.Seq = uint32(subs.GetSubId())
deltrans.SubDelReqMsg.FunctionId = trans.SubReqMsg.FunctionId
- packedData, err := c.e2ap.PackSubscriptionDeleteRequest(deltrans.SubDelReqMsg)
+ deltrans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(deltrans.SubDelReqMsg)
if err != nil {
xapp.Logger.Error("SubReq timeout: Packing SubDelReq failed. Err: %v", err)
//TODO improve error handling. Important at least in merge
if err != nil {
xapp.Logger.Error("SubReq timeout: Packing SubDelReq failed. Err: %v", err)
//TODO improve error handling. Important at least in merge
- deltrans.PayloadLen = len(packedData.Buf)
- deltrans.Payload = packedData.Buf
err = subs.SetTransaction(deltrans)
if err != nil {
err = subs.SetTransaction(deltrans)
if err != nil {
- c.rmrSend("SubReq timer: SubDelReq to E2T", subs, deltrans, deltrans.Payload, deltrans.PayloadLen)
+ c.rmrSend("SubReq timer: SubDelReq to E2T", subs, deltrans, deltrans.Payload)
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
return
}
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
return
}
//
// This is intermediate solution while improving message handling
//
//
// This is intermediate solution while improving message handling
//
- packedData, err := c.e2ap.PackSubscriptionDeleteRequest(trans.SubDelReqMsg)
+ trans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(trans.SubDelReqMsg)
if err != nil {
xapp.Logger.Error("SubDelReq: %s for trans %s", err.Error(), trans)
trans.Release()
return
}
if err != nil {
xapp.Logger.Error("SubDelReq: %s for trans %s", err.Error(), trans)
trans.Release()
return
}
- //Optimize and store packed message to be sent (for retransmission). Again owned by subscription?
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
-
- c.rmrSend("SubDelReq: SubDelReq to E2T", subs, trans, trans.Payload, trans.PayloadLen)
+ c.rmrSend("SubDelReq: SubDelReq to E2T", subs, trans, trans.Payload)
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
return
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
return
if tryCount < maxSubDelReqTryCount {
// Set possible to handle new response for the subId
trans.RetryTransaction()
if tryCount < maxSubDelReqTryCount {
// Set possible to handle new response for the subId
trans.RetryTransaction()
- c.rmrSend("SubDelReq timeout: SubDelReq to E2T", subs, trans, trans.Payload, trans.PayloadLen)
+ c.rmrSend("SubDelReq timeout: SubDelReq to E2T", subs, trans, trans.Payload)
tryCount++
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionDeleteRequestTimer)
return
tryCount++
c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionDeleteRequestTimer)
return
trans.SubDelRespMsg.RequestId.Seq = uint32(subs.GetSubId())
trans.SubDelRespMsg.FunctionId = trans.SubDelReqMsg.FunctionId
trans.SubDelRespMsg.RequestId.Seq = uint32(subs.GetSubId())
trans.SubDelRespMsg.FunctionId = trans.SubDelReqMsg.FunctionId
- packedData, err := c.e2ap.PackSubscriptionDeleteResponse(trans.SubDelRespMsg)
+ var err error
+ trans.Payload, err = c.e2ap.PackSubscriptionDeleteResponse(trans.SubDelRespMsg)
- trans.Payload = packedData.Buf
- trans.PayloadLen = len(packedData.Buf)
- c.rmrReplyToSender(desc+": SubDelResp to xapp", subs, trans, 12021, trans.Payload, trans.PayloadLen)
+ c.rmrReplyToSender(desc+": SubDelResp to xapp", subs, trans, 12021, trans.Payload)
time.Sleep(3 * time.Second)
} else {
//TODO error handling improvement
time.Sleep(3 * time.Second)
} else {
//TODO error handling improvement
import (
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
import (
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+ "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"strconv"
"sync"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"strconv"
"sync"
SubDelReqMsg *e2ap.E2APSubscriptionDeleteRequest //SubDelReq TODO: maybe own transactions per type
SubDelRespMsg *e2ap.E2APSubscriptionDeleteResponse //SubDelResp TODO: maybe own transactions per type
SubDelFailMsg *e2ap.E2APSubscriptionDeleteFailure //SubDelFail TODO: maybe own transactions per type
SubDelReqMsg *e2ap.E2APSubscriptionDeleteRequest //SubDelReq TODO: maybe own transactions per type
SubDelRespMsg *e2ap.E2APSubscriptionDeleteResponse //SubDelResp TODO: maybe own transactions per type
SubDelFailMsg *e2ap.E2APSubscriptionDeleteFailure //SubDelFail TODO: maybe own transactions per type
- Payload []byte //packed message to optimize retransmissions
- PayloadLen int //packed message len to optimize retransmissions
+ Payload *packer.PackedData //Encoded message to be send. Optimized
RespReceived bool
ForwardRespToXapp bool
}
RespReceived bool
ForwardRespToXapp bool
}