import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
+import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.genius.mdsalutil.interfaces.ShardStatusMonitor;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@Inject
public IdManager(DataBroker db, LockManagerService lockManager, IdUtils idUtils,
- @Reference DataImportBootReady dataImportBootReady, @Reference JobCoordinator jobCoordinator)
+ @Reference DataImportBootReady dataImportBootReady,
+ @Reference JobCoordinator jobCoordinator, @Reference ShardStatusMonitor shardStatusMonitor)
throws ReadFailedException, InterruptedException {
this.broker = db;
this.txRunner = new ManagedNewTransactionRunnerImpl(db);
// it appears to be (is) un-used from a Java code PoV!
this.localPool = new ConcurrentHashMap<>();
- populateCache();
+ boolean isDatastoreAvailable = false;
+ int retryCount = 0;
+ int totalRetry = 1000;
+ try {
+ while (retryCount < totalRetry) {
+ isDatastoreAvailable = shardStatusMonitor.getShardStatus(NwConstants.IdManagerShards.getShardList());
+ if (isDatastoreAvailable) {
+ LOG.info("IDManager is UP");
+ populateCache();
+ break;
+ }
+ LOG.error("IdManager: retrying shard status check for the {} time, pending retries {}",
+ ++retryCount, totalRetry - retryCount);
+ Thread.sleep(2000);
+ }
+ } catch (InterruptedException e) {
+ LOG.error("IDManager is DOWN, shard status check failed");
+ }
+
+ if (!isDatastoreAvailable) {
+ LOG.error("IDManager is DOWN, as shards were not available at bundle bringup");
+ }
}
@Override