2 * Copyright (c) 2019 Pantheon Technologies, s.r.o. 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.akka.segjournal;
10 import static java.util.Objects.requireNonNull;
12 import akka.persistence.PersistentRepr;
13 import io.atomix.storage.journal.JournalSegment;
16 * A single entry in the data journal. We do not store {@code persistenceId} for each entry, as that is a
17 * journal-invariant, nor do we store {@code sequenceNr}, as that information is maintained by {@link JournalSegment}'s
20 * @author Robert Varga
22 abstract class DataJournalEntry {
23 static final class ToPersistence extends DataJournalEntry {
24 private final PersistentRepr repr;
26 ToPersistence(final PersistentRepr repr) {
27 this.repr = requireNonNull(repr);
30 PersistentRepr repr() {
35 static final class FromPersistence extends DataJournalEntry {
36 private final String manifest;
37 private final String writerUuid;
38 private final Object payload;
40 FromPersistence(final String manifest, final String writerUuid, final Object payload) {
41 this.manifest = manifest;
42 this.writerUuid = requireNonNull(writerUuid);
43 this.payload = requireNonNull(payload);
46 PersistentRepr toRepr(final String persistenceId, final long sequenceNr) {
47 return PersistentRepr.apply(payload, sequenceNr, persistenceId, manifest, false, null, writerUuid);