import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
+import org.opendaylight.mdsal.eos.binding.api.Entity;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.CarId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.CarService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars;
public void close() {
stopThread();
- unregisterCommitCohort();
+ closeCommitCohortRegistration();
}
private void stopThread() {
final ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration =
dataProvider.registerDataTreeChangeListener(CARS_DTID, new CarDataTreeChangeListener());
- if (carsDtclRegistration != null) {
- carsDtclRegistrations.add(carsDtclRegistration);
- return RpcResultBuilder.<Void>success().buildFuture();
- }
- return RpcResultBuilder.<Void>failed().buildFuture();
+ carsDtclRegistrations.add(carsDtclRegistration);
+ return RpcResultBuilder.<Void>success().buildFuture();
}
@Override
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<Void>> unregisterCommitCohort() {
+ closeCommitCohortRegistration();
+
+ return RpcResultBuilder.<Void>success().buildFuture();
+ }
+
+ private void closeCommitCohortRegistration() {
final DOMDataTreeCommitCohortRegistration<CarEntryDataTreeCommitCohort> reg = commitCohortReg.getAndSet(null);
if (reg != null) {
- try {
- reg.close();
- LOG_CAR_PROVIDER.info("Unregistered commit cohort");
- } catch (Exception e) {
- return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION,
- "Error closing commit cohort registration", e).buildFuture();
- }
+ reg.close();
+ LOG_CAR_PROVIDER.info("Unregistered commit cohort");
}
-
- return RpcResultBuilder.<Void>success().buildFuture();
}
@Override