2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.genius.idmanager.jobs;
10 import static org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.concurrent.Callable;
16 import org.opendaylight.genius.idmanager.IdUtils;
17 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class LocalPoolDeleteJob implements Callable<List<? extends ListenableFuture<?>>> {
24 private static final Logger LOG = LoggerFactory.getLogger(LocalPoolDeleteJob.class);
26 private final String poolName;
27 private final ManagedNewTransactionRunner txRunner;
28 private final IdUtils idUtils;
30 public LocalPoolDeleteJob(String poolName, ManagedNewTransactionRunner txRunner, IdUtils idUtils) {
31 this.poolName = poolName;
32 this.txRunner = txRunner;
33 this.idUtils = idUtils;
37 public List<? extends ListenableFuture<?>> call() {
38 InstanceIdentifier<IdPool> idPoolToBeDeleted = idUtils.getIdPoolInstance(poolName);
39 return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
40 tx.delete(idPoolToBeDeleted);
41 if (LOG.isDebugEnabled()) {
42 LOG.debug("Deleted local pool {}", poolName);