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.base.MoreObjects;
11 import java.io.DataInput;
12 import java.io.DataOutput;
13 import java.io.IOException;
14 import org.opendaylight.yangtools.concepts.WritableObject;
15 import org.opendaylight.yangtools.concepts.WritableObjects;
17 public final class FrontendHistoryMetadata implements WritableObject {
18 private final long historyId;
19 private final long cookie;
20 private final long nextTransaction;
21 private final boolean closed;
23 public FrontendHistoryMetadata(final long historyId, final long cookie, final long nextTransaction,
24 final boolean closed) {
25 this.historyId = historyId;
27 this.nextTransaction = nextTransaction;
31 public long getHistoryId() {
35 public long getCookie() {
39 public long getNextTransaction() {
40 return nextTransaction;
43 public boolean isClosed() {
48 public void writeTo(final DataOutput out) throws IOException {
49 WritableObjects.writeLongs(out, historyId, cookie);
50 WritableObjects.writeLong(out, nextTransaction);
51 out.writeBoolean(closed);
54 public static FrontendHistoryMetadata readFrom(final DataInput in) throws IOException {
55 final byte header = WritableObjects.readLongHeader(in);
56 final long historyId = WritableObjects.readFirstLong(in, header);
57 final long cookie = WritableObjects.readSecondLong(in, header);
58 final long nextTransaction = WritableObjects.readLong(in);
59 final boolean closed = in.readBoolean();
61 return new FrontendHistoryMetadata(historyId, cookie, nextTransaction, closed);
65 public String toString() {
66 return MoreObjects.toStringHelper(FrontendHistoryMetadata.class).add("historiId", historyId)
67 .add("cookie", cookie).add("nextTransaction", nextTransaction).add("closed", closed).toString();