X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fcommands%2FSkipTransactionsRequest.java;fp=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fcommands%2FSkipTransactionsRequest.java;h=dd5faa8e875b474f82c57597411be7039c43b93c;hb=abeaf223cadd818e2054b516e39c20305ea144b8;hp=0000000000000000000000000000000000000000;hpb=87979c22dfbeb25924600a7d3cc6e875edb82c5e;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java new file mode 100644 index 0000000000..dd5faa8e87 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/SkipTransactionsRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.access.commands; + +import akka.actor.ActorRef; +import com.google.common.annotations.Beta; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.primitives.UnsignedLong; +import java.util.Collection; +import java.util.List; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.controller.cluster.access.ABIVersion; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; + +/** + * Request to skip a number of {@link TransactionIdentifier}s within a {code local history}. This request is essentially + * equivalent to {@link TransactionPurgeRequest} for {@link #getTarget()}, but also carries additional sibling + * {@link TransactionIdentifier}s in {@link #getOthers()}. + * + *

+ * This request is sent by the frontend to inform the backend that a set of {@link TransactionIdentifier}s are + * explicitly retired and are guaranteed to never be used by the frontend. + */ +@Beta +public final class SkipTransactionsRequest extends TransactionRequest { + private static final long serialVersionUID = 1L; + + // Note: UnsignedLong is arbitrary, yang.common.Uint64 would work just as well, we really want an immutable + // List, though. + private final @NonNull ImmutableList others; + + public SkipTransactionsRequest(final TransactionIdentifier target, final long sequence, + final ActorRef replyTo, final Collection others) { + super(target, sequence, replyTo); + this.others = ImmutableList.copyOf(others); + } + + /** + * Return this {@link #getTarget()}s sibling {@link TransactionIdentifier}s. + * + * @return Siblings values of {@link TransactionIdentifier#getTransactionId()} + */ + public List getOthers() { + return others; + } + + @Override + protected SkipTransactionsRequestV1 externalizableProxy(final ABIVersion version) { + return new SkipTransactionsRequestV1(this); + } + + @Override + protected SkipTransactionsRequest cloneAsVersion(final ABIVersion version) { + return this; + } + + @Override + protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { + final var helper = super.addToStringAttributes(toStringHelper); + if (!others.isEmpty()) { + helper.add("others", others); + } + return helper; + } +}