2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.access.commands;
10 import com.google.common.annotations.Beta;
11 import java.io.DataInput;
12 import java.io.DataOutput;
13 import java.io.IOException;
14 import org.opendaylight.yangtools.concepts.WritableObject;
17 * Enumeration of transaction persistence protocols. These govern which protocol is executed between the frontend
18 * and backend to drive persistence of a particular transaction.
20 * @author Robert Varga
23 public enum PersistenceProtocol implements WritableObject {
25 * Abort protocol. The transaction has been aborted on the frontend and its effects should not be visible
26 * in the global history. This is a simple request/reply protocol.
35 * Simple commit protocol. The transaction should be committed to the global history. The receiving backend
36 * is the only entity which needs to persist its effects, hence a simple request/reply protocol is sufficient.
45 * Three-phase commit protocol (3PC). The transaction should be committed to the global history, but it is a part
46 * of a transaction spanning multiple entities and coordination is needed to drive persistence.
55 * Transaction is ready. This is not a really a persistence protocol, but an indication that frontend has
56 * completed modifications on the transaction and considers it ready, without deciding the actual commit protocol.
66 public final void writeTo(final DataOutput out) throws IOException {
67 out.writeByte(byteValue());
70 public static PersistenceProtocol readFrom(final DataInput in) throws IOException {
71 return valueOf(in.readByte());
74 abstract byte byteValue();
76 static int byteValue(final PersistenceProtocol finish) {
77 return finish == null ? 0 : finish.byteValue();
80 static PersistenceProtocol valueOf(final byte value) {
93 throw new IllegalArgumentException("Unhandled byte value " + value);