Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
croft1
floodlight
Commits
d09adf83
Commit
d09adf83
authored
12 years ago
by
Shudong Zhou
Browse files
Options
Downloads
Patches
Plain Diff
Make registerApp() thread safe
parent
888f3937
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/core/util/AppCookie.java
+6
-7
6 additions, 7 deletions
...in/java/net/floodlightcontroller/core/util/AppCookie.java
with
6 additions
and
7 deletions
src/main/java/net/floodlightcontroller/core/util/AppCookie.java
+
6
−
7
View file @
d09adf83
...
@@ -17,8 +17,7 @@
...
@@ -17,8 +17,7 @@
package
net.floodlightcontroller.core.util
;
package
net.floodlightcontroller.core.util
;
import
java.util.HashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.Map
;
/***
/***
* FIXME Need a system for registering/binding applications to a unique ID
* FIXME Need a system for registering/binding applications to a unique ID
...
@@ -34,8 +33,8 @@ public class AppCookie {
...
@@ -34,8 +33,8 @@ public class AppCookie {
static
final
int
USER_BITS
=
32
;
static
final
int
USER_BITS
=
32
;
static
final
int
USER_SHIFT
=
0
;
static
final
int
USER_SHIFT
=
0
;
private
static
Map
<
Integer
,
String
>
appIdMap
=
private
static
ConcurrentHash
Map
<
Integer
,
String
>
appIdMap
=
new
HashMap
<
Integer
,
String
>();
new
Concurrent
HashMap
<
Integer
,
String
>();
/**
/**
* Encapsulate an application ID and a user block of stuff into a cookie
* Encapsulate an application ID and a user block of stuff into a cookie
...
@@ -69,9 +68,9 @@ public class AppCookie {
...
@@ -69,9 +68,9 @@ public class AppCookie {
static
public
void
registerApp
(
int
application
,
String
appName
)
static
public
void
registerApp
(
int
application
,
String
appName
)
throws
AppIDInUseException
throws
AppIDInUseException
{
{
if
(
appIdMap
.
get
(
application
)
!=
null
)
{
String
oldApp
=
appIdMap
.
putIfAbsent
(
application
,
appName
);
throw
new
AppIDInUseException
(
application
,
appIdMap
.
get
(
application
));
if
(
oldApp
!=
null
)
{
throw
new
AppIDInUseException
(
application
,
oldApp
);
}
}
appIdMap
.
put
(
application
,
appName
);
}
}
}
}
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