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-25 00:09:24 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f5479705fcd2bfe2aedd9c49e2ef48a0ac405aab
f5479705
1 parent
ce58fa76
DeviceStore bugfixes
Change-Id: Iebbfd99ea578c36438ec11e28e5230c73886dd55
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 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/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
View file @
f547970
package
org
.
onlab
.
onos
.
store
.
device
.
impl
;
import
static
com
.
google
.
common
.
base
.
Predicates
.
notNull
;
import
com.google.common.base.Optional
;
import
com.google.common.cache.LoadingCache
;
import
com.google.common.collect.FluentIterable
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.ImmutableSet.Builder
;
import
com.hazelcast.core.IMap
;
import
com.hazelcast.core.ISet
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -184,10 +187,12 @@ public class DistributedDeviceStore
desc
.
swVersion
(),
desc
.
serialNumber
());
synchronized
(
this
)
{
final
byte
[]
deviceIdBytes
=
serialize
(
device
.
id
());
rawDevices
.
put
(
deviceIdBytes
,
serialize
(
updated
));
devices
.
put
(
device
.
id
(),
Optional
.
of
(
updated
));
availableDevices
.
add
(
serialize
(
device
.
id
()));
}
return
new
DeviceEvent
(
DeviceEvent
.
Type
.
DEVICE_UPDATED
,
device
,
null
);
return
new
DeviceEvent
(
DeviceEvent
.
Type
.
DEVICE_UPDATED
,
updated
,
null
);
}
// Otherwise merely attempt to change availability
...
...
@@ -231,7 +236,7 @@ public class DistributedDeviceStore
events
.
addAll
(
pruneOldPorts
(
device
,
ports
,
processed
));
}
return
events
;
return
FluentIterable
.
from
(
events
).
filter
(
notNull
()).
toList
()
;
}
// Creates a new port based on the port description adds it to the map and
...
...
@@ -258,7 +263,7 @@ public class DistributedDeviceStore
portDescription
.
isEnabled
());
ports
.
put
(
port
.
number
(),
updatedPort
);
updatePortMap
(
device
.
id
(),
ports
);
return
new
DeviceEvent
(
PORT_UPDATED
,
device
,
p
ort
);
return
new
DeviceEvent
(
PORT_UPDATED
,
device
,
updatedP
ort
);
}
return
null
;
}
...
...
@@ -355,17 +360,17 @@ public class DistributedDeviceStore
@Override
protected
void
onAdd
(
DeviceId
deviceId
,
DefaultDevice
device
)
{
delegate
.
notify
(
new
DeviceEvent
(
DEVICE_ADDED
,
device
));
notifyDelegate
(
new
DeviceEvent
(
DEVICE_ADDED
,
device
));
}
@Override
protected
void
onRemove
(
DeviceId
deviceId
,
DefaultDevice
device
)
{
delegate
.
notify
(
new
DeviceEvent
(
DEVICE_REMOVED
,
device
));
notifyDelegate
(
new
DeviceEvent
(
DEVICE_REMOVED
,
device
));
}
@Override
protected
void
onUpdate
(
DeviceId
deviceId
,
DefaultDevice
device
)
{
delegate
.
notify
(
new
DeviceEvent
(
DEVICE_UPDATED
,
device
));
notifyDelegate
(
new
DeviceEvent
(
DEVICE_UPDATED
,
device
));
}
}
...
...
@@ -376,17 +381,17 @@ public class DistributedDeviceStore
@Override
protected
void
onAdd
(
DeviceId
deviceId
,
Map
<
PortNumber
,
Port
>
ports
)
{
//
delegate.notify
(new DeviceEvent(PORT_ADDED, getDevice(deviceId)));
//
notifyDelegate
(new DeviceEvent(PORT_ADDED, getDevice(deviceId)));
}
@Override
protected
void
onRemove
(
DeviceId
deviceId
,
Map
<
PortNumber
,
Port
>
ports
)
{
//
delegate.notify
(new DeviceEvent(PORT_REMOVED, getDevice(deviceId)));
//
notifyDelegate
(new DeviceEvent(PORT_REMOVED, getDevice(deviceId)));
}
@Override
protected
void
onUpdate
(
DeviceId
deviceId
,
Map
<
PortNumber
,
Port
>
ports
)
{
//
delegate.notify
(new DeviceEvent(PORT_UPDATED, getDevice(deviceId)));
//
notifyDelegate
(new DeviceEvent(PORT_UPDATED, getDevice(deviceId)));
}
}
...
...
core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java
View file @
f547970
...
...
@@ -107,7 +107,7 @@ public abstract class AbstractDistributedStore<E extends Event, D extends StoreD
@Override
public
void
entryRemoved
(
EntryEvent
<
byte
[],
byte
[]>
event
)
{
K
key
=
deserialize
(
event
.
getKey
());
V
val
=
deserialize
(
event
.
getValue
());
V
val
=
deserialize
(
event
.
get
Old
Value
());
cache
.
invalidate
(
key
);
onRemove
(
key
,
val
);
}
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
View file @
f547970
package
org
.
onlab
.
onos
.
net
.
trivial
.
impl
;
import
com.google.common.collect.FluentIterable
;
import
com.google.common.collect.ImmutableList
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -33,6 +35,7 @@ import java.util.Set;
import
java.util.concurrent.ConcurrentHashMap
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
static
com
.
google
.
common
.
base
.
Predicates
.
notNull
;
import
static
org
.
onlab
.
onos
.
net
.
device
.
DeviceEvent
.
Type
.*;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -123,7 +126,7 @@ public class SimpleDeviceStore
devices
.
put
(
device
.
id
(),
updated
);
availableDevices
.
add
(
device
.
id
());
}
return
new
DeviceEvent
(
DeviceEvent
.
Type
.
DEVICE_UPDATED
,
device
,
null
);
return
new
DeviceEvent
(
DeviceEvent
.
Type
.
DEVICE_UPDATED
,
updated
,
null
);
}
// Otherwise merely attempt to change availability
...
...
@@ -165,7 +168,7 @@ public class SimpleDeviceStore
events
.
addAll
(
pruneOldPorts
(
device
,
ports
,
processed
));
}
return
events
;
return
FluentIterable
.
from
(
events
).
filter
(
notNull
()).
toList
()
;
}
// Creates a new port based on the port description adds it to the map and
...
...
Please
register
or
login
to post a comment