Cyrill commented on code in PR #6850: URL: https://github.com/apache/ignite-3/pull/6850#discussion_r2511369161
########## modules/raft/src/main/java/org/apache/ignite/raft/jraft/entity/codec/v2/LogEntryV2CodecFactory.java: ########## @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ignite.raft.jraft.entity.codec.v2; + +import org.apache.ignite.raft.jraft.entity.EnumOutter.EntryType; +import org.apache.ignite.raft.jraft.entity.codec.LogEntryCodecFactory; +import org.apache.ignite.raft.jraft.entity.codec.LogEntryDecoder; +import org.apache.ignite.raft.jraft.entity.codec.LogEntryEncoder; + +/** + * Log entry codec implementation V2. Extends V1 format with sequence token support. + * Data format description: + * <ul> + * <li>Magic header, 1 byte. {@link #MAGIC}</li> + * <li>Log entry type, formally a var-long, effectively 1 byte. {@link EntryType}</li> + * <li>Log index, var-long, from 1 to 9 bytes.</li> + * <li>Log term, var-long, from 1 to 9 bytes.</li> + * <li>Checksum, 8 bytes, Little Endian.</li> + * <li><b>Sequence token, var-long, from 1 to 9 bytes. (NEW in V2)</b></li> + * <li><b>Old sequence token, var-long, from 1 to 9 bytes. (NEW in V2)</b></li> + * <li>If type is not {@link EntryType#ENTRY_TYPE_DATA}:<ul> + * <li>Number of peers, var-long. Following it is the array of peers:</li> + * <li>Length of the peer name, 2 bytes, Little Endian.</li> + * <li>ASCII characters of the peer name, according to the read count.</li> + * <li>Peer index, var-long.</li> + * <li>Peer priority + 1, var-long.</li> + * <li>... same block repeats for "oldPeers", "learners" and "oldLearners".</li> + * </ul></li> + * <li>If type is not {@link EntryType#ENTRY_TYPE_CONFIGURATION}:<ul> + * <li>The rest of the {@code byte[]} is the data payload.</li> + * </ul></li> + * </ul> + */ +public class LogEntryV2CodecFactory implements LogEntryCodecFactory { Review Comment: Yes we have tests - the old node will not be able to read such entry. I don't have a better option than to add a property to disable writing v2 until a property is set or until something is on or off - in that case this fix will be literally turned off. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
