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
Yuta HIGUCHI
2016-08-04 18:35:21 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d90dbc9f6672643374e937994640cb4de1cd6f48
d90dbc9f
1 parent
4d287730
Simplify EventHistoryManager
Change-Id: Ifefc68269e469883960359406d603e8c24b399df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
61 deletions
apps/events/src/main/java/org/onosproject/events/EventHistoryManager.java
core/api/src/main/java/org/onosproject/event/ListenerTracker.java
apps/events/src/main/java/org/onosproject/events/EventHistoryManager.java
View file @
d90dbc9
...
...
@@ -32,28 +32,18 @@ import org.apache.felix.scr.annotations.Reference;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.util.UnmodifiableDeque
;
import
org.onosproject.cluster.ClusterEvent
;
import
org.onosproject.cluster.ClusterEventListener
;
import
org.onosproject.cluster.ClusterService
;
import
org.onosproject.core.ApplicationId
;
import
org.onosproject.core.CoreService
;
import
org.onosproject.event.Event
;
import
org.onosproject.event.ListenerTracker
;
import
org.onosproject.mastership.MastershipEvent
;
import
org.onosproject.mastership.MastershipListener
;
import
org.onosproject.mastership.MastershipService
;
import
org.onosproject.net.device.DeviceEvent
;
import
org.onosproject.net.device.DeviceListener
;
import
org.onosproject.net.device.DeviceService
;
import
org.onosproject.net.edge.EdgePortService
;
import
org.onosproject.net.host.HostEvent
;
import
org.onosproject.net.host.HostListener
;
import
org.onosproject.net.host.HostService
;
import
org.onosproject.net.link.LinkEvent
;
import
org.onosproject.net.link.LinkListener
;
import
org.onosproject.net.link.LinkService
;
import
org.onosproject.net.topology.TopologyEvent
;
import
org.onosproject.net.topology.TopologyListener
;
import
org.onosproject.net.topology.TopologyService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -126,12 +116,12 @@ public class EventHistoryManager
pruneInterval
,
pruneInterval
,
TimeUnit
.
SECONDS
);
listeners
=
new
ListenerTracker
();
listeners
.
addListener
(
mastershipService
,
new
InternalMastershipListener
()
)
listeners
.
addListener
(
mastershipService
,
this
::
addEvent
)
.
addListener
(
deviceService
,
new
InternalDeviceListener
())
.
addListener
(
linkService
,
new
InternalLinkListener
()
)
.
addListener
(
topologyService
,
new
InternalTopologyListener
()
)
.
addListener
(
hostService
,
new
InternalHostListener
()
)
.
addListener
(
clusterService
,
new
InternalClusterListener
()
)
.
addListener
(
linkService
,
this
::
addEvent
)
.
addListener
(
topologyService
,
this
::
addEvent
)
.
addListener
(
hostService
,
this
::
addEvent
)
.
addListener
(
clusterService
,
this
::
addEvent
)
.
addListener
(
edgeService
,
this
::
addEvent
);
log
.
info
(
"Started"
);
...
...
@@ -172,15 +162,6 @@ public class EventHistoryManager
history
.
offer
(
event
);
}
class
InternalMastershipListener
implements
MastershipListener
{
@Override
public
void
event
(
MastershipEvent
event
)
{
addEvent
(
event
);
}
}
class
InternalDeviceListener
implements
DeviceListener
{
...
...
@@ -199,40 +180,4 @@ public class EventHistoryManager
}
}
class
InternalLinkListener
implements
LinkListener
{
@Override
public
void
event
(
LinkEvent
event
)
{
addEvent
(
event
);
}
}
class
InternalTopologyListener
implements
TopologyListener
{
@Override
public
void
event
(
TopologyEvent
event
)
{
addEvent
(
event
);
}
}
class
InternalHostListener
implements
HostListener
{
@Override
public
void
event
(
HostEvent
event
)
{
addEvent
(
event
);
}
}
class
InternalClusterListener
implements
ClusterEventListener
{
@Override
public
void
event
(
ClusterEvent
event
)
{
addEvent
(
event
);
}
}
}
...
...
core/api/src/main/java/org/onosproject/event/ListenerTracker.java
View file @
d90dbc9
...
...
@@ -15,13 +15,14 @@
*/
package
org
.
onosproject
.
event
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.annotation.concurrent.NotThreadSafe
;
import
org.apache.commons.lang3.tuple.Pair
;
import
com.google.common.annotations.Beta
;
import
com.google.common.collect.Lists
;
...
...
@@ -66,6 +67,9 @@ public class ListenerTracker {
*/
public
<
E
extends
Event
<?,
?>,
L
extends
EventListener
<
E
>>
ListenerTracker
addListener
(
ListenerService
<
E
,
L
>
service
,
L
listener
)
{
checkNotNull
(
service
);
checkNotNull
(
listener
);
service
.
addListener
(
listener
);
listeners
.
add
(
Pair
.
of
(
service
,
listener
));
return
this
;
...
...
Please
register
or
login
to post a comment