*/
package org.opendaylight.controller.cluster.datastore.persisted;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.WritableObject;
/**
* Enumeration of all ABI versions supported by this implementation of persistence. An ABI version has to be bumped
* whenever:
- * - a new event is defined
- * - serialization format is changed
+ * <ul>
+ * <li>a new event is defined</li>
+ * <li>serialization format is changed</li>
+ * </ul>
*
+ * <p>
* This version effectively defines the protocol version between actors participating on a particular shard. A shard
* participant instance should oppose RAFT candidates which produce persistence of an unsupported version. If a follower
* encounters an unsupported version it must not become fully-operational, as it does not have an accurate view
private final short value;
PayloadVersion(final int intVersion) {
- Preconditions.checkArgument(intVersion >= 0 && intVersion <= 65535);
+ checkArgument(intVersion >= 0 && intVersion <= 65535);
value = (short) intVersion;
}
*
* @return Current {@link PayloadVersion}
*/
- public static @Nonnull PayloadVersion current() {
+ public static @NonNull PayloadVersion current() {
return BORON;
}
* Return the {@link PayloadVersion} corresponding to an unsigned short integer. This method is provided for callers
* which provide their own recovery strategy in case of version incompatibility.
*
- * @param s Short integer as returned from {@link #shortValue()}
+ * @param version Short integer as returned from {@link #shortValue()}
* @return {@link PayloadVersion}
* @throws FutureVersionException if the specified integer identifies a future version
* @throws PastVersionException if the specified integer identifies a past version which is no longer supported
*/
- public static @Nonnull PayloadVersion valueOf(final short s) throws FutureVersionException, PastVersionException {
- switch (Short.toUnsignedInt(s)) {
+ public static @NonNull PayloadVersion valueOf(final short version)
+ throws FutureVersionException, PastVersionException {
+ switch (Short.toUnsignedInt(version)) {
case 0:
case 1:
case 2:
case 3:
case 4:
- throw new PastVersionException(s, BORON);
+ throw new PastVersionException(version, BORON);
case 5:
return BORON;
default:
- throw new FutureVersionException(s, BORON);
+ throw new FutureVersionException(version, BORON);
}
}
* @return An {@link PayloadVersion}
* @throws IOException If read fails or an unsupported version is encountered
*/
- public static @Nonnull PayloadVersion readFrom(final @Nonnull DataInput in) throws IOException {
+ public static @NonNull PayloadVersion readFrom(final @NonNull DataInput in) throws IOException {
final short s = in.readShort();
try {
return valueOf(s);