* Exception which is used to report that a particular request failed on the
* remote device (switch).
*/
-public class DeviceRequestFailedException extends Exception {
+public class DeviceRequestFailedException extends OutboundQueueException {
private static final long serialVersionUID = 1L;
private final Error error;
* If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable)
* will be called with an instance of {@link DeviceRequestFailedException}.
*
+ * If the request fails due to local reasons, {@link FutureCallback#onFailure(Throwable)
+ * will be called with an instance of {@link OutboundQueueException}. In particular, if
+ * this request failed because the device disconnected, {@link OutboundQueueException#DEVICE_DISCONNECTED}
+ * will be reported.
+ *
* @param xid Previously-reserved XID
* @param message Message which should be sent out, or null if the reservation
* should be cancelled.
--- /dev/null
+/*
+ * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.api.connection;
+
+/**
+ * Exception reported when an exceptional event occurs on an {@link OutboundQueue},
+ * which the {@link OutboundQueueHandler} needs to be aware of.
+ */
+public class OutboundQueueException extends Exception {
+ /**
+ * Exception reported when the device disconnects.
+ */
+ public static final OutboundQueueException DEVICE_DISCONNECTED = new OutboundQueueException("Device disconnected");
+
+ private static final long serialVersionUID = 1L;
+
+ public OutboundQueueException(final String message) {
+ super(message);
+ }
+
+ public OutboundQueueException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
import com.google.common.util.concurrent.FutureCallback;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import javax.annotation.Nonnull;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.slf4j.Logger;
completeRequests(queue.length);
}
- int failAll(final Throwable cause) {
+ int failAll(final OutboundQueueException cause) {
int ret = 0;
for (int i = lastBarrierOffset + 1; i < queue.length; ++i) {
final OutboundQueueEntry entry = queue[i];
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
-import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
LOG.debug("Channel shutdown, flushing queue...");
handler.onConnectionQueueChanged(null);
- final Throwable cause = new RejectedExecutionException("Channel disconnected");
for (OutboundQueueImpl queue : activeQueues) {
- entries += queue.failAll(cause);
+ entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED);
}
activeQueues.clear();