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-08 21:56:05 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
92c65ad4298ece8586289c6c1e59fb260fa762d3
92c65ad4
1 parent
c7e1cb63
real application ids
Change-Id: Ia24f1de6ccff614769727ab261002520dfd8506f
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
151 additions
and
69 deletions
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/ProxyArp.java
core/api/src/main/java/org/onlab/onos/ApplicationId.java
core/api/src/main/java/org/onlab/onos/CoreService.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
core/net/src/main/java/org/onlab/onos/cluster/impl/CoreManager.java → core/net/src/main/java/org/onlab/onos/impl/CoreManager.java
core/net/src/main/java/org/onlab/onos/impl/DefaultApplicationId.java
core/net/src/main/java/org/onlab/onos/impl/package-info.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
core/store/hz/net/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleFlowRuleStore.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
92c65ad
...
...
@@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.CoreService
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.Path
;
...
...
@@ -53,13 +54,16 @@ public class ReactiveForwarding {
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
FlowRuleService
flowRuleService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
CoreService
coreService
;
private
ReactivePacketProcessor
processor
=
new
ReactivePacketProcessor
();
private
ApplicationId
appId
;
@Activate
public
void
activate
()
{
appId
=
ApplicationId
.
getAppId
(
);
appId
=
coreService
.
registerApplication
(
"org.onlab.onos.fwd"
);
packetService
.
addProcessor
(
processor
,
PacketProcessor
.
ADVISOR_MAX
+
2
);
log
.
info
(
"Started with Application ID {}"
,
appId
.
id
());
}
...
...
apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
View file @
92c65ad
...
...
@@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.CoreService
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.device.DeviceService
;
...
...
@@ -44,11 +45,14 @@ public class HostMobility {
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
DeviceService
deviceService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
CoreService
coreService
;
private
ApplicationId
appId
;
@Activate
public
void
activate
()
{
appId
=
ApplicationId
.
getAppId
(
);
appId
=
coreService
.
registerApplication
(
"org.onlab.onos.mobility"
);
hostService
.
addListener
(
new
InternalHostListener
());
log
.
info
(
"Started with Application ID {}"
,
appId
.
id
());
}
...
...
apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/ProxyArp.java
View file @
92c65ad
...
...
@@ -8,6 +8,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.CoreService
;
import
org.onlab.onos.net.packet.PacketContext
;
import
org.onlab.onos.net.packet.PacketProcessor
;
import
org.onlab.onos.net.packet.PacketService
;
...
...
@@ -31,11 +32,14 @@ public class ProxyArp {
private
ProxyArpProcessor
processor
=
new
ProxyArpProcessor
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
CoreService
coreService
;
private
ApplicationId
appId
;
@Activate
public
void
activate
()
{
appId
=
ApplicationId
.
getAppId
(
);
appId
=
coreService
.
registerApplication
(
"org.onlab.onos.proxyarp"
);
packetService
.
addProcessor
(
processor
,
PacketProcessor
.
ADVISOR_MAX
+
1
);
log
.
info
(
"Started with Application ID {}"
,
appId
.
id
());
}
...
...
core/api/src/main/java/org/onlab/onos/ApplicationId.java
View file @
92c65ad
package
org
.
onlab
.
onos
;
import
java.util.Objects
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
* Application id
generator class
.
* Application id
entifier
.
*/
public
final
class
ApplicationId
{
public
interface
ApplicationId
{
private
static
final
AtomicInteger
ID_DISPENCER
=
new
AtomicInteger
(
1
);
private
final
Integer
id
;
// Ban public construction
private
ApplicationId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Integer
id
()
{
return
id
;
}
public
static
ApplicationId
valueOf
(
Integer
id
)
{
return
new
ApplicationId
(
id
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(!(
obj
instanceof
ApplicationId
))
{
return
false
;
}
ApplicationId
other
=
(
ApplicationId
)
obj
;
return
Objects
.
equals
(
this
.
id
,
other
.
id
);
}
/**
* Returns the application id.
* @return a short value
*/
short
id
();
/**
* Returns a new application id.
*
* @return app id
* Returns the applications supplied identifier.
* @return a string identifier
*/
public
static
ApplicationId
getAppId
()
{
return
new
ApplicationId
(
ApplicationId
.
ID_DISPENCER
.
getAndIncrement
());
}
String
name
();
}
...
...
core/api/src/main/java/org/onlab/onos/CoreService.java
View file @
92c65ad
...
...
@@ -12,4 +12,21 @@ public interface CoreService {
*/
Version
version
();
/**
* Registers a new application by its name, which is expected
* to follow the reverse DNS convention, e.g.
* {@code org.flying.circus.app}
*
* @param identifier string identifier
* @return the application id
*/
ApplicationId
registerApplication
(
String
identifier
);
/**
* Returns an existing application id from a given id.
* @param id the short value of the id
* @return an application id
*/
ApplicationId
getAppId
(
Short
id
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
View file @
92c65ad
...
...
@@ -21,7 +21,7 @@ public class DefaultFlowRule implements FlowRule {
private
final
FlowId
id
;
private
final
ApplicationId
appId
;
private
final
short
appId
;
private
final
int
timeout
;
...
...
@@ -36,7 +36,7 @@ public class DefaultFlowRule implements FlowRule {
this
.
timeout
=
timeout
;
this
.
created
=
System
.
currentTimeMillis
();
this
.
appId
=
ApplicationId
.
valueOf
((
int
)
(
flowId
>>
32
)
);
this
.
appId
=
(
short
)
(
flowId
>>>
48
);
this
.
id
=
FlowId
.
valueOf
(
flowId
);
}
...
...
@@ -52,11 +52,11 @@ public class DefaultFlowRule implements FlowRule {
this
.
priority
=
priority
;
this
.
selector
=
selector
;
this
.
treatment
=
treatement
;
this
.
appId
=
appId
;
this
.
appId
=
appId
.
id
()
;
this
.
timeout
=
timeout
;
this
.
created
=
System
.
currentTimeMillis
();
this
.
id
=
FlowId
.
valueOf
((((
long
)
appId
().
id
())
<<
32
)
|
(
this
.
hash
()
&
0x
ffffffff
L
));
this
.
id
=
FlowId
.
valueOf
((((
long
)
this
.
appId
)
<<
48
)
|
(
this
.
hash
()
&
0x0000
ffffffff
L
));
}
public
DefaultFlowRule
(
FlowRule
rule
)
{
...
...
@@ -78,7 +78,7 @@ public class DefaultFlowRule implements FlowRule {
}
@Override
public
ApplicationId
appId
()
{
public
short
appId
()
{
return
appId
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
View file @
92c65ad
package
org
.
onlab
.
onos
.
net
.
flow
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.intent.BatchOperationTarget
;
...
...
@@ -26,7 +25,7 @@ public interface FlowRule extends BatchOperationTarget {
*
* @return an applicationId
*/
ApplicationId
appId
();
short
appId
();
/**
* Returns the flow rule priority given in natural order; higher numbers
...
...
core/net/src/main/java/org/onlab/onos/
cluster/
impl/CoreManager.java
→
core/net/src/main/java/org/onlab/onos/impl/CoreManager.java
View file @
92c65ad
package
org
.
onlab
.
onos
.
cluster
.
impl
;
package
org
.
onlab
.
onos
.
impl
;
import
java.io.File
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.CoreService
;
import
org.onlab.onos.Version
;
import
org.onlab.util.Tools
;
import
java.io.File
;
import
java.util.List
;
/**
* Core service implementation.
...
...
@@ -17,9 +22,12 @@ import java.util.List;
@Service
public
class
CoreManager
implements
CoreService
{
private
static
final
AtomicInteger
ID_DISPENSER
=
new
AtomicInteger
(
1
);
private
static
final
File
VERSION_FILE
=
new
File
(
"../VERSION"
);
private
static
Version
version
=
Version
.
version
(
"1.0.0-SNAPSHOT"
);
private
final
Map
<
Short
,
DefaultApplicationId
>
ids
=
new
ConcurrentHashMap
<>();
// TODO: work in progress
@Activate
...
...
@@ -35,4 +43,14 @@ public class CoreManager implements CoreService {
return
version
;
}
@Override
public
ApplicationId
getAppId
(
Short
id
)
{
return
ids
.
get
(
id
);
}
@Override
public
ApplicationId
registerApplication
(
String
name
)
{
return
new
DefaultApplicationId
((
short
)
ID_DISPENSER
.
getAndIncrement
(),
name
);
}
}
...
...
core/net/src/main/java/org/onlab/onos/impl/DefaultApplicationId.java
0 → 100644
View file @
92c65ad
package
org
.
onlab
.
onos
.
impl
;
import
java.util.Objects
;
import
org.onlab.onos.ApplicationId
;
/**
* Application id generator class.
*/
public
class
DefaultApplicationId
implements
ApplicationId
{
private
final
short
id
;
private
final
String
name
;
// Ban public construction
protected
DefaultApplicationId
(
Short
id
,
String
identifier
)
{
this
.
id
=
id
;
this
.
name
=
identifier
;
}
@Override
public
short
id
()
{
return
id
;
}
@Override
public
String
name
()
{
return
name
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(!(
obj
instanceof
DefaultApplicationId
))
{
return
false
;
}
DefaultApplicationId
other
=
(
DefaultApplicationId
)
obj
;
return
Objects
.
equals
(
this
.
id
,
other
.
id
);
}
}
core/net/src/main/java/org/onlab/onos/impl/package-info.java
0 → 100644
View file @
92c65ad
/**
*
*/
package
org
.
onlab
.
onos
.
impl
;
\ No newline at end of file
core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java
View file @
92c65ad
...
...
@@ -13,6 +13,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.CoreService
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.flow.CompletedBatchOperation
;
...
...
@@ -46,10 +47,14 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
FlowRuleService
flowRuleService
;
private
final
ApplicationId
appId
=
ApplicationId
.
getAppId
();
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
CoreService
coreService
;
private
ApplicationId
appId
;
@Activate
public
void
activate
()
{
appId
=
coreService
.
registerApplication
(
"org.onlab.onos.net.intent"
);
intentManager
.
registerInstaller
(
PathIntent
.
class
,
this
);
}
...
...
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
View file @
92c65ad
...
...
@@ -19,6 +19,7 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.event.impl.TestEventDispatcher
;
import
org.onlab.onos.impl.DefaultApplicationId
;
import
org.onlab.onos.net.DefaultDevice
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.Device.Type
;
...
...
@@ -59,6 +60,8 @@ import com.google.common.collect.Sets;
*/
public
class
FlowRuleManagerTest
{
private
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
private
static
final
DeviceId
DID
=
DeviceId
.
deviceId
(
"of:001"
);
private
static
final
int
TIMEOUT
=
10
;
...
...
@@ -87,7 +90,7 @@ public class FlowRuleManagerTest {
mgr
.
addListener
(
listener
);
provider
=
new
TestProvider
(
PID
);
providerService
=
registry
.
register
(
provider
);
appId
=
ApplicationId
.
getAppId
(
);
appId
=
new
TestApplicationId
((
short
)
0
,
"FlowRuleManagerTest"
);
assertTrue
(
"provider should be registered"
,
registry
.
getProviders
().
contains
(
provider
.
id
()));
}
...
...
@@ -475,4 +478,11 @@ public class FlowRuleManagerTest {
}
public
class
TestApplicationId
extends
DefaultApplicationId
{
public
TestApplicationId
(
short
id
,
String
name
)
{
super
(
id
,
name
);
}
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
View file @
92c65ad
...
...
@@ -43,8 +43,8 @@ public class DistributedFlowRuleStore
private
final
Multimap
<
DeviceId
,
FlowEntry
>
flowEntries
=
ArrayListMultimap
.<
DeviceId
,
FlowEntry
>
create
();
private
final
Multimap
<
ApplicationId
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
ApplicationId
,
FlowRule
>
create
();
private
final
Multimap
<
Short
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
Short
,
FlowRule
>
create
();
@Activate
public
void
activate
()
{
...
...
@@ -83,7 +83,7 @@ public class DistributedFlowRuleStore
@Override
public
synchronized
Iterable
<
FlowRule
>
getFlowRulesByAppId
(
ApplicationId
appId
)
{
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
);
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
.
id
()
);
if
(
rules
==
null
)
{
return
Collections
.
emptyList
();
}
...
...
core/store/hz/net/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
View file @
92c65ad
...
...
@@ -43,8 +43,8 @@ public class DistributedFlowRuleStore
private
final
Multimap
<
DeviceId
,
FlowEntry
>
flowEntries
=
ArrayListMultimap
.<
DeviceId
,
FlowEntry
>
create
();
private
final
Multimap
<
ApplicationId
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
ApplicationId
,
FlowRule
>
create
();
private
final
Multimap
<
Short
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
Short
,
FlowRule
>
create
();
@Activate
public
void
activate
()
{
...
...
@@ -83,7 +83,7 @@ public class DistributedFlowRuleStore
@Override
public
synchronized
Iterable
<
FlowRule
>
getFlowRulesByAppId
(
ApplicationId
appId
)
{
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
);
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
.
id
()
);
if
(
rules
==
null
)
{
return
Collections
.
emptyList
();
}
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleFlowRuleStore.java
View file @
92c65ad
...
...
@@ -42,8 +42,8 @@ public class SimpleFlowRuleStore
private
final
Multimap
<
DeviceId
,
FlowEntry
>
flowEntries
=
ArrayListMultimap
.<
DeviceId
,
FlowEntry
>
create
();
private
final
Multimap
<
ApplicationId
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
ApplicationId
,
FlowRule
>
create
();
private
final
Multimap
<
Short
,
FlowRule
>
flowEntriesById
=
ArrayListMultimap
.<
Short
,
FlowRule
>
create
();
@Activate
public
void
activate
()
{
...
...
@@ -82,7 +82,7 @@ public class SimpleFlowRuleStore
@Override
public
synchronized
Iterable
<
FlowRule
>
getFlowRulesByAppId
(
ApplicationId
appId
)
{
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
);
Collection
<
FlowRule
>
rules
=
flowEntriesById
.
get
(
appId
.
id
()
);
if
(
rules
==
null
)
{
return
Collections
.
emptyList
();
}
...
...
Please
register
or
login
to post a comment