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
Madan Jampani
2014-11-03 15:23:02 -0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
a6a45eff699bb8b50a835d8c709abff831bac011
a6a45eff
2 parents
e472181b
5c324331
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
108 additions
and
54 deletions
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleBatchEvent.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleBatchRequest.java
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/DistributedMastershipStore.java
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleFlowRuleStore.java
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
View file @
a6a45ef
...
...
@@ -188,7 +188,7 @@ public final class DefaultTrafficSelector implements TrafficSelector {
}
@Override
public
Builder
matchOpticalSignalType
(
Byte
signalType
)
{
public
Builder
matchOpticalSignalType
(
Short
signalType
)
{
return
add
(
Criteria
.
matchOpticalSignalType
(
signalType
));
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleBatchEvent.java
View file @
a6a45ef
...
...
@@ -27,11 +27,14 @@ public final class FlowRuleBatchEvent extends AbstractEvent<FlowRuleBatchEvent.T
*/
public
enum
Type
{
// Request has been forwarded to MASTER Node
/**
* Signifies that a batch operation has been initiated.
*/
BATCH_OPERATION_REQUESTED
,
// MASTER Node has pushed the batch down to the Device
// (e.g., Received barrier reply)
/**
* Signifies that a batch operation has completed.
*/
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleBatchRequest.java
View file @
a6a45ef
...
...
@@ -25,29 +25,29 @@ import com.google.common.collect.Lists;
public
class
FlowRuleBatchRequest
{
private
final
int
batchId
;
private
final
List
<
Flow
Entry
>
toAdd
;
private
final
List
<
Flow
Entry
>
toRemove
;
private
final
List
<
Flow
Rule
>
toAdd
;
private
final
List
<
Flow
Rule
>
toRemove
;
public
FlowRuleBatchRequest
(
int
batchId
,
List
<?
extends
Flow
Entry
>
toAdd
,
List
<?
extends
FlowEntry
>
toRemove
)
{
public
FlowRuleBatchRequest
(
int
batchId
,
List
<?
extends
Flow
Rule
>
toAdd
,
List
<?
extends
FlowRule
>
toRemove
)
{
this
.
batchId
=
batchId
;
this
.
toAdd
=
Collections
.
unmodifiableList
(
toAdd
);
this
.
toRemove
=
Collections
.
unmodifiableList
(
toRemove
);
}
public
List
<
Flow
Entry
>
toAdd
()
{
public
List
<
Flow
Rule
>
toAdd
()
{
return
toAdd
;
}
public
List
<
Flow
Entry
>
toRemove
()
{
public
List
<
Flow
Rule
>
toRemove
()
{
return
toRemove
;
}
public
FlowRuleBatchOperation
asBatchOperation
()
{
List
<
FlowRuleBatchEntry
>
entries
=
Lists
.
newArrayList
();
for
(
Flow
Entry
e
:
toAdd
)
{
for
(
Flow
Rule
e
:
toAdd
)
{
entries
.
add
(
new
FlowRuleBatchEntry
(
FlowRuleOperation
.
ADD
,
e
));
}
for
(
Flow
Entry
e
:
toRemove
)
{
for
(
Flow
Rule
e
:
toRemove
)
{
entries
.
add
(
new
FlowRuleBatchEntry
(
FlowRuleOperation
.
REMOVE
,
e
));
}
return
new
FlowRuleBatchOperation
(
entries
);
...
...
core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
View file @
a6a45ef
...
...
@@ -147,7 +147,7 @@ public interface TrafficSelector {
* @param signalType
* @return a selection builder
*/
public
Builder
matchOpticalSignalType
(
Byte
signalType
);
public
Builder
matchOpticalSignalType
(
Short
signalType
);
/**
* Builds an immutable traffic selector.
...
...
core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
View file @
a6a45ef
...
...
@@ -161,11 +161,11 @@ public final class Criteria {
/**
* Creates a match on lambda field using the specified value.
*
* @param
lambda
* @param
sigType
* @return match criterion
*/
public
static
Criterion
matchOpticalSignalType
(
Byte
lambda
)
{
return
new
OpticalSignalTypeCriterion
(
lambda
,
Type
.
OCH_SIGTYPE
);
public
static
Criterion
matchOpticalSignalType
(
Short
sigType
)
{
return
new
OpticalSignalTypeCriterion
(
sigType
,
Type
.
OCH_SIGTYPE
);
}
...
...
@@ -587,10 +587,10 @@ public final class Criteria {
public
static
final
class
OpticalSignalTypeCriterion
implements
Criterion
{
private
final
byte
signalType
;
private
final
Short
signalType
;
private
final
Type
type
;
public
OpticalSignalTypeCriterion
(
byte
signalType
,
Type
type
)
{
public
OpticalSignalTypeCriterion
(
Short
signalType
,
Type
type
)
{
this
.
signalType
=
signalType
;
this
.
type
=
type
;
}
...
...
@@ -600,7 +600,7 @@ public final class Criteria {
return
this
.
type
;
}
public
Byte
signalType
()
{
public
Short
signalType
()
{
return
this
.
signalType
;
}
...
...
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
View file @
a6a45ef
...
...
@@ -371,10 +371,11 @@ public class FlowRuleManager
final
FlowRuleBatchRequest
request
=
event
.
subject
();
switch
(
event
.
type
())
{
case
BATCH_OPERATION_REQUESTED:
for
(
FlowEntry
entry
:
request
.
toAdd
())
{
// Request has been forwarded to MASTER Node, and was
for
(
FlowRule
entry
:
request
.
toAdd
())
{
eventDispatcher
.
post
(
new
FlowRuleEvent
(
FlowRuleEvent
.
Type
.
RULE_ADD_REQUESTED
,
entry
));
}
for
(
Flow
Entry
entry
:
request
.
toRemove
())
{
for
(
Flow
Rule
entry
:
request
.
toRemove
())
{
eventDispatcher
.
post
(
new
FlowRuleEvent
(
FlowRuleEvent
.
Type
.
RULE_REMOVE_REQUESTED
,
entry
));
}
// FIXME: what about op.equals(FlowRuleOperation.MODIFY) ?
...
...
@@ -392,21 +393,15 @@ public class FlowRuleManager
Futures
.
getUnchecked
(
result
)));
}
},
futureListeners
);
break
;
case
BATCH_OPERATION_COMPLETED:
Set
<
FlowRule
>
failedItems
=
event
.
result
().
failedItems
();
for
(
FlowEntry
entry
:
request
.
toAdd
())
{
if
(!
failedItems
.
contains
(
entry
))
{
eventDispatcher
.
post
(
new
FlowRuleEvent
(
FlowRuleEvent
.
Type
.
RULE_ADDED
,
entry
));
}
}
for
(
FlowEntry
entry
:
request
.
toRemove
())
{
if
(!
failedItems
.
contains
(
entry
))
{
eventDispatcher
.
post
(
new
FlowRuleEvent
(
FlowRuleEvent
.
Type
.
RULE_REMOVED
,
entry
));
}
}
// MASTER Node has pushed the batch down to the Device
// Note: RULE_ADDED will be posted
// when Flow was actually confirmed by stats reply.
break
;
default
:
break
;
}
...
...
core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
View file @
a6a45ef
...
...
@@ -79,6 +79,7 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
private
ApplicationId
appId
;
//final short WAVELENGTH = 80;
static
final
short
SIGNAL_TYPE
=
(
short
)
1
;
@Activate
public
void
activate
()
{
...
...
@@ -151,7 +152,9 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
prev
=
link
.
dst
();
selectorBuilder
.
matchInport
(
link
.
dst
().
port
());
selectorBuilder
.
matchOpticalSignalType
(
SIGNAL_TYPE
);
//todo
selectorBuilder
.
matchLambda
((
short
)
la
.
toInt
());
}
// build the last T port rule
...
...
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
View file @
a6a45ef
...
...
@@ -148,7 +148,7 @@ public class FlowRuleManagerTest {
int
i
=
0
;
System
.
err
.
println
(
"events :"
+
listener
.
events
);
for
(
FlowRuleEvent
e
:
listener
.
events
)
{
assert
True
(
"unexpected event"
,
e
.
type
().
equals
(
events
[
i
]
));
assert
Equals
(
"unexpected event"
,
events
[
i
],
e
.
type
(
));
i
++;
}
...
...
@@ -178,15 +178,13 @@ public class FlowRuleManagerTest {
RULE_ADDED
,
RULE_ADDED
);
addFlowRule
(
1
);
System
.
err
.
println
(
"events :"
+
listener
.
events
);
assertEquals
(
"should still be 2 rules"
,
2
,
flowCount
());
providerService
.
pushFlowMetrics
(
DID
,
ImmutableList
.
of
(
fe1
));
validateEvents
(
RULE_UPDATED
);
}
// TODO: If preserving iteration order is a requirement, redo FlowRuleStore.
//backing store is sensitive to the order of additions/removals
private
boolean
validateState
(
Map
<
FlowRule
,
FlowEntryState
>
expected
)
{
Map
<
FlowRule
,
FlowEntryState
>
expectedToCheck
=
new
HashMap
<>(
expected
);
Iterable
<
FlowEntry
>
rules
=
service
.
getFlowEntries
(
DID
);
...
...
@@ -539,17 +537,17 @@ public class FlowRuleManagerTest {
@Override
public
boolean
cancel
(
boolean
mayInterruptIfRunning
)
{
return
tru
e
;
return
fals
e
;
}
@Override
public
boolean
isCancelled
()
{
return
tru
e
;
return
fals
e
;
}
@Override
public
boolean
isDone
()
{
return
fals
e
;
return
tru
e
;
}
@Override
...
...
@@ -562,12 +560,14 @@ public class FlowRuleManagerTest {
public
CompletedBatchOperation
get
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
return
n
ull
;
return
n
ew
CompletedBatchOperation
(
true
,
Collections
.<
FlowRule
>
emptySet
())
;
}
@Override
public
void
addListener
(
Runnable
task
,
Executor
executor
)
{
// TODO: add stuff.
if
(
isDone
())
{
executor
.
execute
(
task
);
}
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/mastership/impl/DistributedMastershipStore.java
View file @
a6a45ef
...
...
@@ -447,7 +447,13 @@ implements MastershipStore {
RoleValue
oldValue
=
event
.
getOldValue
();
RoleValue
newValue
=
event
.
getValue
();
if
(
Objects
.
equal
(
oldValue
.
get
(
MASTER
),
newValue
.
get
(
MASTER
)))
{
NodeId
oldMaster
=
null
;
if
(
oldValue
!=
null
)
{
oldMaster
=
oldValue
.
get
(
MASTER
);
}
NodeId
newMaster
=
newValue
.
get
(
MASTER
);
if
(
Objects
.
equal
(
oldMaster
,
newMaster
))
{
notifyDelegate
(
new
MastershipEvent
(
MASTER_CHANGED
,
event
.
getKey
(),
event
.
getValue
().
roleInfo
()));
}
else
{
...
...
core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleFlowRuleStore.java
View file @
a6a45ef
...
...
@@ -16,8 +16,12 @@
package
org
.
onlab
.
onos
.
store
.
trivial
.
impl
;
import
com.google.common.base.Function
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.collect.FluentIterable
;
import
com.google.common.util.concurrent.Futures
;
import
com.google.common.util.concurrent.SettableFuture
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -43,13 +47,15 @@ import org.onlab.onos.store.AbstractStore;
import
org.onlab.util.NewConcurrentHashMap
;
import
org.slf4j.Logger
;
import
java.util.Array
s
;
import
java.util.Array
List
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
static
org
.
apache
.
commons
.
lang3
.
concurrent
.
ConcurrentUtils
.
createIfAbsentUnchecked
;
import
static
org
.
onlab
.
onos
.
net
.
flow
.
FlowRuleEvent
.
Type
.
RULE_REMOVED
;
...
...
@@ -72,6 +78,18 @@ public class SimpleFlowRuleStore
private
final
ConcurrentMap
<
DeviceId
,
ConcurrentMap
<
FlowId
,
List
<
StoredFlowEntry
>>>
flowEntries
=
new
ConcurrentHashMap
<>();
private
final
AtomicInteger
localBatchIdGen
=
new
AtomicInteger
();
// TODO: make this configurable
private
int
pendingFutureTimeoutMinutes
=
5
;
private
Cache
<
Integer
,
SettableFuture
<
CompletedBatchOperation
>>
pendingFutures
=
CacheBuilder
.
newBuilder
()
.
expireAfterWrite
(
pendingFutureTimeoutMinutes
,
TimeUnit
.
MINUTES
)
// TODO Explicitly fail the future if expired?
//.removalListener(listener)
.
build
();
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
...
...
@@ -173,10 +191,6 @@ public class SimpleFlowRuleStore
}
// new flow rule added
existing
.
add
(
f
);
notifyDelegate
(
FlowRuleBatchEvent
.
requested
(
new
FlowRuleBatchRequest
(
1
,
/* FIXME generate something */
Arrays
.<
FlowEntry
>
asList
(
f
),
Collections
.<
FlowEntry
>
emptyList
())));
}
}
...
...
@@ -190,11 +204,6 @@ public class SimpleFlowRuleStore
if
(
entry
.
equals
(
rule
))
{
synchronized
(
entry
)
{
entry
.
setState
(
FlowEntryState
.
PENDING_REMOVE
);
// TODO: Should we notify only if it's "remote" event?
notifyDelegate
(
FlowRuleBatchEvent
.
requested
(
new
FlowRuleBatchRequest
(
1
,
/* FIXME generate something */
Collections
.<
FlowEntry
>
emptyList
(),
Arrays
.<
FlowEntry
>
asList
(
entry
))));
}
}
}
...
...
@@ -251,20 +260,47 @@ public class SimpleFlowRuleStore
@Override
public
Future
<
CompletedBatchOperation
>
storeBatch
(
FlowRuleBatchOperation
batchOperation
)
{
List
<
FlowRule
>
toAdd
=
new
ArrayList
<>();
List
<
FlowRule
>
toRemove
=
new
ArrayList
<>();
for
(
FlowRuleBatchEntry
entry
:
batchOperation
.
getOperations
())
{
final
FlowRule
flowRule
=
entry
.
getTarget
();
if
(
entry
.
getOperator
().
equals
(
FlowRuleOperation
.
ADD
))
{
storeFlowRule
(
entry
.
getTarget
());
if
(!
getFlowEntries
(
flowRule
.
deviceId
(),
flowRule
.
id
()).
contains
(
flowRule
))
{
storeFlowRule
(
flowRule
);
toAdd
.
add
(
flowRule
);
}
}
else
if
(
entry
.
getOperator
().
equals
(
FlowRuleOperation
.
REMOVE
))
{
deleteFlowRule
(
entry
.
getTarget
());
if
(
getFlowEntries
(
flowRule
.
deviceId
(),
flowRule
.
id
()).
contains
(
flowRule
))
{
deleteFlowRule
(
flowRule
);
toRemove
.
add
(
flowRule
);
}
}
else
{
throw
new
UnsupportedOperationException
(
"Unsupported operation type"
);
}
}
return
Futures
.
immediateFuture
(
new
CompletedBatchOperation
(
true
,
Collections
.<
FlowEntry
>
emptySet
()));
if
(
toAdd
.
isEmpty
()
&&
toRemove
.
isEmpty
())
{
return
Futures
.
immediateFuture
(
new
CompletedBatchOperation
(
true
,
Collections
.<
FlowRule
>
emptySet
()));
}
SettableFuture
<
CompletedBatchOperation
>
r
=
SettableFuture
.
create
();
final
int
batchId
=
localBatchIdGen
.
incrementAndGet
();
pendingFutures
.
put
(
batchId
,
r
);
notifyDelegate
(
FlowRuleBatchEvent
.
requested
(
new
FlowRuleBatchRequest
(
batchId
,
toAdd
,
toRemove
)));
return
r
;
}
@Override
public
void
batchOperationComplete
(
FlowRuleBatchEvent
event
)
{
final
Integer
batchId
=
event
.
subject
().
batchId
();
SettableFuture
<
CompletedBatchOperation
>
future
=
pendingFutures
.
getIfPresent
(
batchId
);
if
(
future
!=
null
)
{
future
.
set
(
event
.
result
());
pendingFutures
.
invalidate
(
batchId
);
}
notifyDelegate
(
event
);
}
}
...
...
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java
View file @
a6a45ef
...
...
@@ -289,7 +289,10 @@ public class FlowEntryBuilder {
case
OCH_SIGID:
builder
.
matchLambda
(
match
.
get
(
MatchField
.
OCH_SIGID
).
getChannelNumber
());
break
;
case
OCH_SIGTYPE_BASIC:
case
OCH_SIGTYPE:
builder
.
matchOpticalSignalType
(
match
.
get
(
MatchField
.
OCH_SIGTYPE
).
getValue
());
break
;
case
ARP_OP:
case
ARP_SHA:
case
ARP_SPA:
...
...
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
View file @
a6a45ef
...
...
@@ -19,6 +19,7 @@ import static org.slf4j.LoggerFactory.getLogger;
import
org.onlab.onos.net.flow.FlowRule
;
import
org.onlab.onos.net.flow.TrafficSelector
;
import
org.onlab.onos.net.flow.criteria.Criteria
;
import
org.onlab.onos.net.flow.criteria.Criteria.EthCriterion
;
import
org.onlab.onos.net.flow.criteria.Criteria.EthTypeCriterion
;
import
org.onlab.onos.net.flow.criteria.Criteria.IPCriterion
;
...
...
@@ -46,6 +47,7 @@ import org.projectfloodlight.openflow.types.Masked;
import
org.projectfloodlight.openflow.types.OFPort
;
import
org.projectfloodlight.openflow.types.OFVlanVidMatch
;
import
org.projectfloodlight.openflow.types.TransportPort
;
import
org.projectfloodlight.openflow.types.U8
;
import
org.projectfloodlight.openflow.types.VlanPcp
;
import
org.projectfloodlight.openflow.types.VlanVid
;
import
org.slf4j.Logger
;
...
...
@@ -197,6 +199,12 @@ public abstract class FlowModBuilder {
mBuilder
.
setExact
(
MatchField
.
OCH_SIGID
,
new
CircuitSignalID
((
byte
)
1
,
(
byte
)
2
,
lc
.
lambda
(),
(
short
)
1
));
break
;
case
OCH_SIGTYPE:
Criteria
.
OpticalSignalTypeCriterion
sc
=
(
Criteria
.
OpticalSignalTypeCriterion
)
c
;
mBuilder
.
setExact
(
MatchField
.
OCH_SIGTYPE
,
U8
.
of
(
sc
.
signalType
()));
break
;
case
ARP_OP:
case
ARP_SHA:
case
ARP_SPA:
...
...
web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
View file @
a6a45ef
...
...
@@ -101,7 +101,7 @@ public class TopologyResource extends BaseResource {
new
Prop
(
"Vendor"
,
device
.
manufacturer
()),
new
Prop
(
"H/W Version"
,
device
.
hwVersion
()),
new
Prop
(
"S/W Version"
,
device
.
swVersion
()),
new
Prop
(
"S
/W Version
"
,
device
.
serialNumber
()),
new
Prop
(
"S
erial Number
"
,
device
.
serialNumber
()),
new
Separator
(),
new
Prop
(
"Latitude"
,
annot
.
value
(
"latitude"
)),
new
Prop
(
"Longitude"
,
annot
.
value
(
"longitude"
)),
...
...
Please
register
or
login
to post a comment