eddf8d6dbaa341d3c21e4f1b672780ebc22e7df0
[mdsal.git] / replicate / mdsal-replicate-netty / src / main / java / org / opendaylight / mdsal / replicate / netty / Constants.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.replicate.netty;
9
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.Unpooled;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15 final class Constants {
16     /**
17      * Subscribe request message. This is the only valid initial message in the sink->source direction. Its payload is
18      * composed of a binary normalized node stream. The stream must contain a {@link LogicalDatastoreType} serialized
19      * via {@link LogicalDatastoreType#writeTo(java.io.DataOutput)} followed by a single {@link YangInstanceIdentifier}.
20      */
21     static final byte MSG_SUBSCRIBE_REQ = 1;
22     /**
23      * Initial data indicating non-presence of the subscribed path.
24      */
25     static final byte MSG_EMPTY_DATA    = 2;
26     /**
27      * A chunk of the DataTreeCandidate serialization stream. May be followed by another chunk or
28      * {@link #MSG_DTC_APPLY}.
29      */
30     static final byte MSG_DTC_CHUNK     = 3;
31     /**
32      * End-of-DataTreeCandidate serialization stream. The payload is empty.
33      */
34     static final byte MSG_DTC_APPLY     = 4;
35
36     /**
37      * Length of the length field in each transmitted frame.
38      */
39     static final int LENGTH_FIELD_LENGTH = 4;
40     /**
41      * Maximum frame size allowed by encoding, 1MiB.
42      */
43     static final int LENGTH_FIELD_MAX    = 1024 * 1024;
44
45     static final ByteBuf EMPTY_DATA = Unpooled.wrappedBuffer(new byte[] { MSG_EMPTY_DATA });
46     static final ByteBuf DTC_APPLY = Unpooled.wrappedBuffer(new byte[] { MSG_DTC_APPLY });
47
48     private Constants() {
49         // Hidden on purpose
50     }
51 }