2 * Copyright (c) 2013 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.config.manager.impl;
10 import javax.annotation.concurrent.GuardedBy;
12 public class TransactionStatus {
14 private boolean secondPhaseCommitStarted = false;
15 // switches to true during abort or commit failure
17 private boolean aborted;
18 // switches to true during second phase commit
20 private boolean committed;
22 public synchronized boolean isSecondPhaseCommitStarted() {
23 return secondPhaseCommitStarted;
26 synchronized void setSecondPhaseCommitStarted() {
27 this.secondPhaseCommitStarted = true;
30 public synchronized boolean isAborted() {
34 synchronized void setAborted() {
38 public synchronized boolean isCommitted() {
42 synchronized void setCommitted() {
43 this.committed = true;
46 public synchronized boolean isAbortedOrCommitted() {
47 return aborted || committed;
50 public synchronized void checkNotCommitStarted() {
51 if (secondPhaseCommitStarted == true) {
52 throw new IllegalStateException("Commit was triggered");
56 public synchronized void checkCommitStarted() {
57 if (secondPhaseCommitStarted == false) {
58 throw new IllegalStateException("Commit was not triggered");
62 public synchronized void checkNotAborted() {
63 if (aborted == true) {
64 throw new IllegalStateException("Configuration was aborted");
68 public synchronized void checkNotCommitted() {
69 if (committed == true) {
70 throw new IllegalStateException(
71 "Cannot use this method after second phase commit");
75 public synchronized void checkCommitted() {
76 if (committed == false) {
77 throw new IllegalStateException(
78 "Cannot use this method before second phase commit");