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.datastore.persisted;
10 import com.google.common.io.ByteArrayDataOutput;
11 import com.google.common.io.ByteStreams;
12 import java.io.DataInput;
13 import java.io.IOException;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17 * Payload persisted when a transaction is aborted. It contains the transaction identifier.
19 * @author Robert Varga
21 public final class AbortTransactionPayload extends AbstractIdentifiablePayload<TransactionIdentifier> {
22 private static final class Proxy extends AbstractProxy<TransactionIdentifier> {
23 private static final long serialVersionUID = 1L;
25 // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
26 // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
27 @SuppressWarnings("checkstyle:RedundantModifier")
32 Proxy(final byte[] serialized) {
37 protected TransactionIdentifier readIdentifier(final DataInput in) throws IOException {
38 return TransactionIdentifier.readFrom(in);
42 protected AbortTransactionPayload createObject(final TransactionIdentifier identifier,
43 final byte[] serialized) {
44 return new AbortTransactionPayload(identifier, serialized);
48 private static final long serialVersionUID = 1L;
50 AbortTransactionPayload(final TransactionIdentifier transactionId, final byte[] serialized) {
51 super(transactionId, serialized);
54 public static AbortTransactionPayload create(final TransactionIdentifier transactionId) throws IOException {
55 final ByteArrayDataOutput out = ByteStreams.newDataOutput();
56 transactionId.writeTo(out);
57 return new AbortTransactionPayload(transactionId, out.toByteArray());
61 protected Proxy externalizableProxy(final byte[] serialized) {
62 return new Proxy(serialized);