Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
alshabib
2014-10-13 14:16:46 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
94cf3c557b6d600f182fc4c9ee2ca5cb404a19af
94cf3c55
2 parents
cf369910
3fc4a637
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
273 additions
and
66 deletions
core/api/src/main/java/org/onlab/onos/net/LinkKey.java
core/api/src/main/java/org/onlab/onos/net/host/HostClockService.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/HostClockManager.java
core/store/dist/src/main/java/org/onlab/onos/store/impl/MastershipBasedTimestamp.java
core/store/dist/src/main/java/org/onlab/onos/store/impl/WallClockTimestamp.java
core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java
core/store/dist/src/test/java/org/onlab/onos/store/impl/WallClockTimestampTest.java
core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java
core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
core/store/hz/net/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkStore.java
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleLinkStoreTest.java
core/api/src/main/java/org/onlab/onos/net/LinkKey.java
View file @
94cf3c5
package
org
.
onlab
.
onos
.
net
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
java.util.Objects
;
import
org.onlab.onos.net.link.LinkDescription
;
import
com.google.common.base.MoreObjects
;
// TODO Consider renaming.
...
...
@@ -10,7 +14,7 @@ import com.google.common.base.MoreObjects;
/**
* Immutable representation of a link identity.
*/
public
class
LinkKey
{
public
final
class
LinkKey
{
private
final
ConnectPoint
src
;
private
final
ConnectPoint
dst
;
...
...
@@ -39,18 +43,40 @@ public class LinkKey {
* @param src source connection point
* @param dst destination connection point
*/
public
LinkKey
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
this
.
src
=
src
;
this
.
dst
=
dst
;
private
LinkKey
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
this
.
src
=
checkNotNull
(
src
);
this
.
dst
=
checkNotNull
(
dst
);
}
/**
* Creates a link identifier with source and destination connection point.
*
* @param src source connection point
* @param dst destination connection point
* @return a link identifier
*/
public
static
LinkKey
linkKey
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
return
new
LinkKey
(
src
,
dst
);
}
/**
* Creates a link identifier for the specified link.
*
* @param link link descriptor
* @return a link identifier
*/
public
static
LinkKey
linkKey
(
Link
link
)
{
return
new
LinkKey
(
link
.
src
(),
link
.
dst
());
}
/**
* Creates a link identifier for the specified link.
*
* @param desc link description
* @return a link identifier
*/
public
LinkKey
(
Link
link
)
{
this
(
link
.
src
(),
link
.
dst
());
public
static
LinkKey
linkKey
(
LinkDescription
desc
)
{
return
new
LinkKey
(
desc
.
src
(),
desc
.
dst
());
}
@Override
...
...
@@ -65,7 +91,7 @@ public class LinkKey {
}
if
(
obj
instanceof
LinkKey
)
{
final
LinkKey
other
=
(
LinkKey
)
obj
;
return
Objects
.
equals
(
this
.
src
(),
other
.
src
()
)
&&
return
Objects
.
equals
(
this
.
src
,
other
.
src
)
&&
Objects
.
equals
(
this
.
dst
,
other
.
dst
);
}
return
false
;
...
...
@@ -74,7 +100,7 @@ public class LinkKey {
@Override
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"src"
,
src
()
)
.
add
(
"src"
,
src
)
.
add
(
"dst"
,
dst
)
.
toString
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/host/HostClockService.java
0 → 100644
View file @
94cf3c5
package
org
.
onlab
.
onos
.
net
.
host
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.packet.MacAddress
;
/**
* Interface for a logical clock service that issues per host timestamps.
*/
public
interface
HostClockService
{
/**
* Returns a new timestamp for the specified host mac address.
* @param hostMac host MAC address.
* @return timestamp.
*/
public
Timestamp
getTimestamp
(
MacAddress
hostMac
);
}
core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
View file @
94cf3c5
...
...
@@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import
static
com
.
google
.
common
.
collect
.
Multimaps
.
synchronizedSetMultimap
;
import
static
java
.
util
.
concurrent
.
Executors
.
newSingleThreadExecutor
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.
LINK_REMOVED
;
import
static
org
.
onlab
.
onos
.
net
.
LinkKey
.
linkKey
;
import
static
org
.
onlab
.
util
.
Tools
.
namedThreads
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -82,14 +83,14 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
@Override
public
void
addTrackedResources
(
IntentId
intentId
,
Collection
<
Link
>
resources
)
{
for
(
Link
link
:
resources
)
{
intentsByLink
.
put
(
new
L
inkKey
(
link
),
intentId
);
intentsByLink
.
put
(
l
inkKey
(
link
),
intentId
);
}
}
@Override
public
void
removeTrackedResources
(
IntentId
intentId
,
Collection
<
Link
>
resources
)
{
for
(
Link
link
:
resources
)
{
intentsByLink
.
remove
(
new
L
inkKey
(
link
),
intentId
);
intentsByLink
.
remove
(
l
inkKey
(
link
),
intentId
);
}
}
...
...
@@ -125,7 +126,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
if
(
reason
instanceof
LinkEvent
)
{
LinkEvent
linkEvent
=
(
LinkEvent
)
reason
;
if
(
linkEvent
.
type
()
==
LINK_REMOVED
)
{
Set
<
IntentId
>
intentIds
=
intentsByLink
.
get
(
new
L
inkKey
(
linkEvent
.
subject
()));
Set
<
IntentId
>
intentIds
=
intentsByLink
.
get
(
l
inkKey
(
linkEvent
.
subject
()));
toBeRecompiled
.
addAll
(
intentIds
);
}
recompileOnly
=
recompileOnly
&&
linkEvent
.
type
()
==
LINK_REMOVED
;
...
...
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
View file @
94cf3c5
...
...
@@ -1090,7 +1090,7 @@ public class GossipDeviceStore
.
toList
();
if
(
nodeIds
.
size
()
==
1
&&
nodeIds
.
get
(
0
).
equals
(
self
))
{
log
.
info
(
"No other peers in the cluster."
);
log
.
debug
(
"No other peers in the cluster."
);
return
;
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/host/impl/HostClockManager.java
0 → 100644
View file @
94cf3c5
package
org
.
onlab
.
onos
.
store
.
host
.
impl
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.net.host.HostClockService
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.onos.store.impl.WallClockTimestamp
;
import
org.onlab.packet.MacAddress
;
import
org.slf4j.Logger
;
/**
* HostClockService to issue Timestamps based on local wallclock time.
*/
@Component
(
immediate
=
true
)
@Service
public
class
HostClockManager
implements
HostClockService
{
private
final
Logger
log
=
getLogger
(
getClass
());
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
log
.
info
(
"Stopped"
);
}
@Override
public
Timestamp
getTimestamp
(
MacAddress
hostMac
)
{
return
new
WallClockTimestamp
();
}
}
core/store/dist/src/main/java/org/onlab/onos/store/impl/MastershipBasedTimestamp.java
View file @
94cf3c5
...
...
@@ -10,8 +10,12 @@ import com.google.common.base.MoreObjects;
import
com.google.common.collect.ComparisonChain
;
/**
* Default implementation of Timestamp.
* TODO: Better documentation.
* A logical timestamp that derives its value from two things:
* <ul>
* <li> The current mastership term of the device.</li>
* <li> The value of the counter used for tracking topology events observed from
* the device during that current time of a device. </li>
* </ul>
*/
public
final
class
MastershipBasedTimestamp
implements
Timestamp
{
...
...
core/store/dist/src/main/java/org/onlab/onos/store/impl/WallClockTimestamp.java
0 → 100644
View file @
94cf3c5
package
org
.
onlab
.
onos
.
store
.
impl
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
java.util.Objects
;
import
org.onlab.onos.store.Timestamp
;
import
com.google.common.base.MoreObjects
;
import
com.google.common.collect.ComparisonChain
;
/**
* A Timestamp that derives its value from the prevailing
* wallclock time on the controller where it is generated.
*/
public
class
WallClockTimestamp
implements
Timestamp
{
private
final
long
unixTimestamp
;
public
WallClockTimestamp
()
{
unixTimestamp
=
System
.
currentTimeMillis
();
}
@Override
public
int
compareTo
(
Timestamp
o
)
{
checkArgument
(
o
instanceof
WallClockTimestamp
,
"Must be WallClockTimestamp"
,
o
);
WallClockTimestamp
that
=
(
WallClockTimestamp
)
o
;
return
ComparisonChain
.
start
()
.
compare
(
this
.
unixTimestamp
,
that
.
unixTimestamp
)
.
result
();
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
unixTimestamp
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(!(
obj
instanceof
WallClockTimestamp
))
{
return
false
;
}
WallClockTimestamp
that
=
(
WallClockTimestamp
)
obj
;
return
Objects
.
equals
(
this
.
unixTimestamp
,
that
.
unixTimestamp
);
}
@Override
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"unixTimestamp"
,
unixTimestamp
)
.
toString
();
}
/**
* Returns the unixTimestamp.
*
* @return unix timestamp
*/
public
long
unixTimestamp
()
{
return
unixTimestamp
;
}
}
core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java
View file @
94cf3c5
...
...
@@ -67,6 +67,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union;
import
static
org
.
onlab
.
onos
.
net
.
DefaultAnnotations
.
merge
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
INDIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
LinkKey
.
linkKey
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.*;
import
static
org
.
onlab
.
util
.
Tools
.
namedThreads
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -203,7 +204,7 @@ public class GossipLinkStore
@Override
public
Link
getLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
return
links
.
get
(
new
L
inkKey
(
src
,
dst
));
return
links
.
get
(
l
inkKey
(
src
,
dst
));
}
@Override
...
...
@@ -237,14 +238,20 @@ public class GossipLinkStore
final
Timestamped
<
LinkDescription
>
deltaDesc
=
new
Timestamped
<>(
linkDescription
,
newTimestamp
);
LinkEvent
event
=
createOrUpdateLinkInternal
(
providerId
,
deltaDesc
);
LinkKey
key
=
linkKey
(
linkDescription
);
final
LinkEvent
event
;
final
Timestamped
<
LinkDescription
>
mergedDesc
;
synchronized
(
getLinkDescriptions
(
key
))
{
event
=
createOrUpdateLinkInternal
(
providerId
,
deltaDesc
);
mergedDesc
=
getLinkDescriptions
(
key
).
get
(
providerId
);
}
if
(
event
!=
null
)
{
log
.
info
(
"Notifying peers of a link update topology event from providerId: "
+
"{} between src: {} and dst: {}"
,
providerId
,
linkDescription
.
src
(),
linkDescription
.
dst
());
try
{
notifyPeers
(
new
InternalLinkEvent
(
providerId
,
delta
Desc
));
notifyPeers
(
new
InternalLinkEvent
(
providerId
,
merged
Desc
));
}
catch
(
IOException
e
)
{
log
.
info
(
"Failed to notify peers of a link update topology event from providerId: "
+
"{} between src: {} and dst: {}"
,
...
...
@@ -258,7 +265,7 @@ public class GossipLinkStore
ProviderId
providerId
,
Timestamped
<
LinkDescription
>
linkDescription
)
{
LinkKey
key
=
new
LinkKey
(
linkDescription
.
value
().
src
(),
linkDescription
.
value
().
dst
());
LinkKey
key
=
linkKey
(
linkDescription
.
value
());
ConcurrentMap
<
ProviderId
,
Timestamped
<
LinkDescription
>>
descs
=
getLinkDescriptions
(
key
);
synchronized
(
descs
)
{
...
...
@@ -351,7 +358,7 @@ public class GossipLinkStore
@Override
public
LinkEvent
removeLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
final
LinkKey
key
=
new
L
inkKey
(
src
,
dst
);
final
LinkKey
key
=
l
inkKey
(
src
,
dst
);
DeviceId
dstDeviceId
=
dst
.
deviceId
();
Timestamp
timestamp
=
deviceClockService
.
getTimestamp
(
dstDeviceId
);
...
...
@@ -538,7 +545,7 @@ public class GossipLinkStore
.
toList
();
if
(
nodeIds
.
size
()
==
1
&&
nodeIds
.
get
(
0
).
equals
(
self
))
{
log
.
info
(
"No other peers in the cluster."
);
log
.
debug
(
"No other peers in the cluster."
);
return
;
}
...
...
core/store/dist/src/test/java/org/onlab/onos/store/impl/WallClockTimestampTest.java
0 → 100644
View file @
94cf3c5
package
org
.
onlab
.
onos
.
store
.
impl
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.nio.ByteBuffer
;
import
org.junit.Test
;
import
org.onlab.onos.store.Timestamp
;
import
org.onlab.util.KryoPool
;
import
com.google.common.testing.EqualsTester
;
/**
* Tests for {@link WallClockTimestamp}.
*/
public
class
WallClockTimestampTest
{
@Test
public
final
void
testBasic
()
throws
InterruptedException
{
WallClockTimestamp
ts1
=
new
WallClockTimestamp
();
Thread
.
sleep
(
50
);
WallClockTimestamp
ts2
=
new
WallClockTimestamp
();
assertTrue
(
ts1
.
compareTo
(
ts1
)
==
0
);
assertTrue
(
ts2
.
compareTo
(
ts1
)
>
0
);
assertTrue
(
ts1
.
compareTo
(
ts2
)
<
0
);
}
@Test
public
final
void
testKryoSerializable
()
{
WallClockTimestamp
ts1
=
new
WallClockTimestamp
();
final
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
1
*
1024
*
1024
);
final
KryoPool
kryos
=
KryoPool
.
newBuilder
()
.
register
(
WallClockTimestamp
.
class
)
.
build
();
kryos
.
serialize
(
ts1
,
buffer
);
buffer
.
flip
();
Timestamp
copy
=
kryos
.
deserialize
(
buffer
);
new
EqualsTester
()
.
addEqualityGroup
(
ts1
,
copy
)
.
testEquals
();
}
}
core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java
0 → 100644
View file @
94cf3c5
This diff is collapsed. Click to expand it.
core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
View file @
94cf3c5
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl;
import
static
com
.
google
.
common
.
cache
.
CacheBuilder
.
newBuilder
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
INDIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
LinkKey
.
linkKey
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.
LINK_ADDED
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.
LINK_REMOVED
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.
LINK_UPDATED
;
...
...
@@ -122,7 +123,7 @@ public class DistributedLinkStore
@Override
public
Link
getLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
return
links
.
getUnchecked
(
new
L
inkKey
(
src
,
dst
)).
orNull
();
return
links
.
getUnchecked
(
l
inkKey
(
src
,
dst
)).
orNull
();
}
@Override
...
...
@@ -150,7 +151,7 @@ public class DistributedLinkStore
@Override
public
LinkEvent
createOrUpdateLink
(
ProviderId
providerId
,
LinkDescription
linkDescription
)
{
LinkKey
key
=
new
LinkKey
(
linkDescription
.
src
(),
linkDescription
.
dst
()
);
LinkKey
key
=
linkKey
(
linkDescription
);
Optional
<
DefaultLink
>
link
=
links
.
getUnchecked
(
key
);
if
(!
link
.
isPresent
())
{
return
createLink
(
providerId
,
key
,
linkDescription
);
...
...
@@ -216,7 +217,7 @@ public class DistributedLinkStore
@Override
public
LinkEvent
removeLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
synchronized
(
this
)
{
LinkKey
key
=
new
L
inkKey
(
src
,
dst
);
LinkKey
key
=
l
inkKey
(
src
,
dst
);
byte
[]
keyBytes
=
serialize
(
key
);
Link
link
=
deserialize
(
rawLinks
.
remove
(
keyBytes
));
links
.
invalidate
(
key
);
...
...
core/store/hz/net/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
View file @
94cf3c5
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.*;
import
static
org
.
onlab
.
onos
.
net
.
LinkKey
.
linkKey
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.*;
import
java.util.HashMap
;
...
...
@@ -122,8 +123,8 @@ public class DistributedLinkStoreTest {
assertEquals
(
"initialy empty"
,
0
,
Iterables
.
size
(
linkStore
.
getLinks
()));
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId1
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -134,7 +135,7 @@ public class DistributedLinkStoreTest {
Map
<
LinkKey
,
Link
>
links
=
new
HashMap
<>();
for
(
Link
link
:
linkStore
.
getLinks
())
{
links
.
put
(
new
LinkKey
(
link
.
src
(),
link
.
dst
()
),
link
);
links
.
put
(
linkKey
(
link
),
link
);
}
assertLink
(
linkId1
,
DIRECT
,
links
.
get
(
linkId1
));
...
...
@@ -143,9 +144,9 @@ public class DistributedLinkStoreTest {
@Test
public
final
void
testGetDeviceEgressLinks
()
{
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -166,9 +167,9 @@ public class DistributedLinkStoreTest {
@Test
public
final
void
testGetDeviceIngressLinks
()
{
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -191,7 +192,7 @@ public class DistributedLinkStoreTest {
public
final
void
testGetLink
()
{
ConnectPoint
src
=
new
ConnectPoint
(
DID1
,
P1
);
ConnectPoint
dst
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
src
,
dst
);
LinkKey
linkId1
=
l
inkKey
(
src
,
dst
);
putLink
(
linkId1
,
DIRECT
);
...
...
@@ -206,9 +207,9 @@ public class DistributedLinkStoreTest {
public
final
void
testGetEgressLinks
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
l
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -231,9 +232,9 @@ public class DistributedLinkStoreTest {
public
final
void
testGetIngressLinks
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
l
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -282,8 +283,8 @@ public class DistributedLinkStoreTest {
public
final
void
testRemoveLink
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId1
=
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
l
inkKey
(
d2P2
,
d1P1
);
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -306,7 +307,7 @@ public class DistributedLinkStoreTest {
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
final
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
final
LinkKey
linkId1
=
l
inkKey
(
d1P1
,
d2P2
);
final
CountDownLatch
addLatch
=
new
CountDownLatch
(
1
);
LinkStoreDelegate
checkAdd
=
new
LinkStoreDelegate
()
{
...
...
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java
View file @
94cf3c5
...
...
@@ -31,6 +31,6 @@ public class LinkKeySerializer extends Serializer<LinkKey> {
public
LinkKey
read
(
Kryo
kryo
,
Input
input
,
Class
<
LinkKey
>
type
)
{
ConnectPoint
src
=
(
ConnectPoint
)
kryo
.
readClassAndObject
(
input
);
ConnectPoint
dst
=
(
ConnectPoint
)
kryo
.
readClassAndObject
(
input
);
return
new
L
inkKey
(
src
,
dst
);
return
LinkKey
.
l
inkKey
(
src
,
dst
);
}
}
...
...
core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
View file @
94cf3c5
...
...
@@ -108,7 +108,7 @@ public class KryoSerializerTest {
testSerialized
(
ImmutableSet
.
of
());
testSerialized
(
IpPrefix
.
valueOf
(
"192.168.0.1/24"
));
testSerialized
(
IpAddress
.
valueOf
(
"192.168.0.1"
));
testSerialized
(
new
L
inkKey
(
CP1
,
CP2
));
testSerialized
(
LinkKey
.
l
inkKey
(
CP1
,
CP2
));
testSerialized
(
new
NodeId
(
"SomeNodeIdentifier"
));
testSerialized
(
P1
);
testSerialized
(
PID
);
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkStore.java
View file @
94cf3c5
...
...
@@ -42,6 +42,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union;
import
static
org
.
onlab
.
onos
.
net
.
DefaultAnnotations
.
merge
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
INDIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
LinkKey
.
linkKey
;
import
static
org
.
onlab
.
onos
.
net
.
link
.
LinkEvent
.
Type
.*;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
static
com
.
google
.
common
.
collect
.
Multimaps
.
synchronizedSetMultimap
;
...
...
@@ -120,7 +121,7 @@ public class SimpleLinkStore
@Override
public
Link
getLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
return
links
.
get
(
new
L
inkKey
(
src
,
dst
));
return
links
.
get
(
l
inkKey
(
src
,
dst
));
}
@Override
...
...
@@ -148,7 +149,7 @@ public class SimpleLinkStore
@Override
public
LinkEvent
createOrUpdateLink
(
ProviderId
providerId
,
LinkDescription
linkDescription
)
{
LinkKey
key
=
new
LinkKey
(
linkDescription
.
src
(),
linkDescription
.
dst
()
);
LinkKey
key
=
linkKey
(
linkDescription
);
ConcurrentMap
<
ProviderId
,
LinkDescription
>
descs
=
getLinkDescriptions
(
key
);
synchronized
(
descs
)
{
...
...
@@ -225,7 +226,7 @@ public class SimpleLinkStore
@Override
public
LinkEvent
removeLink
(
ConnectPoint
src
,
ConnectPoint
dst
)
{
final
LinkKey
key
=
new
L
inkKey
(
src
,
dst
);
final
LinkKey
key
=
l
inkKey
(
src
,
dst
);
ConcurrentMap
<
ProviderId
,
LinkDescription
>
descs
=
getLinkDescriptions
(
key
);
synchronized
(
descs
)
{
Link
link
=
links
.
remove
(
key
);
...
...
core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleLinkStoreTest.java
View file @
94cf3c5
...
...
@@ -136,8 +136,8 @@ public class SimpleLinkStoreTest {
assertEquals
(
"initialy empty"
,
0
,
Iterables
.
size
(
linkStore
.
getLinks
()));
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -148,7 +148,7 @@ public class SimpleLinkStoreTest {
Map
<
LinkKey
,
Link
>
links
=
new
HashMap
<>();
for
(
Link
link
:
linkStore
.
getLinks
())
{
links
.
put
(
new
LinkKey
(
link
.
src
(),
link
.
dst
()
),
link
);
links
.
put
(
LinkKey
.
linkKey
(
link
),
link
);
}
assertLink
(
linkId1
,
DIRECT
,
links
.
get
(
linkId1
));
...
...
@@ -157,9 +157,9 @@ public class SimpleLinkStoreTest {
@Test
public
final
void
testGetDeviceEgressLinks
()
{
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -180,9 +180,9 @@ public class SimpleLinkStoreTest {
@Test
public
final
void
testGetDeviceIngressLinks
()
{
LinkKey
linkId1
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
new
L
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P1
),
new
ConnectPoint
(
DID2
,
P2
));
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID2
,
P2
),
new
ConnectPoint
(
DID1
,
P1
));
LinkKey
linkId3
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -205,7 +205,7 @@ public class SimpleLinkStoreTest {
public
final
void
testGetLink
()
{
ConnectPoint
src
=
new
ConnectPoint
(
DID1
,
P1
);
ConnectPoint
dst
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
src
,
dst
);
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
src
,
dst
);
putLink
(
linkId1
,
DIRECT
);
...
...
@@ -220,9 +220,9 @@ public class SimpleLinkStoreTest {
public
final
void
testGetEgressLinks
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -245,9 +245,9 @@ public class SimpleLinkStoreTest {
public
final
void
testGetIngressLinks
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
new
L
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId3
=
LinkKey
.
l
inkKey
(
new
ConnectPoint
(
DID1
,
P2
),
new
ConnectPoint
(
DID2
,
P3
));
putLink
(
linkId1
,
DIRECT
);
putLink
(
linkId2
,
DIRECT
);
...
...
@@ -349,8 +349,8 @@ public class SimpleLinkStoreTest {
public
final
void
testRemoveLink
()
{
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
new
L
inkKey
(
d2P2
,
d1P1
);
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
d1P1
,
d2P2
);
LinkKey
linkId2
=
LinkKey
.
l
inkKey
(
d2P2
,
d1P1
);
putLink
(
linkId1
,
DIRECT
,
A1
);
putLink
(
linkId2
,
DIRECT
,
A2
);
...
...
@@ -406,7 +406,7 @@ public class SimpleLinkStoreTest {
final
ConnectPoint
d1P1
=
new
ConnectPoint
(
DID1
,
P1
);
final
ConnectPoint
d2P2
=
new
ConnectPoint
(
DID2
,
P2
);
final
LinkKey
linkId1
=
new
L
inkKey
(
d1P1
,
d2P2
);
final
LinkKey
linkId1
=
LinkKey
.
l
inkKey
(
d1P1
,
d2P2
);
final
CountDownLatch
addLatch
=
new
CountDownLatch
(
1
);
LinkStoreDelegate
checkAdd
=
new
LinkStoreDelegate
()
{
...
...
Please
register
or
login
to post a comment