// Path: network/netty/src/main/java/se/sics/gvod/common/msgs/DirectMsgNettyFactory.java
// public abstract class DirectMsgNettyFactory {
// 
//     public static abstract class Base {
// 
//         protected VodAddress vodDest;
//         protected VodAddress vodSrc;
//         protected TimeoutId timeoutId;
//         protected Address src, dest;
//         protected static Class<? extends MsgFrameDecoder> msgFrameDecoder;
// 
//         public static void setMsgFrameDecoder(Class<? extends MsgFrameDecoder> msgFrameDecoder) {
//             Base.msgFrameDecoder = msgFrameDecoder;
//         }
// 
//         /**
//          *
//          * @param buffer Netty's channel buffer
//          * @param timeout Does this msg include a TimeoutId? (Yes = true, No =
//          * false)
//          * @return
//          * @throws MessageDecodingException
//          */
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             if (Base.msgFrameDecoder == null) {
//                 throw new NullPointerException("VodMsgNettyFactory.setMsgFrameDecoder() must be called before decoding any messages");
//             }
//             decodeHeader(buffer, timeout);
// 
//             DirectMsg msg = process(buffer);
//             finish(msg);
//             return msg;
//         }
//         protected abstract void finish(DirectMsg msg);
// 
//         protected void decodeHeader(ByteBuf buffer, boolean timeout)
//                 throws MessageDecodingException {
//             if (timeout) {
//                 timeoutId = new UUID(buffer.readInt());
//             } else {
//                 timeoutId = new NoTimeoutId();
//             }
//             int srcId = buffer.readInt();
//             int destId = buffer.readInt();
//             src = new Address(srcId);
//             dest = new Address(destId);
// 
//             int srcOverlayId = buffer.readInt();
//             int srcNatPolicy = UserTypesDecoderFactory.readUnsignedIntAsOneByte(buffer);
//             Set<Address> parents = UserTypesDecoderFactory.readListAddresses(buffer);
//             int destOverlayId = buffer.readInt();
//             int destNatPolicy = UserTypesDecoderFactory.readUnsignedIntAsOneByte(buffer);
// 
//             vodSrc = new VodAddress(src, srcOverlayId, (short) srcNatPolicy, parents);
//             vodDest = new VodAddress(dest, destOverlayId, (short) destNatPolicy, null);
//         }
// 
//         protected abstract DirectMsg process(ByteBuf buffer) throws MessageDecodingException;
//     };
// 
//     public static abstract class Request extends Base {
//         
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class Response extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class Oneway extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, false);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//         }
//     }
//     
//     public static abstract class SystemRequest extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//         
//     }
//     
//     public static abstract class SystemResponse extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class SystemOneway extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, false);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//         }
//     }
// }


import io.netty.buffer.ByteBuf;
import se.sics.gvod.common.msgs.DirectMsgNettyFactory;
import se.sics.gvod.common.msgs.MessageDecodingException;
package se.sics.gvod.hp.msgs;


public class HpKeepAliveMsgFactory {

    public static class Request extends DirectMsgNettyFactory.Request {

        private Request() {
        }

        public static HpKeepAliveMsg.Ping fromBuffer(ByteBuf buffer)
                throws MessageDecodingException {
            return (HpKeepAliveMsg.Ping)
                    new HpKeepAliveMsgFactory.Request().decode(buffer);
        }

        @Override
        protected HpKeepAliveMsg.Ping process(ByteBuf buffer) throws MessageDecodingException {
            return new HpKeepAliveMsg.Ping(vodSrc, vodDest);
        }
    }

    public static class Response extends DirectMsgNettyFactory.Response {

        private Response() {
        }

        public static HpKeepAliveMsg.Pong fromBuffer(ByteBuf buffer)
                throws MessageDecodingException {
            return (HpKeepAliveMsg.Pong)
                    new HpKeepAliveMsgFactory.Response().decode(buffer);
        }

