2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.device;
10 import com.google.common.annotations.VisibleForTesting;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import io.netty.util.HashedWheelTimer;
16 import io.netty.util.Timeout;
17 import java.math.BigInteger;
18 import java.net.InetSocketAddress;
19 import java.util.Collection;
20 import java.util.HashMap;
21 import java.util.HashSet;
22 import java.util.Iterator;
23 import java.util.List;
25 import java.util.TreeMap;
26 import java.util.concurrent.ArrayBlockingQueue;
27 import java.util.concurrent.BlockingQueue;
28 import java.util.concurrent.ExecutionException;
29 import javax.annotation.Nonnull;
30 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
31 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
32 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
33 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
34 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
35 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
36 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
37 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
38 import org.opendaylight.openflowplugin.api.openflow.connection.ThrottledNotificationsOfferer;
39 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
40 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
41 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
42 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
43 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
44 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
45 import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
46 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
47 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
48 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
49 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
50 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
51 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
52 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
53 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
54 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
55 import org.opendaylight.openflowplugin.impl.common.NodeStaticReplyTranslatorUtil;
56 import org.opendaylight.openflowplugin.impl.device.listener.MultiMsgCollectorImpl;
57 import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
58 import org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl;
59 import org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl;
60 import org.opendaylight.openflowplugin.impl.services.RequestContextUtil;
61 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
80 import org.opendaylight.yangtools.yang.binding.ChildOf;
81 import org.opendaylight.yangtools.yang.binding.DataObject;
82 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
83 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
84 import org.opendaylight.yangtools.yang.common.RpcError;
85 import org.opendaylight.yangtools.yang.common.RpcResult;
86 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
87 import org.slf4j.Logger;
88 import org.slf4j.LoggerFactory;
93 public class DeviceContextImpl implements DeviceContext {
95 private static final Logger LOG = LoggerFactory.getLogger(DeviceContextImpl.class);
96 public static final String DEVICE_DISCONNECTED = "Device disconnected.";
98 private final ConnectionContext primaryConnectionContext;
99 private final DeviceState deviceState;
100 private final DataBroker dataBroker;
101 private final HashedWheelTimer hashedWheelTimer;
102 private final Map<Long, RequestContext> requests = new TreeMap<>();
104 private final Map<SwitchConnectionDistinguisher, ConnectionContext> auxiliaryConnectionContexts;
105 private final TransactionChainManager txChainManager;
106 private TranslatorLibrary translatorLibrary;
107 private final DeviceFlowRegistry deviceFlowRegistry;
108 private final DeviceGroupRegistry deviceGroupRegistry;
109 private final DeviceMeterRegistry deviceMeterRegistry;
110 private Timeout barrierTaskTimeout;
111 private NotificationService notificationService;
112 private final MessageSpy<Class<?>> messageSpy;
113 private DeviceDisconnectedHandler deviceDisconnectedHandler;
114 private final Collection<DeviceContextClosedHandler> closeHandlers = new HashSet<>();
115 private NotificationPublishService notificationPublishService;
116 private final ThrottledNotificationsOfferer throttledConnectionsHolder;
117 private final BlockingQueue<PacketReceived> bumperQueue;
118 private final OutboundQueue outboundQueueProvider;
121 public MultiMsgCollector getMultiMsgCollector() {
122 return multiMsgCollector;
126 public Long getReservedXid() {
127 return outboundQueueProvider.reserveEntry();
130 private final MultiMsgCollector multiMsgCollector = new MultiMsgCollectorImpl();
134 DeviceContextImpl(@Nonnull final ConnectionContext primaryConnectionContext,
135 @Nonnull final DeviceState deviceState,
136 @Nonnull final DataBroker dataBroker,
137 @Nonnull final HashedWheelTimer hashedWheelTimer,
138 @Nonnull final MessageSpy _messageSpy,
139 @Nonnull final ThrottledNotificationsOfferer throttledConnectionsHolder) {
140 this.primaryConnectionContext = Preconditions.checkNotNull(primaryConnectionContext);
141 this.deviceState = Preconditions.checkNotNull(deviceState);
142 this.dataBroker = Preconditions.checkNotNull(dataBroker);
143 this.hashedWheelTimer = Preconditions.checkNotNull(hashedWheelTimer);
144 txChainManager = new TransactionChainManager(dataBroker, hashedWheelTimer, 500L, 500L);
145 auxiliaryConnectionContexts = new HashMap<>();
146 deviceFlowRegistry = new DeviceFlowRegistryImpl();
147 deviceGroupRegistry = new DeviceGroupRegistryImpl();
148 deviceMeterRegistry = new DeviceMeterRegistryImpl();
149 messageSpy = _messageSpy;
150 this.throttledConnectionsHolder = throttledConnectionsHolder;
151 bumperQueue = new ArrayBlockingQueue<>(5000);
152 multiMsgCollector.setDeviceReplyProcessor(this);
153 outboundQueueProvider = Preconditions.checkNotNull(primaryConnectionContext.getOutboundQueueProvider());
157 * This method is called from {@link DeviceManagerImpl} only. So we could say "posthandshake process finish"
158 * and we are able to set a scheduler for an automatic transaction submitting by time (0,5sec).
160 void submitTransaction() {
161 txChainManager.enableSubmit();
162 txChainManager.submitTransaction();
166 public <M extends ChildOf<DataObject>> void onMessage(final M message, final RequestContext requestContext) {
167 // TODO Auto-generated method stub
172 public void addAuxiliaryConenctionContext(final ConnectionContext connectionContext) {
173 final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
174 auxiliaryConnectionContexts.put(connectionDistinguisher, connectionContext);
177 private static SwitchConnectionDistinguisher createConnectionDistinguisher(final ConnectionContext connectionContext) {
178 return new SwitchConnectionCookieOFImpl(connectionContext.getFeatures().getAuxiliaryId());
182 public void removeAuxiliaryConenctionContext(final ConnectionContext connectionContext) {
183 // TODO Auto-generated method stub
187 public DeviceState getDeviceState() {
192 public ReadTransaction getReadTransaction() {
193 return dataBroker.newReadOnlyTransaction();
197 public <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store,
198 final InstanceIdentifier<T> path, final T data) {
199 txChainManager.writeToTransaction(store, path, data);
203 public <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
204 txChainManager.addDeleteOperationTotTxChain(store, path);
208 public ConnectionContext getPrimaryConnectionContext() {
209 return primaryConnectionContext;
213 public ConnectionContext getAuxiliaryConnectiobContexts(final BigInteger cookie) {
214 return auxiliaryConnectionContexts.get(new SwitchConnectionCookieOFImpl(cookie.longValue()));
218 public RequestContext lookupRequest(final Xid xid) {
219 synchronized (requests) {
220 return requests.get(xid.getValue());
225 public int getNumberOfOutstandingRequests() {
226 synchronized (requests) {
227 return requests.size();
232 public void hookRequestCtx(final Xid xid, final RequestContext requestFutureContext) {
233 synchronized (requests) {
234 requests.put(xid.getValue(), requestFutureContext);
239 public RequestContext unhookRequestCtx(final Xid xid) {
240 synchronized (requests) {
241 return requests.remove(xid.getValue());
246 public DeviceFlowRegistry getDeviceFlowRegistry() {
247 return deviceFlowRegistry;
251 public DeviceGroupRegistry getDeviceGroupRegistry() {
252 return deviceGroupRegistry;
256 public DeviceMeterRegistry getDeviceMeterRegistry() {
257 return deviceMeterRegistry;
261 public void processReply(final OfHeader ofHeader) {
262 final RequestContext requestContext = requests.remove(ofHeader.getXid());
263 if (null != requestContext) {
264 RpcResult<OfHeader> rpcResult;
265 if (ofHeader instanceof Error) {
266 //TODO : this is the point, where we can discover that add flow operation failed and where we should
267 //TODO : remove this flow from deviceFlowRegistry
268 final Error error = (Error) ofHeader;
269 final String message = "Operation on device failed with xid " + ofHeader.getXid() + ".";
270 rpcResult = RpcResultBuilder
272 .withError(RpcError.ErrorType.APPLICATION, message, new DeviceDataException(message, error))
274 messageSpy.spyMessage(ofHeader.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
276 rpcResult = RpcResultBuilder
278 .withResult(ofHeader)
280 messageSpy.spyMessage(ofHeader.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
283 requestContext.setResult(rpcResult);
285 requestContext.close();
286 } catch (final Exception e) {
287 LOG.warn("Closing RequestContext failed: {}", e.getMessage());
288 LOG.debug("Closing RequestContext failed.. ", e);
291 LOG.warn("Can't find request context registered for xid : {}. Type of reply: {}. From address: {}", ofHeader.getXid(), ofHeader.getClass().getName(),
292 getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress());
297 public void processReply(final Xid xid, final List<MultipartReply> ofHeaderList) {
298 final RequestContext requestContext;
299 synchronized (requests) {
300 requestContext = requests.remove(xid.getValue());
302 if (null != requestContext) {
303 final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
304 .<List<MultipartReply>>success()
305 .withResult(ofHeaderList)
307 requestContext.setResult(rpcResult);
308 for (final MultipartReply multipartReply : ofHeaderList) {
309 messageSpy.spyMessage(multipartReply.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
312 unhookRequestCtx(xid);
314 requestContext.close();
315 } catch (final Exception e) {
316 LOG.warn("Closing RequestContext failed: {}", e.getMessage());
317 LOG.debug("Closing RequestContext failed.. ", e);
320 LOG.warn("Can't find request context registered for xid : {}. Type of reply: MULTIPART. From address: {}", xid.getValue(),
321 getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress());
326 public void processException(final Xid xid, final DeviceDataException deviceDataException) {
328 LOG.trace("Processing exception for xid : {}", xid.getValue());
330 final RequestContext requestContext = requests.remove(xid.getValue());
332 if (null != requestContext) {
333 final RpcResult<List<OfHeader>> rpcResult = RpcResultBuilder
334 .<List<OfHeader>>failed()
335 .withError(RpcError.ErrorType.APPLICATION, String.format("Message processing failed : %s", deviceDataException.getError()), deviceDataException)
337 requestContext.setResult(rpcResult);
338 messageSpy.spyMessage(deviceDataException.getClass(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
340 requestContext.close();
341 } catch (final Exception e) {
342 LOG.warn("Closing RequestContext failed: ", e);
343 LOG.debug("Closing RequestContext failed..", e);
346 LOG.warn("Can't find request context registered for xid : {}. Exception message {}",
347 xid.getValue(), deviceDataException.getMessage());
352 public void processFlowRemovedMessage(final FlowRemoved flowRemoved) {
353 //TODO: will be defined later
357 public void processPortStatusMessage(final PortStatusMessage portStatus) {
358 messageSpy.spyMessage(portStatus.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
359 final TranslatorKey translatorKey = new TranslatorKey(portStatus.getVersion(), PortGrouping.class.getName());
360 final MessageTranslator<PortGrouping, FlowCapableNodeConnector> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
361 final FlowCapableNodeConnector flowCapableNodeConnector = messageTranslator.translate(portStatus, this, null);
363 final KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> iiToNodeConnector = provideIIToNodeConnector(portStatus.getPortNo(), portStatus.getVersion());
364 if (portStatus.getReason().equals(PortReason.OFPPRADD) || portStatus.getReason().equals(PortReason.OFPPRMODIFY)) {
365 // because of ADD status node connector has to be created
366 final NodeConnectorBuilder nConnectorBuilder = new NodeConnectorBuilder().setKey(iiToNodeConnector.getKey());
367 nConnectorBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class, new FlowCapableNodeConnectorStatisticsDataBuilder().build());
368 nConnectorBuilder.addAugmentation(FlowCapableNodeConnector.class, flowCapableNodeConnector);
369 writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector, nConnectorBuilder.build());
370 } else if (portStatus.getReason().equals(PortReason.OFPPRDELETE)) {
371 addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector);
375 private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> provideIIToNodeConnector(final long portNo, final short version) {
376 final InstanceIdentifier<Node> iiToNodes = deviceState.getNodeInstanceIdentifier();
377 final BigInteger dataPathId = deviceState.getFeatures().getDatapathId();
378 final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(dataPathId.toString(), portNo, version);
379 return iiToNodes.child(NodeConnector.class, new NodeConnectorKey(nodeConnectorId));
383 public void processPacketInMessage(final PacketInMessage packetInMessage) {
384 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH);
386 final TranslatorKey translatorKey = new TranslatorKey(packetInMessage.getVersion(), PacketIn.class.getName());
387 final MessageTranslator<PacketInMessage, PacketReceived> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
388 final PacketReceived packetReceived = messageTranslator.translate(packetInMessage, this, null);
390 if (packetReceived != null) {
391 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
393 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
397 ListenableFuture<?> listenableFuture = notificationPublishService.offerNotification(packetReceived);
398 if (NotificationPublishService.REJECTED.equals(listenableFuture)) {
399 LOG.debug("notification offer rejected");
400 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_NOTIFICATION_REJECTED);
401 } else if (listenableFuture.isDone()) {
404 x = listenableFuture.get();
405 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
406 } catch (InterruptedException e) {
407 LOG.debug("notification offer interrupted: {}", e.getMessage());
408 LOG.trace("notification offer interrupted..", e);
409 } catch (ExecutionException e) {
410 LOG.debug("notification offer failed: {}", e.getMessage());
411 LOG.trace("notification offer failed..", e);
414 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_NOTIFICATION_REJECTED);
418 messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
422 private void applyThrottling(final PacketReceived packetReceived, final ConnectionAdapter connectionAdapter) {
423 final InetSocketAddress remoteAddress = connectionAdapter.getRemoteAddress();
424 LOG.debug("Notification offer refused by notification service.");
425 messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
426 connectionAdapter.setAutoRead(false);
428 LOG.debug("Throttling ingress for {}", remoteAddress);
429 final ListenableFuture<Void> queueDone;
431 // adding first notification
432 bumperQueue.offer(packetReceived);
433 synchronized (bumperQueue) {
434 queueDone = throttledConnectionsHolder.applyThrottlingOnConnection(bumperQueue);
436 Futures.addCallback(queueDone, new FutureCallback<Void>() {
438 public void onSuccess(final Void result) {
439 LOG.debug("Un - throttling ingress for {}", remoteAddress);
440 connectionAdapter.setAutoRead(true);
444 public void onFailure(final Throwable t) {
445 LOG.warn("failed to offer queued notification for {}: {}", remoteAddress, t.getMessage());
446 LOG.debug("failed to offer queued notification for {}.. ", remoteAddress, t);
452 public TranslatorLibrary oook() {
453 return translatorLibrary;
457 public void setTranslatorLibrary(final TranslatorLibrary translatorLibrary) {
458 this.translatorLibrary = translatorLibrary;
462 public HashedWheelTimer getTimer() {
463 return hashedWheelTimer;
467 public void close() throws Exception {
468 deviceState.setValid(false);
470 LOG.trace("Removing node {} from operational DS.", getDeviceState().getNodeId());
471 addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, getDeviceState().getNodeInstanceIdentifier());
473 deviceGroupRegistry.close();
474 deviceFlowRegistry.close();
475 deviceMeterRegistry.close();
477 if (primaryConnectionContext.getConnectionAdapter().isAlive()) {
478 primaryConnectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.RIP);
479 primaryConnectionContext.getConnectionAdapter().disconnect();
481 for (final Map.Entry<Long, RequestContext> entry : requests.entrySet()) {
482 RequestContextUtil.closeRequestContextWithRpcError(entry.getValue(), DEVICE_DISCONNECTED);
484 for (final ConnectionContext connectionContext : auxiliaryConnectionContexts.values()) {
485 if (connectionContext.getConnectionAdapter().isAlive()) {
486 connectionContext.getConnectionAdapter().disconnect();
489 for (final DeviceContextClosedHandler deviceContextClosedHandler : closeHandlers) {
490 deviceContextClosedHandler.onDeviceContextClosed(this);
496 public void onDeviceDisconnected(final ConnectionContext connectionContext) {
497 if (this.getPrimaryConnectionContext().equals(connectionContext)) {
500 } catch (final Exception e) {
501 LOG.trace("Error closing device context.");
503 if (null != deviceDisconnectedHandler) {
504 deviceDisconnectedHandler.onDeviceDisconnected(connectionContext);
507 final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
508 auxiliaryConnectionContexts.remove(connectionDistinguisher);
513 public RequestContext extractNextOutstandingMessage(final long barrierXid) {
514 RequestContext nextMessage = null;
515 synchronized (requests) {
516 final Iterator<Long> keyIterator = requests.keySet().iterator();
517 if (keyIterator.hasNext()) {
518 final Long oldestXid = keyIterator.next();
519 if (oldestXid < barrierXid) {
520 nextMessage = requests.remove(oldestXid);
528 public void setCurrentBarrierTimeout(final Timeout timeout) {
529 barrierTaskTimeout = timeout;
533 public Timeout getBarrierTaskTimeout() {
534 return barrierTaskTimeout;
538 public void setNotificationService(final NotificationService notificationServiceParam) {
539 notificationService = notificationServiceParam;
543 public void setNotificationPublishService(final NotificationPublishService notificationPublishService) {
544 this.notificationPublishService = notificationPublishService;
548 public MessageSpy getMessageSpy() {
553 public void setDeviceDisconnectedHandler(final DeviceDisconnectedHandler deviceDisconnectedHandler) {
554 this.deviceDisconnectedHandler = deviceDisconnectedHandler;
558 public void addDeviceContextClosedHandler(final DeviceContextClosedHandler deviceContextClosedHandler) {
559 this.closeHandlers.add(deviceContextClosedHandler);
563 public void startGatheringOperationsToOneTransaction() {
564 txChainManager.startGatheringOperationsToOneTransaction();
568 public void commitOperationsGatheredInOneTransaction() {
569 txChainManager.commitOperationsGatheredInOneTransaction();