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-10-24 11:36:17 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6a45616dbe86cda396588e70e5dc0c6531b2f888
6a45616d
1 parent
8eecc2d2
FlowRuleManager is now fully batch based
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
51 deletions
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
View file @
6a45616
...
...
@@ -50,6 +50,7 @@ import org.onlab.onos.net.provider.AbstractProviderService;
import
org.slf4j.Logger
;
import
com.google.common.collect.ArrayListMultimap
;
import
com.google.common.collect.Iterables
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
...
...
@@ -116,71 +117,38 @@ public class FlowRuleManager
@Override
public
void
applyFlowRules
(
FlowRule
...
flowRules
)
{
Set
<
FlowRuleBatchEntry
>
toAddBatchEntries
=
Sets
.
newHashSet
();
for
(
int
i
=
0
;
i
<
flowRules
.
length
;
i
++)
{
FlowRule
f
=
flowRules
[
i
];
store
.
storeFlowRule
(
f
);
}
}
private
void
applyFlowRulesToProviders
(
FlowRule
...
flowRules
)
{
DeviceId
did
=
null
;
FlowRuleProvider
frp
=
null
;
for
(
FlowRule
f
:
flowRules
)
{
if
(!
f
.
deviceId
().
equals
(
did
))
{
did
=
f
.
deviceId
();
final
Device
device
=
deviceService
.
getDevice
(
did
);
frp
=
getProvider
(
device
.
providerId
());
}
if
(
frp
!=
null
)
{
frp
.
applyFlowRule
(
f
);
}
toAddBatchEntries
.
add
(
new
FlowRuleBatchEntry
(
FlowRuleOperation
.
ADD
,
flowRules
[
i
]));
}
applyBatch
(
new
FlowRuleBatchOperation
(
toAddBatchEntries
));
}
@Override
public
void
removeFlowRules
(
FlowRule
...
flowRules
)
{
FlowRule
f
;
Set
<
FlowRuleBatchEntry
>
toRemoveBatchEntries
=
Sets
.
newHashSet
()
;
for
(
int
i
=
0
;
i
<
flowRules
.
length
;
i
++)
{
f
=
flowRules
[
i
];
store
.
deleteFlowRule
(
f
);
}
}
private
void
removeFlowRulesFromProviders
(
FlowRule
...
flowRules
)
{
DeviceId
did
=
null
;
FlowRuleProvider
frp
=
null
;
for
(
FlowRule
f
:
flowRules
)
{
if
(!
f
.
deviceId
().
equals
(
did
))
{
did
=
f
.
deviceId
();
final
Device
device
=
deviceService
.
getDevice
(
did
);
frp
=
getProvider
(
device
.
providerId
());
}
if
(
frp
!=
null
)
{
frp
.
removeFlowRule
(
f
);
}
toRemoveBatchEntries
.
add
(
new
FlowRuleBatchEntry
(
FlowRuleOperation
.
REMOVE
,
flowRules
[
i
]));
}
applyBatch
(
new
FlowRuleBatchOperation
(
toRemoveBatchEntries
));
}
@Override
public
void
removeFlowRulesById
(
ApplicationId
id
)
{
Iterable
<
FlowRule
>
rules
=
getFlowRulesById
(
id
);
FlowRuleProvider
frp
;
Device
device
;
for
(
FlowRule
f
:
rules
)
{
store
.
deleteFlowRule
(
f
);
// FIXME: only accept request and push to provider on internal event
device
=
deviceService
.
getDevice
(
f
.
deviceId
());
frp
=
getProvider
(
device
.
providerId
());
// FIXME: flows removed from store and flows removed from might diverge
// get rid of #removeRulesById?
frp
.
removeRulesById
(
id
,
f
);
}
removeFlowRules
(
Iterables
.
toArray
(
getFlowRulesById
(
id
),
FlowRule
.
class
));
}
@Override
public
Iterable
<
FlowRule
>
getFlowRulesById
(
ApplicationId
id
)
{
return
store
.
getFlowRulesByAppId
(
id
);
Set
<
FlowRule
>
flowEntries
=
Sets
.
newHashSet
();
for
(
Device
d
:
deviceService
.
getDevices
())
{
for
(
FlowEntry
flowEntry
:
store
.
getFlowEntries
(
d
.
id
()))
{
if
(
flowEntry
.
appId
()
==
id
.
id
())
{
flowEntries
.
add
(
flowEntry
);
}
}
}
return
flowEntries
;
}
@Override
...
...
core/net/src/test/java/org/onlab/onos/net/flow/impl/FlowRuleManagerTest.java
View file @
6a45616
...
...
@@ -12,6 +12,7 @@ import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVE_REQUESTED;
import
static
org
.
onlab
.
onos
.
net
.
flow
.
FlowRuleEvent
.
Type
.
RULE_UPDATED
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -461,12 +462,12 @@ public class FlowRuleManagerTest {
@Override
public
int
getDeviceCount
()
{
return
0
;
return
1
;
}
@Override
public
Iterable
<
Device
>
getDevices
()
{
return
null
;
return
Arrays
.
asList
(
DEV
)
;
}
@Override
...
...
Please
register
or
login
to post a comment