From fb84f7c52dd0973acbc66a4ad935a95f025a4a56 Mon Sep 17 00:00:00 2001 From: "michal.polkorab" Date: Mon, 23 Sep 2013 14:24:05 +0200 Subject: [PATCH] Fixed YANG - GetAsyncReply Added creation of source artifact to pom.xml in api project Implemented shutdown method in SwitchConnectionProvider Renamed CommunicationFacade interface to ConnectionFacade Removed version field from ConnectionAdapter Signed-off-by: michal.polkorab Change-Id: I44e411a3253f7bc0ed6be19945436efeb4ba20a1 --- openflow-protocol-api/pom.xml | 13 +++++++++++ .../api/connection/ConnectionAdapter.java | 8 +------ .../src/main/yang/openflow-protocol.yang | 18 ++++++++++----- .../connection/ConnectionAdapterFactory.java | 2 +- .../connection/ConnectionAdapterImpl.java | 16 +------------ ...ationFacade.java => ConnectionFacade.java} | 2 +- .../SwitchConnectionProviderImpl.java | 23 +++++++++++++++---- .../core/PublishingChannelInitializer.java | 4 ++-- .../connection/SwitchConnectionProvider.java | 2 +- 9 files changed, 51 insertions(+), 37 deletions(-) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/{CommunicationFacade.java => ConnectionFacade.java} (75%) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 65374963..2b8a65c1 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -68,6 +68,19 @@ + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + package + + jar-no-fork + + + + diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 888a7391..a955d135 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -34,11 +34,5 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * @param messageListener here will be pushed all messages from switch */ public void setMessageListener(OpenflowProtocolListener messageListener); - - /** - * @param version version of OpenFlow protocol to be used for communication with switch - * (set after version negotiation) - in wire protocol format e.g. 4 (or 0x04) for OF 1.3 - * - */ - public void setVersion(int version); + } diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 37fb5ae1..114d5119 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -660,14 +660,20 @@ module openflow-protocol { uses ofHeader; - leaf-list packet-in-mask { - type oft:packet-in-reason; + list packet-in-mask { + leaf-list mask { + type oft:packet-in-reason; + } } - leaf-list port-status-mask { - type oft:port-reason; + list port-status-mask { + leaf-list mask { + type oft:port-reason; + } } - leaf-list flow-removed-mask { - type oft:flow-removed-reason; + list flow-removed-mask { + leaf-list mask { + type oft:flow-removed-reason; + } } } grouping set-async { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java index 33048177..d0b25e5d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java @@ -20,7 +20,7 @@ public abstract class ConnectionAdapterFactory { * @param ch * @return connection adapter tcp-implementation */ - public static CommunicationFacade createConnectionAdapter(SocketChannel ch) { + public static ConnectionFacade createConnectionAdapter(SocketChannel ch) { ConnectionAdapterImpl connectionAdapter = new ConnectionAdapterImpl(); connectionAdapter.setChannel(ch); return connectionAdapter; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 9457373d..d07b5887 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -74,7 +74,7 @@ import com.google.common.util.concurrent.SettableFuture; * @author mirehak * @author michal.polkorab */ -public class ConnectionAdapterImpl implements CommunicationFacade { +public class ConnectionAdapterImpl implements ConnectionFacade { /** after this time, rpc future response objects will be thrown away (in minutes) */ public static final int RPC_RESPONSE_EXPIRATION = 1; @@ -86,7 +86,6 @@ public class ConnectionAdapterImpl implements CommunicationFacade { private static final String TAG = "OPENFLOW"; private Channel channel; private OpenflowProtocolListener messageListener; - private int version; /** expiring cache for future rpcResponses */ protected Cache> responseCache; @@ -240,11 +239,6 @@ public class ConnectionAdapterImpl implements CommunicationFacade { @Override public void consume(DataObject message) { - if (message == null) { - LOG.error("message is null"); - } else { - LOG.debug("message is ok"); - } if (message instanceof Notification) { if (message instanceof EchoRequestMessage) { messageListener.onEchoRequestMessage((EchoRequestMessage) message); @@ -472,12 +466,4 @@ public class ConnectionAdapterImpl implements CommunicationFacade { return (SettableFuture>) responseCache.getIfPresent(key); } - /* (non-Javadoc) - * @see org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter#setVersion(int) - */ - @Override - public void setVersion(int version) { - this.version = version; - } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/CommunicationFacade.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java similarity index 75% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/CommunicationFacade.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java index 1ac5c2b1..6cdc1f11 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/CommunicationFacade.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java @@ -7,7 +7,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; * @author michal.polkorab * */ -public interface CommunicationFacade extends MessageConsumer, ConnectionAdapter { +public interface ConnectionFacade extends MessageConsumer, ConnectionAdapter { // empty unifying superinterface } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 1ce61d19..3a540449 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -57,12 +57,27 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider { } @Override - public Future shutdown() { + public Future> shutdown() { LOG.debug("shutdown summoned"); - for (ServerFacade server : serverLot) { - server.shutdown(); + ListenableFuture> result = SettableFuture.create(); + try { + List> shutdownChain = new ArrayList<>(); + for (ServerFacade server : serverLot) { + ListenableFuture shutdownFuture = server.shutdown(); + shutdownChain.add(shutdownFuture); + } + + if (!shutdownChain.isEmpty()) { + result = Futures.allAsList(shutdownChain); + } else { + throw new IllegalStateException("no servers configured"); + } + } catch (Exception e) { + SettableFuture> exFuture = SettableFuture.create(); + exFuture.setException(e); + result = exFuture; } - return null; + return result; } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java index 27ecc2c5..2b1badaf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java @@ -8,7 +8,7 @@ import io.netty.channel.socket.SocketChannel; import java.util.Iterator; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.impl.connection.CommunicationFacade; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES; @@ -32,7 +32,7 @@ public class PublishingChannelInitializer extends ChannelInitializer shutdown(); + public Future> shutdown(); /** * @param switchConHandler instance being informed when new switch connects -- 2.36.6