private RemoteDeviceConnector remoteDeviceConnector;
private NetconfNodeManager netconfNodeManager;
private ActorRef masterActorRef;
- private boolean finalClose = false;
+ private final AtomicBoolean finalClose = new AtomicBoolean(false);
private final AtomicBoolean closed = new AtomicBoolean(false);
- private boolean isMaster;
+ private volatile boolean isMaster;
NetconfTopologyContext(final NetconfTopologySetup netconfTopologyDeviceSetup,
final ServiceGroupIdentifier serviceGroupIdent,
netconfNodeManager = null;
}
- if (!finalClose) {
+ if (!finalClose.get()) {
final String masterAddress =
Cluster.get(netconfTopologyDeviceSetup.getActorSystem()).selfAddress().toString();
masterActorRef = netconfTopologyDeviceSetup.getActorSystem().actorOf(NetconfNodeActor.props(
@Override
public ListenableFuture<Void> closeServiceInstance() {
- if (!finalClose) {
+ if (!finalClose.get()) {
// in case that master changes role to slave, new NodeDeviceManager must be created and listener registered
netconfNodeManager = createNodeDeviceManager();
}
}
void closeFinal() throws Exception {
- finalClose = true;
+ if (!finalClose.compareAndSet(false, true)) {
+ return;
+ }
if (netconfNodeManager != null) {
netconfNodeManager.close();