/* * Copyright (c) 2016 Cisco Systems, Inc. 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.concepts; import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; /** * A failure response to a {@link Request}. Contains a {@link RequestException} detailing the cause for this failure. * * @author Robert Varga * * @param Target identifier type * @param Message class */ @Beta public abstract class RequestFailure> extends Response { private static final long serialVersionUID = 1L; private final @NonNull RequestException cause; protected RequestFailure(final @NonNull C failure, final @NonNull ABIVersion version) { super(failure, version); this.cause = requireNonNull(failure.getCause()); } protected RequestFailure(final @NonNull T target, final long sequence, final @NonNull RequestException cause) { super(target, sequence); this.cause = requireNonNull(cause); } /** * Return the failure cause. * * @return Failure cause. */ public final @NonNull RequestException getCause() { return cause; } /** * Return an indication of whether this a hard failure. Hard failures must not be retried but need to be treated * as authoritative response to a request. * * @return True if this represents a hard failure, false otherwise. */ public final boolean isHardFailure() { return !cause.isRetriable(); } @Override protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { return super.addToStringAttributes(toStringHelper).add("cause", cause); } @Override protected abstract AbstractRequestFailureProxy externalizableProxy(ABIVersion version); }