X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2FNetconfEOMAggregator.java;fp=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2FNetconfEOMAggregator.java;h=0000000000000000000000000000000000000000;hp=8b1bb3601ddd3df4b2b033d4d3f697acab76d210;hb=c3108b4e80ec9f6ee6c8cf96df3009bb91dc8bc0;hpb=04a788d2df5303c60cdbcff02254291f411566bd diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfEOMAggregator.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfEOMAggregator.java deleted file mode 100644 index 8b1bb3601d..0000000000 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfEOMAggregator.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.controller.netconf.util.handler; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; - -import java.util.List; - -import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Charsets; - -public class NetconfEOMAggregator extends ByteToMessageDecoder { - private final static Logger logger = LoggerFactory.getLogger(NetconfEOMAggregator.class); - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { - int index = indexOfSequence(in, NetconfMessageConstants.END_OF_MESSAGE); - if (index == -1) { - logger.debug("Message is not complete, read again."); - if (logger.isTraceEnabled()) { - String str = in.toString(Charsets.UTF_8); - logger.trace("Message read so far: {}", str); - } - ctx.read(); - } else { - ByteBuf msg = in.readBytes(index); - in.readBytes(NetconfMessageConstants.END_OF_MESSAGE.length); - in.discardReadBytes(); - logger.debug("Message is complete."); - out.add(msg); - } - } - - private int indexOfSequence(ByteBuf in, byte[] sequence) { - int index = -1; - for (int i = 0; i < in.readableBytes() - sequence.length + 1; i++) { - if (in.getByte(i) == sequence[0]) { - index = i; - for (int j = 1; j < sequence.length; j++) { - if (in.getByte(i + j) != sequence[j]) { - index = -1; - break; - } - } - if (index != -1) { - return index; - } - } - } - return index; - } - -}