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-23 21:58:10 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f5fdef014a65af5f7fd154258fdfb5e3d2e73ba9
f5fdef01
1 parent
9de2772d
getFlowEntries now operates correctly in a distributed setting
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletions
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/FlowStoreMessageSubjects.java
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
View file @
f5fdef0
...
...
@@ -11,6 +11,7 @@ import java.util.Arrays;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
...
...
@@ -159,6 +160,21 @@ public class DistributedFlowRuleStore
}
});
clusterCommunicator
.
addSubscriber
(
GET_DEVICE_FLOW_ENTRIES
,
new
ClusterMessageHandler
()
{
@Override
public
void
handle
(
ClusterMessage
message
)
{
DeviceId
deviceId
=
SERIALIZER
.
decode
(
message
.
payload
());
log
.
info
(
"Received get flow entries request for {} from {}"
,
deviceId
,
message
.
sender
());
Set
<
FlowEntry
>
flowEntries
=
getFlowEntriesInternal
(
deviceId
);
try
{
message
.
respond
(
SERIALIZER
.
encode
(
flowEntries
));
}
catch
(
IOException
e
)
{
log
.
error
(
"Failed to respond to peer's getFlowEntries request"
,
e
);
}
}
});
log
.
info
(
"Started"
);
}
...
...
@@ -217,9 +233,33 @@ public class DistributedFlowRuleStore
@Override
public
synchronized
Iterable
<
FlowEntry
>
getFlowEntries
(
DeviceId
deviceId
)
{
ReplicaInfo
replicaInfo
=
replicaInfoManager
.
getReplicaInfoFor
(
deviceId
);
if
(
replicaInfo
.
master
().
get
().
equals
(
clusterService
.
getLocalNode
().
id
()))
{
return
getFlowEntriesInternal
(
deviceId
);
}
log
.
info
(
"Forwarding getFlowEntries to {}, which is the primary (master) for device {}"
,
replicaInfo
.
master
().
orNull
(),
deviceId
);
ClusterMessage
message
=
new
ClusterMessage
(
clusterService
.
getLocalNode
().
id
(),
GET_DEVICE_FLOW_ENTRIES
,
SERIALIZER
.
encode
(
deviceId
));
try
{
ClusterMessageResponse
response
=
clusterCommunicator
.
sendAndReceive
(
message
,
replicaInfo
.
master
().
get
());
return
SERIALIZER
.
decode
(
response
.
get
(
FLOW_RULE_STORE_TIMEOUT_MILLIS
,
TimeUnit
.
MILLISECONDS
));
}
catch
(
IOException
|
TimeoutException
e
)
{
// FIXME: throw a FlowStoreException
throw
new
RuntimeException
(
e
);
}
}
private
Set
<
FlowEntry
>
getFlowEntriesInternal
(
DeviceId
deviceId
)
{
Collection
<?
extends
FlowEntry
>
rules
=
flowEntries
.
get
(
deviceId
);
if
(
rules
==
null
)
{
return
Collections
.
empty
Lis
t
();
return
Collections
.
empty
Se
t
();
}
return
ImmutableSet
.
copyOf
(
rules
);
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/FlowStoreMessageSubjects.java
View file @
f5fdef0
...
...
@@ -13,4 +13,7 @@ public final class FlowStoreMessageSubjects {
public
static
final
MessageSubject
GET_FLOW_ENTRY
=
new
MessageSubject
(
"peer-forward-get-flow-entry"
);
public
static
final
MessageSubject
GET_DEVICE_FLOW_ENTRIES
=
new
MessageSubject
(
"peer-forward-get-device-flow-entries"
);
}
...
...
Please
register
or
login
to post a comment