<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bgp-concepts</artifactId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <artifactId>util</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>util</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>concepts</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bgp-concepts</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>bgp-parser-api</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ </dependency>
+
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>concepts</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <artifactId>util</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>util</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>concepts</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<surefire.version>2.15</surefire.version>
<yangtools.version>0.5.9-SNAPSHOT</yangtools.version>
- <controller.config.version>0.2.3-SNAPSHOT</controller.config.version>
<yang.binding.version>0.6.0-SNAPSHOT</yang.binding.version>
+
+ <controller.config.version>0.2.3-SNAPSHOT</controller.config.version>
<ietf.types.version>2010.09.24.2-SNAPSHOT</ietf.types.version>
<ietf.topology.version>2013.10.21.0-SNAPSHOT</ietf.topology.version>
</properties>
<artifactId>concepts</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
</dependency>
<!-- Controller infrastructure -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
+++ /dev/null
-target
-.classpath
-.settings
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>common-protocol</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
- <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
- <tag>HEAD</tag>
- </scm>
- <parent>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>commons.parent</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <relativePath>../commons/parent</relativePath>
- </parent>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
-
- <artifactId>framework</artifactId>
- <description>Common protocol framework</description>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-buffer</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-common</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-transport</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <!-- Testing dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.util.concurrent.DefaultPromise;
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.Promise;
-
-import java.io.Closeable;
-import java.net.InetSocketAddress;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Dispatcher class for creating servers and clients. The idea is to first create servers and clients and the run the
- * start method that will handle sockets in different thread.
- */
-public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> implements Closeable {
-
- protected interface PipelineInitializer<S extends ProtocolSession<?>> {
- /**
- * Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore this
- * method needs to be implemented in protocol specific Dispatchers.
- *
- * @param channel whose pipeline should be defined, also to be passed to {@link SessionNegotiatorFactory}
- * @param promise to be passed to {@link SessionNegotiatorFactory}
- */
- void initializeChannel(SocketChannel channel, Promise<S> promise);
- }
-
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDispatcher.class);
-
- private final EventLoopGroup bossGroup;
-
- private final EventLoopGroup workerGroup;
-
- private final EventExecutor executor;
-
- /**
- * Internally creates new instances of NioEventLoopGroup, might deplete system resources and result in Too many open files exception.
- *
- * @deprecated use {@link AbstractDispatcher#AbstractDispatcher(io.netty.channel.EventLoopGroup, io.netty.channel.EventLoopGroup)} instead.
- */
- @Deprecated
- protected AbstractDispatcher() {
- this(GlobalEventExecutor.INSTANCE, new NioEventLoopGroup(),new NioEventLoopGroup());
- }
-
- protected AbstractDispatcher(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
- this(GlobalEventExecutor.INSTANCE, bossGroup, workerGroup);
- }
-
- protected AbstractDispatcher(final EventExecutor executor, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
- this.bossGroup = Preconditions.checkNotNull(bossGroup);
- this.workerGroup = Preconditions.checkNotNull(workerGroup);
- this.executor = Preconditions.checkNotNull(executor);
- }
-
-
- /**
- * Creates server. Each server needs factories to pass their instances to client sessions.
- *
- * @param address address to which the server should be bound
- * @param initializer instance of PipelineInitializer used to initialize the channel pipeline
- *
- * @return ChannelFuture representing the binding process
- */
- protected ChannelFuture createServer(final InetSocketAddress address, final PipelineInitializer<S> initializer) {
- final ServerBootstrap b = new ServerBootstrap();
- b.group(this.bossGroup, this.workerGroup);
- b.channel(NioServerSocketChannel.class);
- b.option(ChannelOption.SO_BACKLOG, 128);
- b.childHandler(new ChannelInitializer<SocketChannel>() {
-
- @Override
- protected void initChannel(final SocketChannel ch) {
- initializer.initializeChannel(ch, new DefaultPromise<S>(executor));
- }
- });
- b.childOption(ChannelOption.SO_KEEPALIVE, true);
-
- // Bind and start to accept incoming connections.
- final ChannelFuture f = b.bind(address);
- LOG.debug("Initiated server {} at {}.", f, address);
- return f;
-
- }
-
- /**
- * Creates a client.
- *
- * @param address remote address
- * @param connectStrategy Reconnection strategy to be used when initial connection fails
- *
- * @return Future representing the connection process. Its result represents the combined success of TCP connection
- * as well as session negotiation.
- */
- protected Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final PipelineInitializer<S> initializer) {
- final Bootstrap b = new Bootstrap();
- final ProtocolSessionPromise<S> p = new ProtocolSessionPromise<S>(executor, address, strategy, b);
- b.group(this.workerGroup).channel(NioSocketChannel.class).option(ChannelOption.SO_KEEPALIVE, true).handler(
- new ChannelInitializer<SocketChannel>() {
-
- @Override
- protected void initChannel(final SocketChannel ch) {
- initializer.initializeChannel(ch, p);
- }
- });
- p.connect();
- LOG.debug("Client created.");
- return p;
- }
-
- /**
- * Creates a client.
- *
- * @param address remote address
- * @param connectStrategyFactory Factory for creating reconnection strategy to be used when initial connection fails
- * @param reestablishStrategy Reconnection strategy to be used when the already-established session fails
- *
- * @return Future representing the reconnection task. It will report completion based on reestablishStrategy, e.g.
- * success if it indicates no further attempts should be made and failure if it reports an error
- */
- protected Future<Void> createReconnectingClient(final InetSocketAddress address, final ReconnectStrategyFactory connectStrategyFactory,
- final ReconnectStrategy reestablishStrategy, final PipelineInitializer<S> initializer) {
-
- final ReconnectPromise<S, L> p = new ReconnectPromise<S, L>(GlobalEventExecutor.INSTANCE, this, address, connectStrategyFactory, reestablishStrategy, initializer);
- p.connect();
-
- return p;
-
- }
-
- /**
- * @deprecated Should only be used with {@link AbstractDispatcher#AbstractDispatcher()}
- */
- @Deprecated
- @Override
- public void close() {
- try {
- this.workerGroup.shutdownGracefully();
- } finally {
- this.bossGroup.shutdownGracefully();
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractProtocolSession<M> extends SimpleChannelInboundHandler<Object> implements ProtocolSession<M> {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractProtocolSession.class);
-
- /**
- * Handles incoming message (parsing, reacting if necessary).
- *
- * @param msg incoming message
- */
- protected abstract void handleMessage(final M msg);
-
- /**
- * Called when reached the end of input stream while reading.
- */
- protected abstract void endOfInput();
-
- /**
- * Called when the session is added to the pipeline.
- */
- protected abstract void sessionUp();
-
- @Override
- public final void channelInactive(final ChannelHandlerContext ctx) {
- LOG.debug("Channel {} inactive.", ctx.channel());
- endOfInput();
- }
-
- @Override
- protected final void channelRead0(final ChannelHandlerContext ctx, final Object msg) {
- LOG.debug("Message was received: {}", msg);
- handleMessage((M) msg);
- }
-
- @Override
- public final void handlerAdded(final ChannelHandlerContext ctx) {
- sessionUp();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.concurrent.Promise;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Abstract base class for session negotiators. It implements the basic
- * substrate to implement SessionNegotiator API specification, with subclasses
- * needing to provide only
- *
- * @param <M> Protocol message type
- * @param <S> Protocol session type, has to extend ProtocolSession<M>
- */
-public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>> extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
- private final Logger logger = LoggerFactory.getLogger(AbstractSessionNegotiator.class);
- private final Promise<S> promise;
- protected final Channel channel;
-
- public AbstractSessionNegotiator(final Promise<S> promise, final Channel channel) {
- this.promise = Preconditions.checkNotNull(promise);
- this.channel = Preconditions.checkNotNull(channel);
- }
-
- protected abstract void startNegotiation() throws Exception;
- protected abstract void handleMessage(M msg) throws Exception;
-
- protected final void negotiationSuccessful(final S session) {
- logger.debug("Negotiation on channel {} successful with session {}", channel, session);
- channel.pipeline().replace(this, "session", session);
- promise.setSuccess(session);
- }
-
- protected final void negotiationFailed(final Throwable cause) {
- logger.debug("Negotiation on channel {} failed", channel, cause);
- channel.close();
- promise.setFailure(cause);
- }
-
- @Override
- public final void channelActive(final ChannelHandlerContext ctx) {
- logger.debug("Starting session negotiation on channel {}", channel);
- try {
- startNegotiation();
- } catch (Exception e) {
- logger.info("Unexpected negotiation failure", e);
- negotiationFailed(e);
- }
- }
-
- @Override
- public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
- logger.debug("Negotiation read invoked on channel {}", channel);
- try {
- handleMessage((M)msg);
- } catch (Exception e) {
- logger.debug("Unexpected exception during negotiation", e);
- negotiationFailed(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-/**
- * Used when something occurs during parsing bytes to java objects.
- *
- * @deprecated This exception no longer carries any special meaning. Users
- * are advised to stop using it and define their own replacement.
- */
-@Deprecated
-public class DeserializerException extends Exception {
-
- private static final long serialVersionUID = -2247000673438452870L;
-
- /**
- * Creates a deserializer exception.
- * @param err string
- */
- public DeserializerException(final String err) {
- super(err);
- }
-
- /**
- * Creates a deserializer exception.
- * @param err string
- * @param e underlying exception
- */
- public DeserializerException(final String err, final Throwable e) {
- super(err, e);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-/**
- * Documented exception occurrs when an error is thrown that is documented
- * in any RFC or draft for the specific protocol.
- *
- * @deprecated This exception no longer carries any special meaning. Users
- * are advised to stop using it and define their own replacement.
- */
-@Deprecated
-public class DocumentedException extends Exception {
-
- private static final long serialVersionUID = -3727963789710833704L;
-
- /**
- * Creates a documented exception
- * @param message string
- */
- public DocumentedException(final String message) {
- super(message);
- }
-
- /**
- * Creates a documented exception
- * @param err string
- * @param cause the cause (which is saved for later retrieval by the
- * Throwable.getCause() method). (A null value is permitted, and indicates
- * that the cause is nonexistent or unknown.)
- */
- public DocumentedException(final String err, final Exception cause) {
- super(err, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Utility ReconnectStrategy singleton, which will cause the reconnect process
- * to always fail.
- */
-@ThreadSafe
-public final class NeverReconnectStrategy implements ReconnectStrategy {
- private final EventExecutor executor;
- private final int timeout;
-
- public NeverReconnectStrategy(final EventExecutor executor, final int timeout) {
- Preconditions.checkArgument(timeout >= 0);
- this.executor = Preconditions.checkNotNull(executor);
- this.timeout = timeout;
- }
-
- @Override
- public Future<Void> scheduleReconnect(final Throwable cause) {
- return executor.newFailedFuture(new Throwable());
- }
-
- @Override
- public void reconnectSuccessful() {
- // Nothing to do
- }
-
- @Override
- public int getConnectTimeout() {
- return timeout;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.ChannelHandler;
-
-import com.google.common.base.Preconditions;
-
-/**
- * @deprecated This is an adaptor class for turning ProtocolMessageFactory into
- * Netty encoder/decoder. Use Netty-provided classes directly, by subclassing
- * {@link io.netty.handler.codec.ByteToMessageDecoder} or similar instead.
- */
-@Deprecated
-public class ProtocolHandlerFactory<T> {
- private final ProtocolMessageEncoder<T> encoder;
- protected final ProtocolMessageFactory<T> msgFactory;
-
- public ProtocolHandlerFactory(final ProtocolMessageFactory<T> msgFactory) {
- this.msgFactory = Preconditions.checkNotNull(msgFactory);
- this.encoder = new ProtocolMessageEncoder<T>(msgFactory);
- }
-
- public ChannelHandler[] getEncoders() {
- return new ChannelHandler[] { this.encoder };
- }
-
- public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] { new ProtocolMessageDecoder<T>(this.msgFactory) };
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * @deprecated This is an adaptor class for turning ProtocolMessageFactory into Netty decoder. Use Netty-provided
- * classes directly, by subclassing {@link io.netty.handler.codec.ByteToMessageDecoder} or similar instead.
- */
-@Deprecated
-public final class ProtocolMessageDecoder<T> extends ByteToMessageDecoder {
-
- private static final Logger LOG = LoggerFactory.getLogger(ProtocolMessageDecoder.class);
-
- private final ProtocolMessageFactory<T> factory;
-
- public ProtocolMessageDecoder(final ProtocolMessageFactory<T> factory) {
- this.factory = Preconditions.checkNotNull(factory);
- }
-
- @Override
- protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws Exception {
- if (in.readableBytes() == 0) {
- LOG.debug("No more content in incoming buffer.");
- return;
- }
- in.markReaderIndex();
- try {
- LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
- final byte[] bytes = new byte[in.readableBytes()];
- in.readBytes(bytes);
- out.add(this.factory.parse(bytes));
- } catch (DeserializerException | DocumentedException e) {
- LOG.debug("Failed to decode protocol message", e);
- this.exceptionCaught(ctx, e);
- }
- in.discardReadBytes();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated This is an adaptor class for turning ProtocolMessageFactory into Netty encoder. Use Netty-provided
- * classes directly, by subclassing {@link io.netty.handler.codec.MessageToByteDecoder} or similar instead.
- */
-@Deprecated
-@Sharable
-public final class ProtocolMessageEncoder<T> extends MessageToByteEncoder<Object> {
-
- private static final Logger LOG = LoggerFactory.getLogger(ProtocolMessageEncoder.class);
-
- private final ProtocolMessageFactory<T> factory;
-
- public ProtocolMessageEncoder(final ProtocolMessageFactory<T> factory) {
- this.factory = factory;
- }
-
- @Override
- protected void encode(final ChannelHandlerContext ctx, final Object msg, final ByteBuf out) throws Exception {
- LOG.debug("Sent to encode : {}", msg);
- final byte[] bytes = this.factory.put((T) msg);
- out.writeBytes(bytes);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-
-/**
- * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol
- * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g.
- * OpenMessageParser etc.
- *
- * @param <T> type of messages created by this factory
- *
- * @deprecated Interact with Netty 4.0 directly, by subclassing {@link io.netty.handler.codec.ByteToMessageCodec} or
- * similar.
- */
-@Deprecated
-public interface ProtocolMessageFactory<T> {
-
- /**
- * Parses message from byte array. Requires specific protocol message header object to parse the header.
- *
- * @param bytes byte array from which the message will be parsed
- * @return List of specific protocol messages
- * @throws DeserializerException if some parsing error occurs
- * @throws DocumentedException if some documented error occurs
- */
- T parse(byte[] bytes) throws DeserializerException, DocumentedException;
-
- /**
- * Serializes protocol specific message to byte array.
- *
- * @param msg message to be serialized.
- * @return byte array resulting message
- */
- byte[] put(T msg);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import java.io.Closeable;
-
-/**
- * Protocol Session represents the finite state machine in underlying protocol, including timers and its purpose is to
- * create a connection between server and client. Session is automatically started, when TCP connection is created, but
- * can be stopped manually. If the session is up, it has to redirect messages to/from user. Handles also malformed
- * messages and unknown requests.
- *
- * This interface should be implemented by a final class representing a protocol specific session.
- */
-public interface ProtocolSession<T> extends Closeable {
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelOption;
-import io.netty.util.concurrent.DefaultPromise;
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.FutureListener;
-import io.netty.util.concurrent.Promise;
-
-import java.net.InetSocketAddress;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-@ThreadSafe
-final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends DefaultPromise<S> {
- private static final Logger LOG = LoggerFactory.getLogger(ProtocolSessionPromise.class);
- private final ReconnectStrategy strategy;
- private final InetSocketAddress address;
- private final Bootstrap b;
-
- @GuardedBy("this")
- private Future<?> pending;
-
- ProtocolSessionPromise(final EventExecutor executor, final InetSocketAddress address, final ReconnectStrategy strategy,
- final Bootstrap b) {
- super(executor);
- this.strategy = Preconditions.checkNotNull(strategy);
- this.address = Preconditions.checkNotNull(address);
- this.b = Preconditions.checkNotNull(b);
- }
-
- synchronized void connect() {
- final Object lock = this;
-
- try {
- final int timeout = this.strategy.getConnectTimeout();
-
- LOG.debug("Promise {} attempting connect for {}ms", lock, timeout);
-
- this.b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, timeout);
- this.pending = this.b.connect(this.address).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(final ChannelFuture cf) throws Exception {
- synchronized (lock) {
-
- LOG.debug("Promise {} connection resolved", lock);
-
- // Triggered when a connection attempt is resolved.
- Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(cf));
-
- /*
- * The promise we gave out could have been cancelled,
- * which cascades to the connect getting cancelled,
- * but there is a slight race window, where the connect
- * is already resolved, but the listener has not yet
- * been notified -- cancellation at that point won't
- * stop the notification arriving, so we have to close
- * the race here.
- */
- if (isCancelled()) {
- if (cf.isSuccess()) {
- LOG.debug("Closing channel for cancelled promise {}", lock);
- cf.channel().close();
- }
- return;
- }
-
- if (!cf.isSuccess()) {
- LOG.info("Attempt to connect to connect to {} failed", ProtocolSessionPromise.this.address, cf.cause());
- final Future<Void> rf = ProtocolSessionPromise.this.strategy.scheduleReconnect(cf.cause());
- rf.addListener(new FutureListener<Void>() {
- @Override
- public void operationComplete(final Future<Void> sf) {
- synchronized (lock) {
- // Triggered when a connection attempt is to be made.
- Preconditions.checkState(ProtocolSessionPromise.this.pending.equals(sf));
-
- /*
- * The promise we gave out could have been cancelled,
- * which cascades to the reconnect attempt getting
- * cancelled, but there is a slight race window, where
- * the reconnect attempt is already enqueued, but the
- * listener has not yet been notified -- if cancellation
- * happens at that point, we need to catch it here.
- */
- if (!isCancelled()) {
- if (sf.isSuccess()) {
- connect();
- } else {
- setFailure(sf.cause());
- }
- }
- }
- }
- });
-
- ProtocolSessionPromise.this.pending = rf;
- } else {
- LOG.debug("Promise {} connection successful", lock);
- }
- }
- }
- });
- } catch (final Exception e) {
- LOG.info("Failed to connect to {}", e);
- setFailure(e);
- }
- }
-
- @Override
- public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
- if (super.cancel(mayInterruptIfRunning)) {
- this.pending.cancel(mayInterruptIfRunning);
- return true;
- }
-
- return false;
- }
-
- @Override
- public synchronized Promise<S> setSuccess(final S result) {
- LOG.debug("Promise {} completed", this);
- this.strategy.reconnectSuccessful();
- return super.setSuccess(result);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Utility ReconnectStrategy singleton, which will cause the reconnect process
- * to immediately schedule a reconnection attempt.
- */
-@ThreadSafe
-public final class ReconnectImmediatelyStrategy implements ReconnectStrategy {
- private static final Logger LOG = LoggerFactory.getLogger(ReconnectImmediatelyStrategy.class);
- private final EventExecutor executor;
- private final int timeout;
-
- public ReconnectImmediatelyStrategy(final EventExecutor executor, final int timeout) {
- Preconditions.checkArgument(timeout >= 0);
- this.executor = Preconditions.checkNotNull(executor);
- this.timeout = timeout;
- }
-
- @Override
- public Future<Void> scheduleReconnect(final Throwable cause) {
- LOG.debug("Connection attempt failed", cause);
- return executor.newSucceededFuture(null);
- }
-
- @Override
- public void reconnectSuccessful() {
- // Nothing to do
- }
-
- @Override
- public int getConnectTimeout() {
- return timeout;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.util.concurrent.DefaultPromise;
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.FutureListener;
-import io.netty.util.concurrent.Promise;
-
-import java.io.Closeable;
-import java.net.InetSocketAddress;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.opendaylight.protocol.framework.AbstractDispatcher.PipelineInitializer;
-
-import com.google.common.base.Preconditions;
-
-final class ReconnectPromise<S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> extends DefaultPromise<Void> {
- private final AbstractDispatcher<S, L> dispatcher;
- private final InetSocketAddress address;
- private final ReconnectStrategyFactory strategyFactory;
- private final ReconnectStrategy strategy;
- private final PipelineInitializer<S> initializer;
- private Future<?> pending;
-
- private final AtomicBoolean negotiationFinished = new AtomicBoolean(false);
-
- public ReconnectPromise(final EventExecutor executor, final AbstractDispatcher<S, L> dispatcher, final InetSocketAddress address,
- final ReconnectStrategyFactory connectStrategyFactory, final ReconnectStrategy reestablishStrategy,
- final PipelineInitializer<S> initializer) {
- super(executor);
- this.dispatcher = Preconditions.checkNotNull(dispatcher);
- this.address = Preconditions.checkNotNull(address);
- this.strategyFactory = Preconditions.checkNotNull(connectStrategyFactory);
- this.strategy = Preconditions.checkNotNull(reestablishStrategy);
- this.initializer = Preconditions.checkNotNull(initializer);
- }
-
- // FIXME: BUG-190: refactor
-
- synchronized void connect() {
- negotiationFinished.set(false);
-
- final ReconnectStrategy cs = this.strategyFactory.createReconnectStrategy();
- final ReconnectStrategy rs = new ReconnectStrategy() {
- @Override
- public Future<Void> scheduleReconnect(final Throwable cause) {
- return cs.scheduleReconnect(cause);
- }
-
- @Override
- public void reconnectSuccessful() {
- cs.reconnectSuccessful();
- }
-
- @Override
- public int getConnectTimeout() throws Exception {
- final int cst = cs.getConnectTimeout();
- final int rst = ReconnectPromise.this.strategy.getConnectTimeout();
-
- if (cst == 0) {
- return rst;
- }
- if (rst == 0) {
- return cst;
- }
- return Math.min(cst, rst);
- }
- };
-
- final Future<S> cf = this.dispatcher.createClient(this.address, rs, new PipelineInitializer<S>() {
- @Override
- public void initializeChannel(final SocketChannel channel, final Promise<S> promise) {
- addChannelClosedListener(channel.closeFuture());
- initializer.initializeChannel(channel, promise);
- }
- });
-
- final Object lock = this;
- this.pending = cf;
-
- cf.addListener(new FutureListener<S>() {
-
- @Override
- public void operationComplete(final Future<S> future) {
- synchronized (lock) {
- if (!future.isSuccess()) {
- final Future<Void> rf = ReconnectPromise.this.strategy.scheduleReconnect(cf.cause());
-
- if(rf == null) {
- // This should reflect: no more reconnecting strategies, enough
- // Currently all reconnect strategies fail with exception, should return null
- return;
- }
-
- ReconnectPromise.this.pending = rf;
-
- rf.addListener(new FutureListener<Void>() {
- @Override
- public void operationComplete(final Future<Void> sf) {
- synchronized (lock) {
- /*
- * The promise we gave out could have been cancelled,
- * which cascades to the reconnect attempt getting
- * cancelled, but there is a slight race window, where
- * the reconnect attempt is already enqueued, but the
- * listener has not yet been notified -- if cancellation
- * happens at that point, we need to catch it here.
- */
- if (!isCancelled()) {
- if (sf.isSuccess()) {
- connect();
- } else {
- setFailure(sf.cause());
- }
- }
- }
- }
- });
- } else {
- /*
- * FIXME: BUG-190: we have a slight race window with cancellation
- * here. Analyze and define its semantics.
- */
- ReconnectPromise.this.strategy.reconnectSuccessful();
- negotiationFinished.set(true);
- }
- }
- }
- });
- }
-
- private final ClosedChannelListener closedChannelListener = new ClosedChannelListener();
-
- class ClosedChannelListener implements Closeable, FutureListener<Void> {
-
- private final AtomicBoolean stop = new AtomicBoolean(false);
-
- @Override
- public void operationComplete(final Future<Void> future) throws Exception {
- if (stop.get()) {
- return;
- }
-
- // Start reconnecting crashed session after negotiation was successful
- if (!negotiationFinished.get()) {
- return;
- }
-
- connect();
- }
-
- @Override
- public void close() {
- this.stop.set(true);
- }
- }
-
- private void addChannelClosedListener(final ChannelFuture channelFuture) {
- channelFuture.addListener(closedChannelListener);
- }
-
- @Override
- public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
- closedChannelListener.close();
-
- if (super.cancel(mayInterruptIfRunning)) {
- this.pending.cancel(mayInterruptIfRunning);
- return true;
- }
-
- return false;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.util.concurrent.Future;
-
-/**
- * Interface exposed by a reconnection strategy provider. A reconnection
- * strategy decides whether to attempt reconnection and when to do that.
- *
- * The proper way of using this API is such that when a connection attempt
- * has failed, the user will call scheduleReconnect() to obtain a future,
- * which tracks schedule of the next connect attempt. The user should add its
- * own listener to be get notified when the future is done. Once the
- * the notification fires, user should examine the future to see whether
- * it is successful or not. If it is successful, the user should immediately
- * initiate a connection attempt. If it is unsuccessful, the user must
- * not attempt any more connection attempts and should abort the reconnection
- * process.
- */
-public interface ReconnectStrategy {
- /**
- * Query the strategy for the connect timeout.
- *
- * @return connect try timeout in milliseconds, or
- * 0 for infinite (or system-default) timeout
- * @throws Exception if the connection should not be attempted
- */
- int getConnectTimeout() throws Exception;
-
- /**
- * Schedule a connection attempt. The precise time when the connection
- * should be attempted is signaled by successful completion of returned
- * future.
- *
- * @param cause Cause of previous failure
- * @return a future tracking the schedule, may not be null
- * @throws IllegalStateException when a connection attempt is currently
- * scheduled.
- */
- Future<Void> scheduleReconnect(Throwable cause);
-
- /**
- * Reset the strategy state. Users call this method once the reconnection
- * process succeeds.
- */
- void reconnectSuccessful();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-/**
- * Factory interface for creating new ReconnectStrategy instances. This is
- * primarily useful for allowing injection of a specific type of strategy for
- * on-demand use, pretty much like you would use a ThreadFactory.
- */
-public interface ReconnectStrategyFactory {
- /**
- * Create a new ReconnectStrategy.
- *
- * @return a new reconnecty strategy
- */
- ReconnectStrategy createReconnectStrategy();
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import java.util.EventListener;
-
-/**
- * Listener that receives session state informations. This interface should be
- * implemented by a protocol specific abstract class, that is extended by
- * a final class that implements the methods.
- */
-public interface SessionListener<M, S extends ProtocolSession<?>, T extends TerminationReason> extends EventListener {
- /**
- * Fired when the session was established successfully.
- *
- * @param remoteParams Peer address families which we accepted
- */
- void onSessionUp(S session);
-
- /**
- * Fired when the session went down because of an IO error. Implementation should take care of closing underlying
- * session.
- *
- * @param session that went down
- * @param e Exception that was thrown as the cause of session being down
- */
- void onSessionDown(S session, Exception e);
-
- /**
- * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
- * Any outstanding queued messages were not sent. The user should not attempt to make any use of the session.
- *
- * @param reason the cause why the session went down
- */
- void onSessionTerminated(S session, T reason);
-
- /**
- * Fired when a normal protocol message is received.
- *
- * @param message Protocol message
- */
- void onMessage(S session, M message);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-
-/**
- * Factory for generating Session Listeners. Used by a server. This interface should be
- * implemented by a protocol specific abstract class, that is extended by
- * a final class that implements the methods.
- */
-public interface SessionListenerFactory<T extends SessionListener<?, ?, ?>> {
- /**
- * Returns one session listener
- * @return specific session listener
- */
- T getSessionListener();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.ChannelInboundHandler;
-
-/**
- * Session negotiator concepts. A negotiator is responsible for message
- * handling while the exact session parameters are not known. Once the
- * session parameters are finalized, the negotiator replaces itself in
- * the channel pipeline with the session.
- *
- * @param <T> Protocol session type.
- */
-public interface SessionNegotiator<T extends ProtocolSession<?>> extends ChannelInboundHandler {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.Channel;
-import io.netty.util.concurrent.Promise;
-
-/**
- * A factory class creating SessionNegotiators.
- *
- * @param <S> session type
- */
-public interface SessionNegotiatorFactory<M, S extends ProtocolSession<?>, L extends SessionListener<?, ?, ?>> {
- /**
- * Create a new negotiator attached to a channel, which will notify
- * a promise once the negotiation completes.
- *
- * @param channel Underlying channel
- * @param promise Promise to be notified
- * @return new negotiator instance
- */
- SessionNegotiator<S> getSessionNegotiator(SessionListenerFactory<L> factory, Channel channel, Promise<S> promise);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-/**
- * Marker interface for grouping session termination cause.
- */
-public interface TerminationReason {
-
- /**
- * Get cause of session termination.
- * @return human-readable cause.
- */
- String getErrorMessage();
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Swiss army knife equivalent for reconnect strategies.
- *
- * This strategy continues to schedule reconnect attempts, each having to complete in a fixed time (connectTime).
- *
- * Initial sleep time is specified as minSleep. Each subsequent unsuccessful attempt multiplies this time by a constant
- * factor (sleepFactor) -- this allows for either constant reconnect times (sleepFactor = 1), or various degrees of
- * exponential back-off (sleepFactor > 1). Maximum sleep time between attempts can be capped to a specific value
- * (maxSleep).
- *
- * The strategy can optionally give up based on two criteria:
- *
- * A preset number of connection retries (maxAttempts) has been reached, or
- *
- * A preset absolute deadline is reached (deadline nanoseconds, as reported by System.nanoTime(). In this specific case,
- * both connectTime and maxSleep will be controlled such that the connection attempt is resolved as closely to the
- * deadline as possible.
- *
- * Both these caps can be combined, with the strategy giving up as soon as the first one is reached.
- */
-@ThreadSafe
-public final class TimedReconnectStrategy implements ReconnectStrategy {
- private static final Logger LOG = LoggerFactory.getLogger(TimedReconnectStrategy.class);
- private final EventExecutor executor;
- private final Long deadline, maxAttempts, maxSleep;
- private final double sleepFactor;
- private final int connectTime;
- private final long minSleep;
-
- @GuardedBy("this")
- private long attempts;
-
- @GuardedBy("this")
- private long lastSleep;
-
- @GuardedBy("this")
- private boolean scheduled;
-
- public TimedReconnectStrategy(final EventExecutor executor, final int connectTime, final long minSleep, final double sleepFactor,
- final Long maxSleep, final Long maxAttempts, final Long deadline) {
- Preconditions.checkArgument(maxSleep == null || minSleep <= maxSleep);
- Preconditions.checkArgument(sleepFactor >= 1);
- Preconditions.checkArgument(connectTime >= 0);
- this.executor = Preconditions.checkNotNull(executor);
- this.deadline = deadline;
- this.maxAttempts = maxAttempts;
- this.minSleep = minSleep;
- this.maxSleep = maxSleep;
- this.sleepFactor = sleepFactor;
- this.connectTime = connectTime;
- }
-
- @Override
- public synchronized Future<Void> scheduleReconnect(final Throwable cause) {
- LOG.debug("Connection attempt failed", cause);
-
- // Check if a reconnect attempt is scheduled
- Preconditions.checkState(!this.scheduled);
-
- // Get a stable 'now' time for deadline calculations
- final long now = System.nanoTime();
-
- // Obvious stop conditions
- if (this.maxAttempts != null && this.attempts >= this.maxAttempts) {
- return this.executor.newFailedFuture(new Throwable("Maximum reconnection attempts reached"));
- }
- if (this.deadline != null && this.deadline <= now) {
- return this.executor.newFailedFuture(new TimeoutException("Reconnect deadline reached"));
- }
-
- /*
- * First connection attempt gets initialized to minimum sleep,
- * each subsequent is exponentially backed off by sleepFactor.
- */
- if (this.attempts != 0) {
- this.lastSleep *= this.sleepFactor;
- } else {
- this.lastSleep = this.minSleep;
- }
-
- // Cap the sleep time to maxSleep
- if (this.maxSleep != null && this.lastSleep > this.maxSleep) {
- LOG.debug("Capped sleep time from {} to {}", this.lastSleep, this.maxSleep);
- this.lastSleep = this.maxSleep;
- }
-
- this.attempts++;
-
- // Check if the reconnect attempt is within the deadline
- if (this.deadline != null && this.deadline <= now + TimeUnit.MILLISECONDS.toNanos(this.lastSleep)) {
- return this.executor.newFailedFuture(new TimeoutException("Next reconnect would happen after deadline"));
- }
-
- LOG.debug("Connection attempt {} sleeping for {} milliseconds", this.attempts, this.lastSleep);
-
- // If we are not sleeping at all, return an already-succeeded future
- if (this.lastSleep == 0) {
- return this.executor.newSucceededFuture(null);
- }
-
- // Need to retain a final reference to this for locking purposes,
- // also set the scheduled flag.
- final Object lock = this;
- this.scheduled = true;
-
- // Schedule a task for the right time. It will also clear the flag.
- return this.executor.schedule(new Callable<Void>() {
- @Override
- public Void call() throws TimeoutException {
- synchronized (lock) {
- Preconditions.checkState(TimedReconnectStrategy.this.scheduled);
- TimedReconnectStrategy.this.scheduled = false;
- }
-
- return null;
- }
- }, this.lastSleep, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public synchronized void reconnectSuccessful() {
- Preconditions.checkState(!this.scheduled);
- this.attempts = 0;
- }
-
- @Override
- public int getConnectTimeout() throws TimeoutException {
- int timeout = this.connectTime;
-
- if (this.deadline != null) {
-
- // If there is a deadline, we may need to cap the connect
- // timeout to meet the deadline.
- final long now = System.nanoTime();
- if (now >= this.deadline) {
- throw new TimeoutException("Reconnect deadline already passed");
- }
-
- final long left = TimeUnit.NANOSECONDS.toMillis(this.deadline - now);
- if (left < 1) {
- throw new TimeoutException("Connect timeout too close to deadline");
- }
-
- /*
- * A bit of magic:
- * - if time left is less than the timeout, set it directly
- * - if there is no timeout, and time left is:
- * - less than maximum integer, set timeout to time left
- * - more than maximum integer, set timeout Integer.MAX_VALUE
- */
- if (timeout > left) {
- timeout = (int) left;
- } else if (timeout == 0) {
- timeout = left <= Integer.MAX_VALUE ? (int) left : Integer.MAX_VALUE;
- }
- }
- return timeout;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-@Deprecated
-public class ComplementaryTest {
-
- @Test
- public void testExceptions() {
- final DeserializerException de = new DeserializerException("some error");
- final DocumentedException ee = new DocumentedException("some error");
-
- assertEquals(de.getMessage(), ee.getMessage());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.util.concurrent.DefaultPromise;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.Promise;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServerTest {
- SimpleDispatcher clientDispatcher, dispatcher;
-
- final SimpleSessionListener pce = new SimpleSessionListener();
-
- SimpleSession session = null;
-
- ChannelFuture server = null;
-
- InetSocketAddress serverAddress;
- private NioEventLoopGroup eventLoopGroup;
-
-
- @Before
- public void setUp() {
- final int port = 10000 + (int)(10000 * Math.random());
- serverAddress = new InetSocketAddress("127.0.0.1", port);
- eventLoopGroup = new NioEventLoopGroup();
- }
-
- @Test
- public void testConnectionEstablished() throws Exception {
- final Promise<Boolean> p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
-
- this.dispatcher = new SimpleDispatcher(new SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener>() {
-
- @Override
- public SessionNegotiator<SimpleSession> getSessionNegotiator(final SessionListenerFactory<SimpleSessionListener> factory,
- final Channel channel, final Promise<SimpleSession> promise) {
- p.setSuccess(true);
- return new SimpleSessionNegotiator(promise, channel);
- }
- }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
-
- this.server = this.dispatcher.createServer(this.serverAddress, new SessionListenerFactory<SimpleSessionListener>() {
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- });
-
- this.server.get();
-
- this.clientDispatcher = new SimpleDispatcher(new SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener>() {
- @Override
- public SessionNegotiator<SimpleSession> getSessionNegotiator(final SessionListenerFactory<SimpleSessionListener> factory,
- final Channel channel, final Promise<SimpleSession> promise) {
- return new SimpleSessionNegotiator(promise, channel);
- }
- }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
-
- this.session = this.clientDispatcher.createClient(this.serverAddress,
- new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), new SessionListenerFactory<SimpleSessionListener>() {
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- }).get(6, TimeUnit.SECONDS);
-
- assertEquals(true, p.get(3, TimeUnit.SECONDS));
- }
-
- @Test
- public void testConnectionFailed() throws IOException, InterruptedException, ExecutionException, TimeoutException {
- final Promise<Boolean> p = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
-
- this.dispatcher = new SimpleDispatcher(new SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener>() {
-
- @Override
- public SessionNegotiator<SimpleSession> getSessionNegotiator(final SessionListenerFactory<SimpleSessionListener> factory,
- final Channel channel, final Promise<SimpleSession> promise) {
- p.setSuccess(true);
- return new SimpleSessionNegotiator(promise, channel);
- }
- }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
-
- this.server = this.dispatcher.createServer(this.serverAddress, new SessionListenerFactory<SimpleSessionListener>() {
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- });
-
- this.server.get();
-
- this.clientDispatcher = new SimpleDispatcher(new SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener>() {
- @Override
- public SessionNegotiator<SimpleSession> getSessionNegotiator(final SessionListenerFactory<SimpleSessionListener> factory,
- final Channel channel, final Promise<SimpleSession> promise) {
- return new SimpleSessionNegotiator(promise, channel);
- }
- }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
-
- this.session = this.clientDispatcher.createClient(this.serverAddress,
- new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), new SessionListenerFactory<SimpleSessionListener>() {
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- }).get(6, TimeUnit.SECONDS);
-
- final Future<?> session = this.clientDispatcher.createClient(this.serverAddress,
- new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000), new SessionListenerFactory<SimpleSessionListener>() {
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- });
- assertFalse(session.isSuccess());
- }
-
- @After
- public void tearDown() throws IOException, InterruptedException {
- this.server.channel().close();
- this.eventLoopGroup.shutdownGracefully();
- try {
- Thread.sleep(500);
- } catch (final InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-
-public class Session extends AbstractProtocolSession<SimpleMessage> {
-
- private static final Logger logger = LoggerFactory.getLogger(Session.class);
-
- public final List<SimpleMessage> msgs = Lists.newArrayList();
-
- public boolean up = false;
-
- @Override
- public void close() {
-
- }
-
- @Override
- public void handleMessage(final SimpleMessage msg) {
- logger.debug("Message received: {}", msg.getMessage());
- this.up = true;
- this.msgs.add(msg);
- logger.debug(this.msgs.size() + "");
- }
-
- @Override
- public void endOfInput() {
- logger.debug("End of input reported.");
- }
-
- @Override
- protected void sessionUp() {
- logger.debug("Session up reported.");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
-import java.util.List;
-
-import com.google.common.base.Charsets;
-
-/**
- *
- */
-public class SimpleByteToMessageDecoder extends ByteToMessageDecoder {
- @Override
- protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) {
- out.add(new SimpleMessage(Charsets.UTF_8.decode(in.nioBuffer()).toString()));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelOutboundHandler;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.Promise;
-
-import java.net.InetSocketAddress;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-public class SimpleDispatcher extends AbstractDispatcher<SimpleSession, SimpleSessionListener> {
- private static final Logger logger = LoggerFactory.getLogger(SimpleDispatcher.class);
-
- private final SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener> negotiatorFactory;
- private final ChannelOutboundHandler encoder = new SimpleMessageToByteEncoder();
-
- private final class SimplePipelineInitializer implements PipelineInitializer<SimpleSession> {
- final SessionListenerFactory<SimpleSessionListener> listenerFactory;
-
- SimplePipelineInitializer(final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
- this.listenerFactory = Preconditions.checkNotNull(listenerFactory);
- }
-
- @Override
- public void initializeChannel(final SocketChannel channel, final Promise<SimpleSession> promise) {
- channel.pipeline().addLast(new SimpleByteToMessageDecoder());
- channel.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise));
- channel.pipeline().addLast(encoder);
- logger.debug("initialization completed for channel {}", channel);
- }
-
- }
-
- public SimpleDispatcher(final SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener> negotiatorFactory,
- final Promise<SimpleSession> promise, final EventLoopGroup eventLoopGroup) {
- super(eventLoopGroup, eventLoopGroup);
- this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory);
- }
-
- public Future<SimpleSession> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
- return super.createClient(address, strategy, new SimplePipelineInitializer(listenerFactory));
- }
-
- public ChannelFuture createServer(final InetSocketAddress address, final SessionListenerFactory<SimpleSessionListener> listenerFactory) {
- return super.createServer(address, new SimplePipelineInitializer(listenerFactory));
- }
-
- @Override
- public void close() {
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-public class SimpleMessage {
-
- private final String s;
-
- public SimpleMessage(final String s) {
- this.s = s;
- }
-
- public String getMessage() {
- return this.s;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-
-/**
- *
- */
-@Sharable
-public class SimpleMessageToByteEncoder extends MessageToByteEncoder<SimpleMessage> {
- @Override
- protected void encode(final ChannelHandlerContext ctx, final SimpleMessage msg, final ByteBuf out) {
- out.writeBytes(msg.getMessage().getBytes());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-public final class SimpleSession extends AbstractProtocolSession<SimpleMessage> {
-
- public SimpleSession() {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public void handleMessage(final SimpleMessage msg) {
- }
-
- @Override
- public void endOfInput() {
- }
-
- @Override
- protected void sessionUp() {
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Simple Session Listener that is notified about messages and changes in the session.
- */
-public class SimpleSessionListener implements SessionListener<SimpleMessage, SimpleSession, TerminationReason> {
- private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
-
- public List<SimpleMessage> messages = new ArrayList<SimpleMessage>();
-
- public boolean up = false;
-
- public boolean failed = false;
-
- @Override
- public void onMessage(final SimpleSession session, final SimpleMessage message) {
- logger.debug("Received message: " + message.getClass() + " " + message);
- this.messages.add(message);
- }
-
- @Override
- public void onSessionUp(final SimpleSession session) {
- this.up = true;
- }
-
- @Override
- public void onSessionDown(final SimpleSession session, final Exception e) {
- this.failed = true;
- this.notifyAll();
- }
-
- @Override
- public void onSessionTerminated(final SimpleSession session, final TerminationReason reason) {
- this.failed = true;
- this.notifyAll();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-public class SimpleSessionListenerFactory implements SessionListenerFactory<SimpleSessionListener> {
-
- @Override
- public SimpleSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
-
-import io.netty.channel.Channel;
-import io.netty.util.concurrent.Promise;
-
-public class SimpleSessionNegotiator extends AbstractSessionNegotiator<SimpleMessage, SimpleSession> {
-
- public SimpleSessionNegotiator(Promise<SimpleSession> promise, Channel channel) {
- super(promise, channel);
- }
-
- @Override
- protected void startNegotiation() throws Exception {
- negotiationSuccessful(new SimpleSession());
- }
-
- @Override
- protected void handleMessage(SimpleMessage msg) throws Exception {
- throw new IllegalStateException("This method should never be invoked");
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root level="TRACE">
- <appender-ref ref="STDOUT" />
- </root>
-</configuration>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-broker-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
ret.add(mavenBundle("org.javassist", "javassist", "3.17.1-GA"));
ret.add(mavenBundle("org.opendaylight.controller", "config-api", "0.2.3-SNAPSHOT"));
+ ret.add(mavenBundle("org.opendaylight.controller", "protocol-framework", "0.4.0-SNAPSHOT"));
ret.add(mavenBundle("org.opendaylight.controller", "sal-common-api", "1.0-SNAPSHOT"));
ret.add(mavenBundle("org.opendaylight.controller", "sal-binding-api", "1.0-SNAPSHOT"));
ret.add(mavenBundle("org.opendaylight.controller", "sal-binding-broker-impl", "1.0-SNAPSHOT"));
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("bgp-concepts", "bgp-parser-api",
"bgp-parser-spi", "bgp-rib-api", "bgp-rib-spi",
- "concepts", "framework", "rsvp-api", "util");
+ "concepts", "rsvp-api", "util");
}
@Override
public final class BgpParserApiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("bgp-concepts", "bgp-util", "concepts", "framework", "util");
+ return Lists.newArrayList("bgp-concepts", "bgp-util", "concepts", "util");
}
@Override
public final class BgpParserImplBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("bgp-concepts", "bgp-linkstate", "bgp-parser-api", "bgp-parser-spi", "bgp-util", "concepts", "framework", "rsvp-api", "util");
+ return Lists.newArrayList("bgp-concepts", "bgp-linkstate", "bgp-parser-api",
+ "bgp-parser-spi", "bgp-util", "concepts", "rsvp-api", "util");
}
@Override
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "bgp-concepts", "bgp-parser-api",
- "bgp-parser-spi", "bgp-parser-impl", "framework", "util");
+ "bgp-parser-spi", "bgp-parser-impl", "util");
}
@Override
public final class BgpParserSpiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-util", "concepts", "framework", "util");
+ return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-util", "concepts", "util");
}
@Override
public final class BgpRibApiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api", "framework", "util");
+ return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api", "util");
}
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api",
"bgp-parser-impl", "bgp-parser-spi", "bgp-rib-api", "bgp-rib-spi",
- "bgp-util", "framework", "rsvp-api", "util");
+ "bgp-util", "rsvp-api", "util");
}
@Override
protected Collection<String> prerequisiteBundles() {
return Lists.newArrayList("concepts", "bgp-concepts", "bgp-linkstate", "bgp-parser-api",
"bgp-parser-impl", "bgp-parser-spi", "bgp-rib-api", "bgp-rib-impl",
- "bgp-rib-spi", "bgp-util", "framework", "rsvp-api", "util");
+ "bgp-rib-spi", "bgp-util", "rsvp-api", "util");
}
@Override
public final class BgpRibSpiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-rib-api", "concepts", "framework", "util");
+ return Lists.newArrayList("bgp-concepts", "bgp-parser-api", "bgp-rib-api", "concepts", "util");
}
@Override
public final class BgpUtilBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "bgp-concepts", "bgp-parser-api", "framework", "util");
+ return Lists.newArrayList("concepts", "bgp-concepts", "bgp-parser-api", "util");
}
@Override
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.integration;
-
-import java.util.Collection;
-
-import com.google.common.collect.Lists;
-
-public final class FrameworkBundleTest extends AbstractBundleTest {
- @Override
- protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "util");
- }
-
- @Override
- protected Collection<String> requiredBundles() {
- return Lists.newArrayList("framework");
- }
-}
public final class PcepApiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "framework", "rsvp-api", "util");
+ return Lists.newArrayList("concepts", "rsvp-api", "util");
}
@Override
public final class PcepImplBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "framework", "pcep-api", "pcep-spi", "rsvp-api", "util");
+ return Lists.newArrayList("concepts", "pcep-api", "pcep-spi", "rsvp-api", "util");
}
@Override
public final class PcepSpiBundleTest extends AbstractBundleTest {
@Override
protected Collection<String> prerequisiteBundles() {
- return Lists.newArrayList("concepts", "framework", "pcep-api", "rsvp-api", "util");
+ return Lists.newArrayList("concepts", "pcep-api", "rsvp-api", "util");
}
@Override
<groupId>${project.groupId}</groupId>
<artifactId>concepts</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
<artifactId>yang-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
+ </dependency>
+
<!--
FIXME: these are IETF models which are pre-generated in SAL infra.
This should not be here, but rather should somehow be
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <artifactId>util</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>util</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<artifactId>mockito-configuration</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
- <version>${project.version}</version>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<groupId>${project.groupId}</groupId>
<artifactId>concepts</artifactId>
</dependency>
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>framework</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
<modules>
<!-- Common infra -->
<module>concepts</module>
- <module>framework</module>
<module>util</module>
<!-- Subsystems -->