import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.Epoll;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.ThreadFactory;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.lispflowmapping.dsbackend.DataStoreBackEnd;
import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.southbound.lisp.LispXtrSouthboundHandler;
import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
private volatile boolean isMaster = false;
private volatile String bindingAddress;
private AuthKeyDb akdb;
- private MapRegisterCache mapRegisterCache = new MapRegisterCache();
+ private final MapRegisterCache mapRegisterCache = new MapRegisterCache();
private boolean mapRegisterCacheEnabled;
private long mapRegisterCacheTimeout;
private final ClusterSingletonServiceProvider clusterSingletonService;
private LispSouthboundHandler lispSouthboundHandler;
private LispXtrSouthboundHandler lispXtrSouthboundHandler;
- private NotificationPublishService notificationPublishService;
+ private final NotificationPublishService notificationPublishService;
private int numChannels = 1;
- private Channel[] channel;
+ private final Channel[] channel;
private Channel xtrChannel;
private Class channelType;
private volatile int xtrPort = LispMessage.XTR_PORT_NUM;
private volatile boolean listenOnXtrPort = false;
- private ConcurrentLispSouthboundStats statistics = new ConcurrentLispSouthboundStats();
- private Bootstrap bootstrap = new Bootstrap();
- private Bootstrap xtrBootstrap = new Bootstrap();
- private ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
+ private final ConcurrentLispSouthboundStats statistics = new ConcurrentLispSouthboundStats();
+ private final Bootstrap bootstrap = new Bootstrap();
+ private final Bootstrap xtrBootstrap = new Bootstrap();
+ private final ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
private EventLoopGroup eventLoopGroup;
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private AuthenticationKeyDataListener authenticationKeyDataListener;
private DataStoreBackEnd dsbe;
this.dsbe = new DataStoreBackEnd(dataBroker);
restoreDaoFromDatastore();
- LispSouthboundHandler lispSouthboundHandler = new LispSouthboundHandler(this);
- this.lispSouthboundHandler = lispSouthboundHandler;
+ LispSouthboundHandler lsbh = new LispSouthboundHandler(this);
+ this.lispSouthboundHandler = lsbh;
- LispXtrSouthboundHandler lispXtrSouthboundHandler = new LispXtrSouthboundHandler(this);
- this.lispXtrSouthboundHandler = lispXtrSouthboundHandler;
+ LispXtrSouthboundHandler lxsbh = new LispXtrSouthboundHandler(this);
+ this.lispXtrSouthboundHandler = lxsbh;
if (Epoll.isAvailable()) {
eventLoopGroup = new EpollEventLoopGroup(numChannels, threadFactory);
bootstrap.group(eventLoopGroup);
bootstrap.channel(channelType);
- bootstrap.handler(lispSouthboundHandler);
+ bootstrap.handler(lsbh);
xtrBootstrap.group(eventLoopGroup);
xtrBootstrap.channel(channelType);
- xtrBootstrap.handler(lispXtrSouthboundHandler);
+ xtrBootstrap.handler(lxsbh);
start();
startXtr();
public void handleSerializedLispBuffer(TransportAddress address, ByteBuffer outBuffer,
final MessageType packetType) {
InetAddress ip = getInetAddress(address);
- handleSerializedLispBuffer(ip, outBuffer, packetType, address.getPort().getValue(), null);
+ handleSerializedLispBuffer(ip, outBuffer, packetType, address.getPort().getValue().toJava(), null);
}
public void handleSerializedLispBuffer(InetAddress address, ByteBuffer outBuffer,
if (LOG.isTraceEnabled()) {
LOG.trace("Buffer:\n{}", ByteBufUtil.prettyHexDump(data));
}
- senderChannel.write(packet).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) {
- if (future.isSuccess()) {
- LOG.trace("Success");
- statistics.incrementTx(packetType.getIntValue());
- } else {
- LOG.warn("Failed to send packet");
- statistics.incrementTxErrors();
- }
+ senderChannel.write(packet).addListener(future -> {
+ if (future.isSuccess()) {
+ LOG.trace("Success");
+ statistics.incrementTx(packetType.getIntValue());
+ } else {
+ LOG.warn("Failed to send packet");
+ statistics.incrementTxErrors();
}
});
senderChannel.flush();