import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.idmanager.IdUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.IdEntries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class UpdateIdEntryJob implements Callable<List<ListenableFuture<Void>>> {
+ private static final Logger LOG = LoggerFactory.getLogger(UpdateIdEntryJob.class);
private final String parentPoolName;
private final String localPoolName;
private final String idKey;
}
@Override
- public List<ListenableFuture<Void>> call() throws Exception {
+ public List<ListenableFuture<Void>> call() throws TransactionCommitFailedException {
WriteTransaction tx = broker.newWriteOnlyTransaction();
idUtils.updateChildPool(tx, parentPoolName, localPoolName);
if (newIdValues != null && !newIdValues.isEmpty()) {
tx.delete(CONFIGURATION, idUtils.getIdEntriesInstanceIdentifier(parentPoolName, idKey));
}
tx.submit().checkedGet();
- Optional.ofNullable(idUtils.releaseIdLatchMap.get(parentPoolName + idKey))
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Updated id entry with idValues {}, idKey {}, pool {}", newIdValues, idKey, localPoolName);
+ }
+ String uniqueIdKey = idUtils.getUniqueKey(parentPoolName, idKey);
+ Optional.ofNullable(idUtils.releaseIdLatchMap.get(uniqueIdKey))
.ifPresent(latch -> latch.countDown());
+ // Once the id is written to DS, removing the id value from map.
+ idUtils.allocatedIdMap.remove(uniqueIdKey);
return Collections.emptyList();
}
}