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
9 package org.opendaylight.genius.idmanager.jobs;
11 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import java.util.Collections;
15 import java.util.List;
16 import java.util.concurrent.Callable;
17 import org.opendaylight.genius.idmanager.IdUtils;
18 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class LocalPoolDeleteJob implements Callable<List<? extends ListenableFuture<?>>> {
26 private static final Logger LOG = LoggerFactory.getLogger(LocalPoolDeleteJob.class);
28 private final String poolName;
29 private final ManagedNewTransactionRunner txRunner;
30 private final IdUtils idUtils;
32 public LocalPoolDeleteJob(String poolName, ManagedNewTransactionRunner txRunner, IdUtils idUtils) {
33 this.poolName = poolName;
34 this.txRunner = txRunner;
35 this.idUtils = idUtils;
39 public List<ListenableFuture<Void>> call() {
40 InstanceIdentifier<IdPool> idPoolToBeDeleted = idUtils.getIdPoolInstance(poolName);
41 return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
42 tx.delete(idPoolToBeDeleted);
43 if (LOG.isDebugEnabled()) {
44 LOG.debug("Deleted local pool {}", poolName);