Netty Replicator - improve the reconnection and keepalive mechanisms
[mdsal.git] / replicate / mdsal-replicate-netty / src / main / java / org / opendaylight / mdsal / replicate / netty / Constants.java
index eddf8d6dbaa341d3c21e4f1b672780ebc22e7df0..8041640ebce19d8ab7c136a11c21c208455a5b3d 100644 (file)
@@ -32,6 +32,14 @@ final class Constants {
      * End-of-DataTreeCandidate serialization stream. The payload is empty.
      */
     static final byte MSG_DTC_APPLY     = 4;
+    /**
+     * Verify the connection is alive.
+     */
+    static final int MSG_PING           = 5;
+    /**
+     * Verify the connection is alive.
+     */
+    static final int MSG_PONG           = 6;
 
     /**
      * Length of the length field in each transmitted frame.
@@ -42,8 +50,16 @@ final class Constants {
      */
     static final int LENGTH_FIELD_MAX    = 1024 * 1024;
 
-    static final ByteBuf EMPTY_DATA = Unpooled.wrappedBuffer(new byte[] { MSG_EMPTY_DATA });
-    static final ByteBuf DTC_APPLY = Unpooled.wrappedBuffer(new byte[] { MSG_DTC_APPLY });
+    static final ByteBuf EMPTY_DATA = Unpooled.unreleasableBuffer(
+        Unpooled.wrappedBuffer(new byte[] { MSG_EMPTY_DATA }));
+
+    static final ByteBuf DTC_APPLY = Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(new byte[] { MSG_DTC_APPLY }));
+
+    static final ByteBuf PING = Unpooled.unreleasableBuffer(
+        Unpooled.wrappedBuffer(new byte[] { MSG_PING }));
+
+    static final ByteBuf PONG = Unpooled.unreleasableBuffer(
+        Unpooled.wrappedBuffer(new byte[] { MSG_PONG }));
 
     private Constants() {
         // Hidden on purpose