Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
c42757e8
Commit
c42757e8
authored
9 months ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
add mutex to map
parent
42396a3f
No related branches found
No related tags found
1 merge request
!1037
Resolve "Implement gNMI subscription management"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
controller/nucleus/networkElementWatcher.go
+16
-3
16 additions, 3 deletions
controller/nucleus/networkElementWatcher.go
with
16 additions
and
3 deletions
controller/nucleus/networkElementWatcher.go
+
16
−
3
View file @
c42757e8
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"strconv"
"strconv"
"sync"
"code.fbi.h-da.de/danet/gosdn/controller/config"
"code.fbi.h-da.de/danet/gosdn/controller/config"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
...
@@ -33,9 +34,10 @@ const (
...
@@ -33,9 +34,10 @@ const (
// NetworkElementWatcher is a component that subscribes to network elements via gNMI from within the controller and handles
// NetworkElementWatcher is a component that subscribes to network elements via gNMI from within the controller and handles
// responses by triggering the internal event process.
// responses by triggering the internal event process.
type
NetworkElementWatcher
struct
{
type
NetworkElementWatcher
struct
{
mneService
networkelement
.
Service
mneService
networkelement
.
Service
networkelementSubcriptions
map
[
uuid
.
UUID
]
*
networkelementSubscriptionHelper
// TODO: Mutex stuff here!
networkelementSubscriptionsMutex
sync
.
Mutex
eventService
eventInterfaces
.
Service
networkelementSubcriptions
map
[
uuid
.
UUID
]
*
networkelementSubscriptionHelper
eventService
eventInterfaces
.
Service
}
}
// networkelementSubscriptionHelper is used to store information to stop a running subscribe go routine.
// networkelementSubscriptionHelper is used to store information to stop a running subscribe go routine.
...
@@ -150,6 +152,9 @@ func (n *NetworkElementWatcher) callSubscribe(stopContext context.Context, mne n
...
@@ -150,6 +152,9 @@ func (n *NetworkElementWatcher) callSubscribe(stopContext context.Context, mne n
}
}
func
(
n
*
NetworkElementWatcher
)
addToNetworkElementSubscriptions
(
subID
uuid
.
UUID
,
devSub
*
networkelementSubscriptionHelper
)
{
func
(
n
*
NetworkElementWatcher
)
addToNetworkElementSubscriptions
(
subID
uuid
.
UUID
,
devSub
*
networkelementSubscriptionHelper
)
{
n
.
networkelementSubscriptionsMutex
.
Lock
()
defer
n
.
networkelementSubscriptionsMutex
.
Unlock
()
n
.
networkelementSubcriptions
[
subID
]
=
devSub
n
.
networkelementSubcriptions
[
subID
]
=
devSub
}
}
...
@@ -163,6 +168,9 @@ func (n *NetworkElementWatcher) StopAndRemoveAllNetworkElementSubscriptions() {
...
@@ -163,6 +168,9 @@ func (n *NetworkElementWatcher) StopAndRemoveAllNetworkElementSubscriptions() {
// StopAndRemoveNetworkElementSubscription passes a subscription uuid to stop the running subscription go routing and removes the entry from the map
// StopAndRemoveNetworkElementSubscription passes a subscription uuid to stop the running subscription go routing and removes the entry from the map
// of network element subscriptions.
// of network element subscriptions.
func
(
n
*
NetworkElementWatcher
)
StopAndRemoveNetworkElementSubscription
(
subID
uuid
.
UUID
)
{
func
(
n
*
NetworkElementWatcher
)
StopAndRemoveNetworkElementSubscription
(
subID
uuid
.
UUID
)
{
n
.
networkelementSubscriptionsMutex
.
Lock
()
defer
n
.
networkelementSubscriptionsMutex
.
Unlock
()
n
.
networkelementSubcriptions
[
subID
]
.
stopFunc
()
n
.
networkelementSubcriptions
[
subID
]
.
stopFunc
()
delete
(
n
.
networkelementSubcriptions
,
subID
)
delete
(
n
.
networkelementSubcriptions
,
subID
)
}
}
...
@@ -253,6 +261,8 @@ func (n *NetworkElementWatcher) mergeGnmiSubscriptions(gNMISusbcriptionPathsFrom
...
@@ -253,6 +261,8 @@ func (n *NetworkElementWatcher) mergeGnmiSubscriptions(gNMISusbcriptionPathsFrom
// GetAllSubscriptionInformations returns the information of all running sunscriptions.
// GetAllSubscriptionInformations returns the information of all running sunscriptions.
func
(
n
*
NetworkElementWatcher
)
GetAllSubscriptionInformations
()
[]
*
networkelementSubscriptionHelper
{
func
(
n
*
NetworkElementWatcher
)
GetAllSubscriptionInformations
()
[]
*
networkelementSubscriptionHelper
{
var
information
[]
*
networkelementSubscriptionHelper
var
information
[]
*
networkelementSubscriptionHelper
n
.
networkelementSubscriptionsMutex
.
Lock
()
defer
n
.
networkelementSubscriptionsMutex
.
Unlock
()
for
_
,
info
:=
range
n
.
networkelementSubcriptions
{
for
_
,
info
:=
range
n
.
networkelementSubcriptions
{
information
=
append
(
information
,
info
)
information
=
append
(
information
,
info
)
...
@@ -263,6 +273,9 @@ func (n *NetworkElementWatcher) GetAllSubscriptionInformations() []*networkeleme
...
@@ -263,6 +273,9 @@ func (n *NetworkElementWatcher) GetAllSubscriptionInformations() []*networkeleme
// GetSubscriptionInformations returns the information for one specific subscription referenced by its ID.
// GetSubscriptionInformations returns the information for one specific subscription referenced by its ID.
func
(
n
*
NetworkElementWatcher
)
GetSubscriptionInformations
(
subID
uuid
.
UUID
)
(
*
networkelementSubscriptionHelper
,
error
)
{
func
(
n
*
NetworkElementWatcher
)
GetSubscriptionInformations
(
subID
uuid
.
UUID
)
(
*
networkelementSubscriptionHelper
,
error
)
{
n
.
networkelementSubscriptionsMutex
.
Lock
()
defer
n
.
networkelementSubscriptionsMutex
.
Unlock
()
information
,
ok
:=
n
.
networkelementSubcriptions
[
subID
]
information
,
ok
:=
n
.
networkelementSubcriptions
[
subID
]
if
!
ok
{
if
!
ok
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Couldn't retrieve information for subscription with ID: %s"
,
subID
.
String
()))
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Couldn't retrieve information for subscription with ID: %s"
,
subID
.
String
()))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment