X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2FNetconfDevice.java;h=8d52950a2954539da471fcbe1f164b01f4eeb1c1;hb=9ce96ee41db1bc2e79ef02c1bc0a1e6b5bcf477f;hp=abbbb68265e3209915f32f17e589ff76c4dc2a91;hpb=2b379f8680220cf2a387cbb120deb38f299d4596;p=controller.git diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java index abbbb68265..8d52950a29 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java @@ -119,6 +119,9 @@ public class NetconfDevice implements Provider, // NetconfDeviceListener listener; + private boolean rollbackSupported; + + public NetconfDevice(String name) { this.name = name; this.logger = LoggerFactory.getLogger(NetconfDevice.class + "#" + name); @@ -172,30 +175,41 @@ public class NetconfDevice implements Provider, // } } - void bringUp(SchemaSourceProvider delegate, Set capabilities) { - remoteSourceProvider = schemaSourceProvider.createInstanceFor(delegate); - deviceContextProvider = new NetconfDeviceSchemaContextProvider(this, remoteSourceProvider); - deviceContextProvider.createContextFromCapabilities(capabilities); - if (mountInstance != null && getSchemaContext().isPresent()) { - mountInstance.setSchemaContext(getSchemaContext().get()); - } + void bringUp(final SchemaSourceProvider delegate, final Set capabilities, final boolean rollbackSupported) { + // This has to be called from separate thread, not from netty thread calling onSessionUp in DeviceListener. + // Reason: delegate.getSchema blocks thread when waiting for response + // however, if the netty thread is blocked, no incoming message can be processed + // ... netty should pick another thread from pool to process incoming message, but it does not http://netty.io/wiki/thread-model.html + // TODO redesign +refactor + processingExecutor.submit(new Runnable() { + @Override + public void run() { + NetconfDevice.this.rollbackSupported = rollbackSupported; + remoteSourceProvider = schemaSourceProvider.createInstanceFor(delegate); + deviceContextProvider = new NetconfDeviceSchemaContextProvider(NetconfDevice.this, remoteSourceProvider); + deviceContextProvider.createContextFromCapabilities(capabilities); + if (mountInstance != null && getSchemaContext().isPresent()) { + mountInstance.setSchemaContext(getSchemaContext().get()); + } - updateDeviceState(true, capabilities); + updateDeviceState(true, capabilities); - if (mountInstance != null) { - confReaderReg = mountInstance.registerConfigurationReader(ROOT_PATH, this); - operReaderReg = mountInstance.registerOperationalReader(ROOT_PATH, this); - commitHandlerReg = mountInstance.registerCommitHandler(ROOT_PATH, this); + if (mountInstance != null) { + confReaderReg = mountInstance.registerConfigurationReader(ROOT_PATH, NetconfDevice.this); + operReaderReg = mountInstance.registerOperationalReader(ROOT_PATH, NetconfDevice.this); + commitHandlerReg = mountInstance.registerCommitHandler(ROOT_PATH, NetconfDevice.this); - List rpcs = new ArrayList<>(); - // TODO same condition twice - if (mountInstance != null && getSchemaContext().isPresent()) { - for (RpcDefinition rpc : mountInstance.getSchemaContext().getOperations()) { - rpcs.add(mountInstance.addRpcImplementation(rpc.getQName(), this)); + List rpcs = new ArrayList<>(); + // TODO same condition twice + if (mountInstance != null && getSchemaContext().isPresent()) { + for (RpcDefinition rpc : mountInstance.getSchemaContext().getOperations()) { + rpcs.add(mountInstance.addRpcImplementation(rpc.getQName(), NetconfDevice.this)); + } + } + rpcReg = rpcs; } } - rpcReg = rpcs; - } + }); } private void updateDeviceState(boolean up, Set capabilities) { @@ -353,7 +367,7 @@ public class NetconfDevice implements Provider, // public DataCommitTransaction requestCommit( DataModification modification) { NetconfDeviceTwoPhaseCommitTransaction twoPhaseCommit = new NetconfDeviceTwoPhaseCommitTransaction(this, - modification, true); + modification, true, rollbackSupported); try { twoPhaseCommit.prepare(); } catch (InterruptedException e) {