StringEncoder is stateless and therefore can be shared across multiple
channel pipelines. Create a single instance for use by all connections.
Change-Id: I660cb90ac3de0476f5637d6a53a8c49826c71f1d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
-import io.netty.util.CharsetUtil;
import java.net.InetAddress;
import java.net.InetAddress;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
private static final String USE_SSL = "use-ssl";
private static final int RETRY_PERIOD = 100; // retry after 100 milliseconds
private static final String USE_SSL = "use-ssl";
private static final int RETRY_PERIOD = 100; // retry after 100 milliseconds
+ private static final StringEncoder UTF8_ENCODER = new StringEncoder(StandardCharsets.UTF_8);
+
private static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newScheduledThreadPool(10,
new ThreadFactoryBuilder().setNameFormat("OVSDBPassiveConnServ-%d").build());
private static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newScheduledThreadPool(10,
new ThreadFactoryBuilder().setNameFormat("OVSDBPassiveConnServ-%d").build());
channel.pipeline().addLast(
//new LoggingHandler(LogLevel.INFO),
new JsonRpcDecoder(jsonRpcDecoderMaxFrameLength),
channel.pipeline().addLast(
//new LoggingHandler(LogLevel.INFO),
new JsonRpcDecoder(jsonRpcDecoderMaxFrameLength),
- new StringEncoder(CharsetUtil.UTF_8),
new IdleStateHandler(IDLE_READER_TIMEOUT, 0, 0),
new ReadTimeoutHandler(READ_TIMEOUT),
new ExceptionHandler(OvsdbConnectionService.this));
new IdleStateHandler(IDLE_READER_TIMEOUT, 0, 0),
new ReadTimeoutHandler(READ_TIMEOUT),
new ExceptionHandler(OvsdbConnectionService.this));
channel.pipeline().addLast(
new JsonRpcDecoder(jsonRpcDecoderMaxFrameLength),
channel.pipeline().addLast(
new JsonRpcDecoder(jsonRpcDecoderMaxFrameLength),
- new StringEncoder(CharsetUtil.UTF_8),
new IdleStateHandler(IDLE_READER_TIMEOUT, 0, 0),
new ReadTimeoutHandler(READ_TIMEOUT),
new ExceptionHandler(OvsdbConnectionService.this));
new IdleStateHandler(IDLE_READER_TIMEOUT, 0, 0),
new ReadTimeoutHandler(READ_TIMEOUT),
new ExceptionHandler(OvsdbConnectionService.this));