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
2014-09-24 00:00:13 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bb1fc725481e8289e627ed7274bc81723e4eedba
bb1fc725
1 parent
b4139d8d
Conditionally update Cache
Change-Id: I97b4e537c15110b8962d585421cd4f4a14a82841
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java
core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
View file @
bb1fc72
...
...
@@ -73,6 +73,7 @@ public class DistributedDeviceStore
private
IMap
<
byte
[],
byte
[]>
rawDevicePorts
;
private
LoadingCache
<
DeviceId
,
Optional
<
Map
<
PortNumber
,
Port
>>>
devicePorts
;
@Override
@Activate
public
void
activate
()
{
super
.
activate
();
...
...
@@ -361,5 +362,4 @@ public class DistributedDeviceStore
}
// TODO cache serialized DeviceID if we suffer from serialization cost
}
...
...
core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java
View file @
bb1fc72
...
...
@@ -6,6 +6,7 @@ import com.hazelcast.core.EntryAdapter;
import
com.hazelcast.core.EntryEvent
;
import
com.hazelcast.core.HazelcastInstance
;
import
com.hazelcast.core.MapEvent
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Reference
;
...
...
@@ -86,8 +87,12 @@ public abstract class AbstractDistributedStore<E extends Event, D extends StoreD
@Override
public
void
entryUpdated
(
EntryEvent
<
byte
[],
byte
[]>
event
)
{
cache
.
put
(
storeService
.<
K
>
deserialize
(
event
.
getKey
()),
Optional
.
of
(
storeService
.<
V
>
deserialize
(
event
.
getValue
())));
K
key
=
storeService
.<
K
>
deserialize
(
event
.
getKey
());
final
V
oldVal
=
storeService
.<
V
>
deserialize
(
event
.
getOldValue
());
Optional
<
V
>
oldValue
=
Optional
.
fromNullable
(
oldVal
);
final
V
newVal
=
storeService
.<
V
>
deserialize
(
event
.
getValue
());
Optional
<
V
>
newValue
=
Optional
.
of
(
newVal
);
cache
.
asMap
().
replace
(
key
,
oldValue
,
newValue
);
}
@Override
...
...
@@ -97,7 +102,10 @@ public abstract class AbstractDistributedStore<E extends Event, D extends StoreD
@Override
public
void
entryAdded
(
EntryEvent
<
byte
[],
byte
[]>
event
)
{
entryUpdated
(
event
);
K
key
=
storeService
.<
K
>
deserialize
(
event
.
getKey
());
final
V
newVal
=
storeService
.<
V
>
deserialize
(
event
.
getValue
());
Optional
<
V
>
newValue
=
Optional
.
of
(
newVal
);
cache
.
asMap
().
putIfAbsent
(
key
,
newValue
);
}
}
...
...
Please
register
or
login
to post a comment