blob: 5f81aef119f03c726e28f2a6b989ec4b2d6fc824 [file] [log] [blame]
tom8cc5aa72014-09-19 15:14:43 -07001package org.onlab.onos.store.device.impl;
2
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -07003import static com.google.common.base.Preconditions.checkArgument;
4import static com.google.common.base.Preconditions.checkNotNull;
5import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
6import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_MASTERSHIP_CHANGED;
7import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_REMOVED;
8import static org.onlab.onos.net.device.DeviceEvent.Type.PORT_ADDED;
9import static org.onlab.onos.net.device.DeviceEvent.Type.PORT_REMOVED;
10import static org.onlab.onos.net.device.DeviceEvent.Type.PORT_UPDATED;
11import static org.slf4j.LoggerFactory.getLogger;
tom8cc5aa72014-09-19 15:14:43 -070012
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -070013import java.net.URI;
tom8cc5aa72014-09-19 15:14:43 -070014import java.util.ArrayList;
15import java.util.Collections;
16import java.util.HashMap;
17import java.util.HashSet;
18import java.util.Iterator;
19import java.util.List;
20import java.util.Map;
21import java.util.Objects;
22import java.util.Set;
tom8cc5aa72014-09-19 15:14:43 -070023
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -070024import org.apache.felix.scr.annotations.Activate;
25import org.apache.felix.scr.annotations.Component;
26import org.apache.felix.scr.annotations.Deactivate;
27import org.apache.felix.scr.annotations.Reference;
28import org.apache.felix.scr.annotations.ReferenceCardinality;
29import org.apache.felix.scr.annotations.Service;
30import org.onlab.onos.net.DefaultDevice;
31import org.onlab.onos.net.DefaultPort;
32import org.onlab.onos.net.Device;
33import org.onlab.onos.net.DeviceId;
34import org.onlab.onos.net.Element;
35import org.onlab.onos.net.MastershipRole;
36import org.onlab.onos.net.Port;
37import org.onlab.onos.net.PortNumber;
38import org.onlab.onos.net.device.DeviceDescription;
39import org.onlab.onos.net.device.DeviceEvent;
40import org.onlab.onos.net.device.DeviceStore;
41import org.onlab.onos.net.device.PortDescription;
42import org.onlab.onos.net.provider.ProviderId;
43import org.onlab.util.KryoPool;
44import org.slf4j.Logger;
45
46import com.google.common.base.Optional;
47import com.google.common.cache.CacheBuilder;
48import com.google.common.cache.CacheLoader;
49import com.google.common.cache.LoadingCache;
50import com.google.common.collect.ImmutableList;
51import com.google.common.collect.ImmutableSet;
52import com.google.common.collect.ImmutableSet.Builder;
53import com.hazelcast.core.EntryAdapter;
54import com.hazelcast.core.EntryEvent;
55import com.hazelcast.core.HazelcastInstance;
56import com.hazelcast.core.IMap;
57import com.hazelcast.core.ISet;
58import com.hazelcast.core.MapEvent;
59
60import de.javakaffee.kryoserializers.URISerializer;
61
tom8cc5aa72014-09-19 15:14:43 -070062
63/**
64 * Manages inventory of infrastructure devices using Hazelcast-backed map.
65 */
66@Component(immediate = true)
67@Service
68public class DistributedDeviceStore implements DeviceStore {
69
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -070070 /**
71 * An IMap EntryListener, which reflects each remote event to cache.
72 *
73 * @param <K> IMap key type after deserialization
74 * @param <V> IMap value type after deserialization
75 */
76 public static final class RemoteEventHandler<K, V> extends
77 EntryAdapter<byte[], byte[]> {
78
79 private LoadingCache<K, Optional<V>> cache;
80
81 /**
82 * Constructor.
83 *
84 * @param cache cache to update
85 */
86 public RemoteEventHandler(
87 LoadingCache<K, Optional<V>> cache) {
88 this.cache = checkNotNull(cache);
89 }
90
91 @Override
92 public void mapCleared(MapEvent event) {
93 cache.invalidateAll();
94 }
95
96 @Override
97 public void entryUpdated(EntryEvent<byte[], byte[]> event) {
98 cache.put(POOL.<K>deserialize(event.getKey()),
99 Optional.of(POOL.<V>deserialize(
100 event.getValue())));
101 }
102
103 @Override
104 public void entryRemoved(EntryEvent<byte[], byte[]> event) {
105 cache.invalidate(POOL.<DeviceId>deserialize(event.getKey()));
106 }
107
108 @Override
109 public void entryAdded(EntryEvent<byte[], byte[]> event) {
110 entryUpdated(event);
111 }
112 }
113
114 /**
115 * CacheLoader to wrap Map value with Optional,
116 * to handle negative hit on underlying IMap.
117 *
118 * @param <K> IMap key type after deserialization
119 * @param <V> IMap value type after deserialization
120 */
121 public static final class OptionalCacheLoader<K, V> extends
122 CacheLoader<K, Optional<V>> {
123
124 private IMap<byte[], byte[]> rawMap;
125
126 /**
127 * Constructor.
128 *
129 * @param rawMap underlying IMap
130 */
131 public OptionalCacheLoader(IMap<byte[], byte[]> rawMap) {
132 this.rawMap = checkNotNull(rawMap);
133 }
134
135 @Override
136 public Optional<V> load(K key) throws Exception {
137 byte[] keyBytes = serialize(key);
138 byte[] valBytes = rawMap.get(keyBytes);
139 if (valBytes == null) {
140 return Optional.absent();
141 }
142 V dev = deserialize(valBytes);
143 return Optional.of(dev);
144 }
145 }
146
tom8cc5aa72014-09-19 15:14:43 -0700147 private final Logger log = getLogger(getClass());
148
149 public static final String DEVICE_NOT_FOUND = "Device with ID %s not found";
150
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700151 // FIXME Slice out types used in common to separate pool/namespace.
152 private static final KryoPool POOL = KryoPool.newBuilder()
153 .register(URI.class, new URISerializer())
154 .register(
155 ArrayList.class,
156
157 ProviderId.class,
158 Device.Type.class,
159
160 DeviceId.class,
161 DefaultDevice.class,
162 MastershipRole.class,
163 HashMap.class,
164 Port.class,
165 Element.class
166 )
167 .register(PortNumber.class, new PortNumberSerializer())
168 .register(DefaultPort.class, new DefaultPortSerializer())
169 .build()
170 .populate(10);
171
172 // private IMap<DeviceId, DefaultDevice> cache;
173 private IMap<byte[], byte[]> rawDevices;
174 private LoadingCache<DeviceId, Optional<DefaultDevice>> devices;
175
176 // private IMap<DeviceId, MastershipRole> roles;
177 private IMap<byte[], byte[]> rawRoles;
178 private LoadingCache<DeviceId, Optional<MastershipRole>> roles;
179
180 // private ISet<DeviceId> availableDevices;
181 private ISet<byte[]> availableDevices;
182
183 // TODO DevicePorts is very inefficient consider restructuring.
184 // private IMap<DeviceId, Map<PortNumber, Port>> devicePorts;
185 private IMap<byte[], byte[]> rawDevicePorts;
186 private LoadingCache<DeviceId, Optional<Map<PortNumber, Port>>> devicePorts;
187
188 // FIXME change to protected once we remove DistributedDeviceManagerTest.
189 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
190 /*protected*/public HazelcastInstance theInstance;
191
tom8cc5aa72014-09-19 15:14:43 -0700192
193 @Activate
194 public void activate() {
195 log.info("Started");
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700196
197 // IMap event handler needs value
198 final boolean includeValue = true;
199
200 // TODO decide on Map name scheme to avoid collision
201 rawDevices = theInstance.getMap("devices");
202 devices = new AbsentInvalidatingLoadingCache<DeviceId, DefaultDevice>(
203 CacheBuilder.newBuilder()
204 .build(new OptionalCacheLoader<DeviceId, DefaultDevice>(rawDevices)));
205 // refresh/populate cache based on notification from other instance
206 rawDevices.addEntryListener(
207 new RemoteEventHandler<DeviceId, DefaultDevice>(devices),
208 includeValue);
209
210 rawRoles = theInstance.getMap("roles");
211 roles = new AbsentInvalidatingLoadingCache<DeviceId, MastershipRole>(
212 CacheBuilder.newBuilder()
213 .build(new OptionalCacheLoader<DeviceId, MastershipRole>(rawRoles)));
214 // refresh/populate cache based on notification from other instance
215 rawRoles.addEntryListener(
216 new RemoteEventHandler<DeviceId, MastershipRole>(roles),
217 includeValue);
218
219 // TODO cache avai
220 availableDevices = theInstance.getSet("availableDevices");
221
222 rawDevicePorts = theInstance.getMap("devicePorts");
223 devicePorts = new AbsentInvalidatingLoadingCache<DeviceId, Map<PortNumber, Port>>(
224 CacheBuilder.newBuilder()
225 .build(new OptionalCacheLoader<DeviceId, Map<PortNumber, Port>>(rawDevicePorts)));
226 // refresh/populate cache based on notification from other instance
227 rawDevicePorts.addEntryListener(
228 new RemoteEventHandler<DeviceId, Map<PortNumber, Port>>(devicePorts),
229 includeValue);
230
tom8cc5aa72014-09-19 15:14:43 -0700231 }
232
233 @Deactivate
234 public void deactivate() {
235 log.info("Stopped");
236 }
237
238 @Override
239 public int getDeviceCount() {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700240 // TODO IMap size or cache size?
241 return rawDevices.size();
tom8cc5aa72014-09-19 15:14:43 -0700242 }
243
244 @Override
245 public Iterable<Device> getDevices() {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700246// TODO Revisit if we ever need to do this.
247// log.info("{}:{}", rawMap.size(), cache.size());
248// if (rawMap.size() != cache.size()) {
249// for (Entry<byte[], byte[]> e : rawMap.entrySet()) {
250// final DeviceId key = deserialize(e.getKey());
251// final DefaultDevice val = deserialize(e.getValue());
252// cache.put(key, val);
253// }
254// }
255
256 // TODO builder v.s. copyOf. Guava semms to be using copyOf?
257 Builder<Device> builder = ImmutableSet.<Device>builder();
258 for (Optional<DefaultDevice> e : devices.asMap().values()) {
259 if (e.isPresent()) {
260 builder.add(e.get());
261 }
262 }
263 return builder.build();
tom8cc5aa72014-09-19 15:14:43 -0700264 }
265
266 @Override
267 public Device getDevice(DeviceId deviceId) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700268 // TODO revisit if ignoring exception is safe.
269 return devices.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700270 }
271
272 @Override
273 public DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
274 DeviceDescription deviceDescription) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700275 DefaultDevice device = devices.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700276 if (device == null) {
277 return createDevice(providerId, deviceId, deviceDescription);
278 }
279 return updateDevice(providerId, device, deviceDescription);
280 }
281
282 // Creates the device and returns the appropriate event if necessary.
283 private DeviceEvent createDevice(ProviderId providerId, DeviceId deviceId,
284 DeviceDescription desc) {
285 DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(),
286 desc.manufacturer(),
287 desc.hwVersion(), desc.swVersion(),
288 desc.serialNumber());
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700289
tom8cc5aa72014-09-19 15:14:43 -0700290 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700291 final byte[] deviceIdBytes = serialize(deviceId);
292 rawDevices.put(deviceIdBytes, serialize(device));
293 devices.put(deviceId, Optional.of(device));
294
295 availableDevices.add(deviceIdBytes);
tom8cc5aa72014-09-19 15:14:43 -0700296
297 // For now claim the device as a master automatically.
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700298 rawRoles.put(deviceIdBytes, serialize(MastershipRole.MASTER));
299 roles.put(deviceId, Optional.of(MastershipRole.MASTER));
tom8cc5aa72014-09-19 15:14:43 -0700300 }
301 return new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, null);
302 }
303
304 // Updates the device and returns the appropriate event if necessary.
305 private DeviceEvent updateDevice(ProviderId providerId, DefaultDevice device,
306 DeviceDescription desc) {
307 // We allow only certain attributes to trigger update
308 if (!Objects.equals(device.hwVersion(), desc.hwVersion()) ||
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700309 !Objects.equals(device.swVersion(), desc.swVersion())) {
310
tom8cc5aa72014-09-19 15:14:43 -0700311 DefaultDevice updated = new DefaultDevice(providerId, device.id(),
312 desc.type(),
313 desc.manufacturer(),
314 desc.hwVersion(),
315 desc.swVersion(),
316 desc.serialNumber());
317 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700318 devices.put(device.id(), Optional.of(updated));
319 availableDevices.add(serialize(device.id()));
tom8cc5aa72014-09-19 15:14:43 -0700320 }
321 return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, device, null);
322 }
323
324 // Otherwise merely attempt to change availability
325 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700326 boolean added = availableDevices.add(serialize(device.id()));
tom8cc5aa72014-09-19 15:14:43 -0700327 return !added ? null :
328 new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null);
329 }
330 }
331
332 @Override
333 public DeviceEvent markOffline(DeviceId deviceId) {
334 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700335 Device device = devices.getUnchecked(deviceId).orNull();
336 boolean removed = device != null && availableDevices.remove(serialize(deviceId));
tom8cc5aa72014-09-19 15:14:43 -0700337 return !removed ? null :
338 new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null);
339 }
340 }
341
342 @Override
343 public List<DeviceEvent> updatePorts(DeviceId deviceId,
344 List<PortDescription> portDescriptions) {
345 List<DeviceEvent> events = new ArrayList<>();
346 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700347 Device device = devices.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700348 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
349 Map<PortNumber, Port> ports = getPortMap(deviceId);
350
351 // Add new ports
352 Set<PortNumber> processed = new HashSet<>();
353 for (PortDescription portDescription : portDescriptions) {
354 Port port = ports.get(portDescription.portNumber());
355 events.add(port == null ?
356 createPort(device, portDescription, ports) :
357 updatePort(device, port, portDescription, ports));
358 processed.add(portDescription.portNumber());
359 }
360
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700361 updatePortMap(deviceId, ports);
362
tom8cc5aa72014-09-19 15:14:43 -0700363 events.addAll(pruneOldPorts(device, ports, processed));
364 }
365 return events;
366 }
367
368 // Creates a new port based on the port description adds it to the map and
369 // Returns corresponding event.
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700370 //@GuardedBy("this")
tom8cc5aa72014-09-19 15:14:43 -0700371 private DeviceEvent createPort(Device device, PortDescription portDescription,
372 Map<PortNumber, Port> ports) {
373 DefaultPort port = new DefaultPort(device, portDescription.portNumber(),
374 portDescription.isEnabled());
375 ports.put(port.number(), port);
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700376 updatePortMap(device.id(), ports);
tom8cc5aa72014-09-19 15:14:43 -0700377 return new DeviceEvent(PORT_ADDED, device, port);
378 }
379
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700380 // Checks if the specified port requires update and if so, it replaces the
tom8cc5aa72014-09-19 15:14:43 -0700381 // existing entry in the map and returns corresponding event.
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700382 //@GuardedBy("this")
tom8cc5aa72014-09-19 15:14:43 -0700383 private DeviceEvent updatePort(Device device, Port port,
384 PortDescription portDescription,
385 Map<PortNumber, Port> ports) {
386 if (port.isEnabled() != portDescription.isEnabled()) {
387 DefaultPort updatedPort =
388 new DefaultPort(device, portDescription.portNumber(),
389 portDescription.isEnabled());
390 ports.put(port.number(), updatedPort);
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700391 updatePortMap(device.id(), ports);
tom8cc5aa72014-09-19 15:14:43 -0700392 return new DeviceEvent(PORT_UPDATED, device, port);
393 }
394 return null;
395 }
396
397 // Prunes the specified list of ports based on which ports are in the
398 // processed list and returns list of corresponding events.
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700399 //@GuardedBy("this")
tom8cc5aa72014-09-19 15:14:43 -0700400 private List<DeviceEvent> pruneOldPorts(Device device,
401 Map<PortNumber, Port> ports,
402 Set<PortNumber> processed) {
403 List<DeviceEvent> events = new ArrayList<>();
404 Iterator<PortNumber> iterator = ports.keySet().iterator();
405 while (iterator.hasNext()) {
406 PortNumber portNumber = iterator.next();
407 if (!processed.contains(portNumber)) {
408 events.add(new DeviceEvent(PORT_REMOVED, device,
409 ports.get(portNumber)));
410 iterator.remove();
411 }
412 }
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700413 if (!events.isEmpty()) {
414 updatePortMap(device.id(), ports);
415 }
tom8cc5aa72014-09-19 15:14:43 -0700416 return events;
417 }
418
419 // Gets the map of ports for the specified device; if one does not already
420 // exist, it creates and registers a new one.
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700421 // WARN: returned value is a copy, changes made to the Map
422 // needs to be written back using updatePortMap
423 //@GuardedBy("this")
tom8cc5aa72014-09-19 15:14:43 -0700424 private Map<PortNumber, Port> getPortMap(DeviceId deviceId) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700425 Map<PortNumber, Port> ports = devicePorts.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700426 if (ports == null) {
427 ports = new HashMap<>();
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700428 // this probably is waste of time in most cases.
429 updatePortMap(deviceId, ports);
tom8cc5aa72014-09-19 15:14:43 -0700430 }
431 return ports;
432 }
433
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700434 //@GuardedBy("this")
435 private void updatePortMap(DeviceId deviceId, Map<PortNumber, Port> ports) {
436 rawDevicePorts.put(serialize(deviceId), serialize(ports));
437 devicePorts.put(deviceId, Optional.of(ports));
438 }
439
tom8cc5aa72014-09-19 15:14:43 -0700440 @Override
441 public DeviceEvent updatePortStatus(DeviceId deviceId,
442 PortDescription portDescription) {
443 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700444 Device device = devices.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700445 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
446 Map<PortNumber, Port> ports = getPortMap(deviceId);
447 Port port = ports.get(portDescription.portNumber());
448 return updatePort(device, port, portDescription, ports);
449 }
450 }
451
452 @Override
453 public List<Port> getPorts(DeviceId deviceId) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700454 Map<PortNumber, Port> ports = devicePorts.getUnchecked(deviceId).orNull();
455 return ports == null ? Collections.<Port>emptyList() : ImmutableList.copyOf(ports.values());
tom8cc5aa72014-09-19 15:14:43 -0700456 }
457
458 @Override
459 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700460 Map<PortNumber, Port> ports = devicePorts.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700461 return ports == null ? null : ports.get(portNumber);
462 }
463
464 @Override
465 public boolean isAvailable(DeviceId deviceId) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700466 return availableDevices.contains(serialize(deviceId));
tom8cc5aa72014-09-19 15:14:43 -0700467 }
468
469 @Override
470 public MastershipRole getRole(DeviceId deviceId) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700471 MastershipRole role = roles.getUnchecked(deviceId).orNull();
tom8cc5aa72014-09-19 15:14:43 -0700472 return role != null ? role : MastershipRole.NONE;
473 }
474
475 @Override
476 public DeviceEvent setRole(DeviceId deviceId, MastershipRole role) {
477 synchronized (this) {
478 Device device = getDevice(deviceId);
479 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700480 MastershipRole oldRole = deserialize(
481 rawRoles.put(serialize(deviceId), serialize(role)));
482 roles.put(deviceId, Optional.of(role));
tom8cc5aa72014-09-19 15:14:43 -0700483 return oldRole == role ? null :
484 new DeviceEvent(DEVICE_MASTERSHIP_CHANGED, device, null);
485 }
486 }
487
488 @Override
489 public DeviceEvent removeDevice(DeviceId deviceId) {
490 synchronized (this) {
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700491 byte[] deviceIdBytes = serialize(deviceId);
492 rawRoles.remove(deviceIdBytes);
493 roles.invalidate(deviceId);
494
495 // TODO conditional remove?
496 Device device = deserialize(rawDevices.remove(deviceIdBytes));
497 devices.invalidate(deviceId);
tom8cc5aa72014-09-19 15:14:43 -0700498 return device == null ? null :
499 new DeviceEvent(DEVICE_REMOVED, device, null);
500 }
501 }
Yuta HIGUCHIb3b2ac42014-09-21 23:37:11 -0700502
503 // TODO cache serialized DeviceID if we suffer from serialization cost
504
505 private static byte[] serialize(final Object obj) {
506 return POOL.serialize(obj);
507 }
508
509 private static <T> T deserialize(final byte[] bytes) {
510 if (bytes == null) {
511 return null;
512 }
513 return POOL.deserialize(bytes);
514 }
515
tom8cc5aa72014-09-19 15:14:43 -0700516}