2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore.messages;
11 import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
13 public class CanCommitTransactionReply implements SerializableMessage {
14 public static final Class<ThreePhaseCommitCohortMessages.CanCommitTransactionReply> SERIALIZABLE_CLASS =
15 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.class;
17 public static final CanCommitTransactionReply YES = new CanCommitTransactionReply(true);
18 public static final CanCommitTransactionReply NO = new CanCommitTransactionReply(false);
20 private final boolean canCommit;
21 private final Object serializedMessage;
23 private CanCommitTransactionReply(final boolean canCommit) {
24 this.canCommit = canCommit;
25 this.serializedMessage = ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder().
26 setCanCommit(canCommit).build();
29 public boolean getCanCommit() {
34 public Object toSerializable() {
35 return serializedMessage;
38 public static CanCommitTransactionReply fromSerializable(final Object message) {
39 ThreePhaseCommitCohortMessages.CanCommitTransactionReply serialized =
40 (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) message;
41 return serialized.getCanCommit() ? YES : NO;