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.cluster.datastore.DataStoreVersions;
12 import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
14 public class CanCommitTransaction extends AbstractThreePhaseCommitMessage {
15 private static final long serialVersionUID = 1L;
17 public CanCommitTransaction() {
20 public CanCommitTransaction(String transactionID, final short version) {
21 super(transactionID, version);
26 protected Object newLegacySerializedInstance() {
27 return ThreePhaseCommitCohortMessages.CanCommitTransaction.newBuilder().
28 setTransactionId(getTransactionID()).build();
31 public static CanCommitTransaction fromSerializable(Object serializable) {
32 if(serializable instanceof CanCommitTransaction) {
33 return (CanCommitTransaction)serializable;
35 return new CanCommitTransaction(((ThreePhaseCommitCohortMessages.CanCommitTransaction)serializable).
36 getTransactionId(), DataStoreVersions.LITHIUM_VERSION);
40 public static boolean isSerializedType(Object message) {
41 return message instanceof CanCommitTransaction ||
42 message instanceof ThreePhaseCommitCohortMessages.CanCommitTransaction;