Code Review
/
ric-plt
/
submgr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
xapp-frame version change
[ric-plt/submgr.git]
/
pkg
/
control
/
registry.go
diff --git
a/pkg/control/registry.go
b/pkg/control/registry.go
index
b816b61
..
9e4eaaa
100644
(file)
--- a/
pkg/control/registry.go
+++ b/
pkg/control/registry.go
@@
-54,7
+54,7
@@
func (r *Registry) QueryHandler() (models.SubscriptionList, error) {
resp := models.SubscriptionList{}
for _, subs := range r.register {
subs.mutex.Lock()
resp := models.SubscriptionList{}
for _, subs := range r.register {
subs.mutex.Lock()
- resp = append(resp, &models.SubscriptionData{SubscriptionID: int64(subs.ReqId.
Seq
), Meid: subs.Meid.RanName, Endpoint: subs.EpList.StringList()})
+ resp = append(resp, &models.SubscriptionData{SubscriptionID: int64(subs.ReqId.
InstanceId
), Meid: subs.Meid.RanName, Endpoint: subs.EpList.StringList()})
subs.mutex.Unlock()
}
return resp, nil
subs.mutex.Unlock()
}
return resp, nil
@@
-62,10
+62,10
@@
func (r *Registry) QueryHandler() (models.SubscriptionList, error) {
func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, error) {
if len(r.subIds) > 0 {
func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, error) {
if len(r.subIds) > 0 {
- s
equenceNumber
:= r.subIds[0]
+ s
ubId
:= r.subIds[0]
r.subIds = r.subIds[1:]
r.subIds = r.subIds[1:]
- if _, ok := r.register[s
equenceNumber
]; ok == true {
- r.subIds = append(r.subIds, s
equenceNumber
)
+ if _, ok := r.register[s
ubId
]; ok == true {
+ r.subIds = append(r.subIds, s
ubId
)
return nil, fmt.Errorf("Registry: Failed to reserve subscription exists")
}
subs := &Subscription{
return nil, fmt.Errorf("Registry: Failed to reserve subscription exists")
}
subs := &Subscription{
@@
-75,10
+75,10
@@
func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubs
valid: true,
}
subs.ReqId.Id = 123
valid: true,
}
subs.ReqId.Id = 123
- subs.ReqId.
Seq = sequenceNumber
+ subs.ReqId.
InstanceId = subId
if subs.EpList.AddEndpoint(trans.GetEndpoint()) == false {
if subs.EpList.AddEndpoint(trans.GetEndpoint()) == false {
- r.subIds = append(r.subIds, subs.ReqId.
Seq
)
+ r.subIds = append(r.subIds, subs.ReqId.
InstanceId
)
return nil, fmt.Errorf("Registry: Endpoint existing already in subscription")
}
return nil, fmt.Errorf("Registry: Endpoint existing already in subscription")
}
@@
-141,6
+141,8
@@
func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.
if actionType == e2ap.E2AP_ActionTypePolicy {
if subs, ok := r.register[trans.GetSubId()]; ok {
xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found", subs.String())
if actionType == e2ap.E2AP_ActionTypePolicy {
if subs, ok := r.register[trans.GetSubId()]; ok {
xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found", subs.String())
+ // Update message data to subscription
+ subs.SubReqMsg = subReqMsg
subs.SetCachedResponse(nil, true)
return subs, nil
}
subs.SetCachedResponse(nil, true)
return subs, nil
}
@@
-168,23
+170,23
@@
func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.
// Subscription route updates
//
if epamount == 1 {
// Subscription route updates
//
if epamount == 1 {
- subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.
Seq
)}
+ subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.
InstanceId
)}
err = r.rtmgrClient.SubscriptionRequestCreate(subRouteAction)
} else {
err = r.rtmgrClient.SubscriptionRequestCreate(subRouteAction)
} else {
- subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.
Seq
)}
+ subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.
InstanceId
)}
err = r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
}
r.mutex.Lock()
if err != nil {
if newAlloc {
err = r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
}
r.mutex.Lock()
if err != nil {
if newAlloc {
- r.subIds = append(r.subIds, subs.ReqId.
Seq
)
+ r.subIds = append(r.subIds, subs.ReqId.
InstanceId
)
}
return nil, err
}
if newAlloc {
}
return nil, err
}
if newAlloc {
- r.register[subs.ReqId.
Seq
] = subs
+ r.register[subs.ReqId.
InstanceId
] = subs
}
xapp.Logger.Debug("CREATE %s", subs.String())
xapp.Logger.Debug("Registry: substable=%v", r.register)
}
xapp.Logger.Debug("CREATE %s", subs.String())
xapp.Logger.Debug("Registry: substable=%v", r.register)
@@
-194,6
+196,7
@@
func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.
func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (uint64, error) {
var reportFound bool = false
var policyFound bool = false
func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (uint64, error) {
var reportFound bool = false
var policyFound bool = false
+ var insertFound bool = false
for _, acts := range subReqMsg.ActionSetups {
if acts.ActionType == e2ap.E2AP_ActionTypeReport {
for _, acts := range subReqMsg.ActionSetups {
if acts.ActionType == e2ap.E2AP_ActionTypeReport {
@@
-202,9
+205,12
@@
func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (ui
if acts.ActionType == e2ap.E2AP_ActionTypePolicy {
policyFound = true
}
if acts.ActionType == e2ap.E2AP_ActionTypePolicy {
policyFound = true
}
+ if acts.ActionType == e2ap.E2AP_ActionTypeInsert {
+ insertFound = true
+ }
}
}
- if reportFound == true && policyFound == true {
- return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("
Report and Policy
in same RICactions-ToBeSetup-List")
+ if reportFound == true && policyFound == true
|| reportFound == true && insertFound == true || policyFound == true && insertFound == true
{
+ return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("
Different action types (Report, Policy or Insert)
in same RICactions-ToBeSetup-List")
}
if reportFound == true {
return e2ap.E2AP_ActionTypeReport, nil
}
if reportFound == true {
return e2ap.E2AP_ActionTypeReport, nil
@@
-212,6
+218,9
@@
func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (ui
if policyFound == true {
return e2ap.E2AP_ActionTypePolicy, nil
}
if policyFound == true {
return e2ap.E2AP_ActionTypePolicy, nil
}
+ if insertFound == true {
+ return e2ap.E2AP_ActionTypeInsert, nil
+ }
return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Invalid action type in RICactions-ToBeSetup-List")
}
return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Invalid action type in RICactions-ToBeSetup-List")
}
@@
-225,7
+234,7
@@
func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
delStatus := subs.EpList.DelEndpoint(trans.GetEndpoint())
epamount := subs.EpList.Size()
delStatus := subs.EpList.DelEndpoint(trans.GetEndpoint())
epamount := subs.EpList.Size()
- s
eqId := subs.ReqId.Seq
+ s
ubId := subs.ReqId.InstanceId
if delStatus == false {
return nil
if delStatus == false {
return nil
@@
-244,9
+253,9
@@
func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
//
// Subscription route delete
//
//
// Subscription route delete
//
- tmpList := RmrEndpointList{}
+ tmpList :=
xapp.
RmrEndpointList{}
tmpList.AddEndpoint(trans.GetEndpoint())
tmpList.AddEndpoint(trans.GetEndpoint())
- subRouteAction := SubRouteInfo{tmpList, uint16(s
eq
Id)}
+ subRouteAction := SubRouteInfo{tmpList, uint16(s
ub
Id)}
r.rtmgrClient.SubscriptionRequestDelete(subRouteAction)
//
r.rtmgrClient.SubscriptionRequestDelete(subRouteAction)
//
@@
-255,18
+264,18
@@
func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
r.mutex.Lock()
defer r.mutex.Unlock()
r.mutex.Lock()
defer r.mutex.Unlock()
- if _, ok := r.register[s
eq
Id]; ok {
+ if _, ok := r.register[s
ub
Id]; ok {
xapp.Logger.Debug("RELEASE %s", subs.String())
xapp.Logger.Debug("RELEASE %s", subs.String())
- delete(r.register, s
eq
Id)
+ delete(r.register, s
ub
Id)
xapp.Logger.Debug("Registry: substable=%v", r.register)
}
xapp.Logger.Debug("Registry: substable=%v", r.register)
}
- r.subIds = append(r.subIds, s
eq
Id)
+ r.subIds = append(r.subIds, s
ub
Id)
} else if subs.EpList.Size() > 0 {
//
// Subscription route updates
//
} else if subs.EpList.Size() > 0 {
//
// Subscription route updates
//
- subRouteAction := SubRouteInfo{subs.EpList, uint16(s
eq
Id)}
+ subRouteAction := SubRouteInfo{subs.EpList, uint16(s
ub
Id)}
r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
}
r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
}
@@
-275,22
+284,22
@@
func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
return nil
}
return nil
}
-func (r *Registry) GetSubscription(s
n
uint32) *Subscription {
+func (r *Registry) GetSubscription(s
ubId
uint32) *Subscription {
r.mutex.Lock()
defer r.mutex.Unlock()
r.mutex.Lock()
defer r.mutex.Unlock()
- if _, ok := r.register[s
n
]; ok {
- return r.register[s
n
]
+ if _, ok := r.register[s
ubId
]; ok {
+ return r.register[s
ubId
]
}
return nil
}
}
return nil
}
-func (r *Registry) GetSubscriptionFirstMatch(
i
ds []uint32) (*Subscription, error) {
+func (r *Registry) GetSubscriptionFirstMatch(
subI
ds []uint32) (*Subscription, error) {
r.mutex.Lock()
defer r.mutex.Unlock()
r.mutex.Lock()
defer r.mutex.Unlock()
- for _,
id := range i
ds {
- if _, ok := r.register[
i
d]; ok {
- return r.register[
i
d], nil
+ for _,
subId := range subI
ds {
+ if _, ok := r.register[
subI
d]; ok {
+ return r.register[
subI
d], nil
}
}
}
}
- return nil, fmt.Errorf("No valid subscription found with
ids %v", i
ds)
+ return nil, fmt.Errorf("No valid subscription found with
subIds %v", subI
ds)
}
}