        @Override
        protected HpKeepAliveMsg.Pong process(ByteBuf buffer) throws MessageDecodingException {

// Path: network/netty/src/main/java/se/sics/gvod/common/msgs/DirectMsgNettyFactory.java
// public abstract class DirectMsgNettyFactory {
// 
//     public static abstract class Base {
// 
//         protected VodAddress vodDest;
//         protected VodAddress vodSrc;
//         protected TimeoutId timeoutId;
//         protected Address src, dest;
//         protected static Class<? extends MsgFrameDecoder> msgFrameDecoder;
// 
//         public static void setMsgFrameDecoder(Class<? extends MsgFrameDecoder> msgFrameDecoder) {
//             Base.msgFrameDecoder = msgFrameDecoder;
//         }
// 
//         /**
//          *
//          * @param buffer Netty's channel buffer
//          * @param timeout Does this msg include a TimeoutId? (Yes = true, No =
//          * false)
//          * @return
//          * @throws MessageDecodingException
//          */
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             if (Base.msgFrameDecoder == null) {
//                 throw new NullPointerException("VodMsgNettyFactory.setMsgFrameDecoder() must be called before decoding any messages");
//             }
//             decodeHeader(buffer, timeout);
// 
//             DirectMsg msg = process(buffer);
//             finish(msg);
//             return msg;
//         }
//         protected abstract void finish(DirectMsg msg);
// 
//         protected void decodeHeader(ByteBuf buffer, boolean timeout)
//                 throws MessageDecodingException {
//             if (timeout) {
//                 timeoutId = new UUID(buffer.readInt());
//             } else {
//                 timeoutId = new NoTimeoutId();
//             }
//             int srcId = buffer.readInt();
//             int destId = buffer.readInt();
//             src = new Address(srcId);
//             dest = new Address(destId);
// 
//             int srcOverlayId = buffer.readInt();
//             int srcNatPolicy = UserTypesDecoderFactory.readUnsignedIntAsOneByte(buffer);
//             Set<Address> parents = UserTypesDecoderFactory.readListAddresses(buffer);
//             int destOverlayId = buffer.readInt();
//             int destNatPolicy = UserTypesDecoderFactory.readUnsignedIntAsOneByte(buffer);
// 
//             vodSrc = new VodAddress(src, srcOverlayId, (short) srcNatPolicy, parents);
//             vodDest = new VodAddress(dest, destOverlayId, (short) destNatPolicy, null);
//         }
// 
//         protected abstract DirectMsg process(ByteBuf buffer) throws MessageDecodingException;
//     };
// 
//     public static abstract class Request extends Base {
//         
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class Response extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class Oneway extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, false);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//         }
//     }
//     
//     public static abstract class SystemRequest extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//         
//     }
//     
//     public static abstract class SystemResponse extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, true);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//             msg.setTimeoutId(timeoutId);
//         }
//     }
//     
//     public static abstract class SystemOneway extends Base  {
//         protected DirectMsg decode(ByteBuf buffer) throws MessageDecodingException {
//             return super.decode(buffer, false);
//         }
//         @Override
//         protected DirectMsg decode(ByteBuf buffer, boolean timeout) throws MessageDecodingException {
//             throw new UnsupportedOperationException("Call decode(), not decode(.., boolean timeout)");
//         }        
//         @Override
//         protected void finish(DirectMsg msg) {
//         }
//     }
// }


// Path: network/netty/src/main/java/se/sics/gvod/hp/msgs/HpKeepAliveMsgFactory.java
import io.netty.buffer.ByteBuf;
import se.sics.gvod.common.msgs.DirectMsgNettyFactory;
import se.sics.gvod.common.msgs.MessageDecodingException;

package se.sics.gvod.hp.msgs;


public class HpKeepAliveMsgFactory {

    public static class Request extends DirectMsgNettyFactory.Request {

        private Request() {
        }

        public static HpKeepAliveMsg.Ping fromBuffer(ByteBuf buffer)
                throws MessageDecodingException {
            return (HpKeepAliveMsg.Ping)
                    new HpKeepAliveMsgFactory.Request().decode(buffer);
        }

        @Override
        protected HpKeepAliveMsg.Ping process(ByteBuf buffer) throws MessageDecodingException {
            return new HpKeepAliveMsg.Ping(vodSrc, vodDest);
        }
    }

    public static class Response extends DirectMsgNettyFactory.Response {

        private Response() {
        }

        public static HpKeepAliveMsg.Pong fromBuffer(ByteBuf buffer)
                throws MessageDecodingException {
            return (HpKeepAliveMsg.Pong)
                    new HpKeepAliveMsgFactory.Response().decode(buffer);
        }

        @Override
        protected HpKeepAliveMsg.Pong process(ByteBuf buffer) throws MessageDecodingException {

            return new HpKeepAliveMsg.Pong(vodSrc, vodDest, timeoutId);