2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
23 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
24 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
32 type TransactionXappKey struct {
34 Xid string // xapp xid in req
37 func (key *TransactionXappKey) String() string {
38 return key.RmrEndpoint.String() + "/" + key.Xid
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
44 type Transaction struct {
46 tracker *Tracker //tracker instance
47 Subs *Subscription //related subscription
48 RmrEndpoint RmrEndpoint //xapp endpoint
49 Mtype int //type of initiating message
50 Xid string //xapp xid in req
51 Meid *xapp.RMRMeid //meid transaction related
52 SubReqMsg *e2ap.E2APSubscriptionRequest //SubReq TODO: maybe own transactions per type
53 SubDelReqMsg *e2ap.E2APSubscriptionDeleteRequest //SubDelReq TODO: maybe own transactions per type
54 Payload []byte //packed message to optimize retransmissions
55 PayloadLen int //packed message len to optimize retransmissions
57 ForwardRespToXapp bool
60 func (t *Transaction) String() string {
62 defer t.mutex.Unlock()
63 var subId string = "?"
65 subId = strconv.FormatUint(uint64(t.Subs.Seq), 10)
67 return subId + "/" + t.RmrEndpoint.String() + "/" + t.Xid
70 func (t *Transaction) GetXid() string {
72 defer t.mutex.Unlock()
76 func (t *Transaction) GetMtype() int {
78 defer t.mutex.Unlock()
82 func (t *Transaction) GetMeid() *xapp.RMRMeid {
84 defer t.mutex.Unlock()
91 func (t *Transaction) GetSrc() string {
93 defer t.mutex.Unlock()
94 return t.RmrEndpoint.String()
97 func (t *Transaction) CheckResponseReceived() bool {
99 defer t.mutex.Unlock()
100 if t.RespReceived == false {
101 t.RespReceived = true
107 func (t *Transaction) RetryTransaction() {
109 defer t.mutex.Unlock()
110 t.RespReceived = false
113 func (t *Transaction) Release() {
115 defer t.mutex.Unlock()
117 t.Subs.UnSetTransaction(t)
119 if t.tracker != nil {
120 xappkey := TransactionXappKey{t.RmrEndpoint, t.Xid}
121 t.tracker.UnTrackTransaction(xappkey)