2 * Copyright (c) 2017 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.sharding;
10 import static akka.actor.ActorRef.noSender;
12 import akka.actor.ActorRef;
13 import akka.actor.Status;
14 import org.eclipse.jdt.annotation.Nullable;
17 * Base class for lookup tasks. Lookup tasks are supposed to run repeatedly until successful lookup or maximum retries
18 * are hit. This class is NOT thread-safe.
20 @Deprecated(forRemoval = true)
21 abstract class LookupTask implements Runnable {
22 private final int maxRetries;
23 private final ActorRef replyTo;
24 private int retried = 0;
26 LookupTask(final ActorRef replyTo, final int maxRetries) {
27 this.replyTo = replyTo;
28 this.maxRetries = maxRetries;
31 abstract void reschedule(int retries);
33 void tryReschedule(final @Nullable Throwable throwable) {
34 if (retried <= maxRetries) {
42 void fail(final @Nullable Throwable throwable) {
43 if (throwable == null) {
44 replyTo.tell(new Status.Failure(
45 new DOMDataTreeShardCreationFailedException("Unable to find the backend shard."
46 + "Failing..")), noSender());
48 replyTo.tell(new Status.Failure(
49 new DOMDataTreeShardCreationFailedException("Unable to find the backend shard."
50 + "Failing..", throwable)), noSender());