X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fcallhome-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fcallhome%2Fmount%2FIetfZeroTouchCallHomeServerProvider.java;h=8bb21ffa51b3582add48ef346dafd5ec00a5d70f;hb=4f0f6f3a97b17d1e6914149c4c999d8801596c41;hp=e8b96e671b47b724bd05d35ab061db9e476fb6b5;hpb=b4352cee21473f4f59667a03c52680d39cfbf733;p=netconf.git diff --git a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java index e8b96e671b..8bb21ffa51 100644 --- a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java +++ b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java @@ -11,6 +11,7 @@ package org.opendaylight.netconf.callhome.mount; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; +import io.netty.channel.nio.NioEventLoopGroup; import java.io.IOException; import java.net.InetSocketAddress; import java.util.Collection; @@ -62,7 +63,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT private int port = 0; // 0 = use default in NetconfCallHomeBuilder private final CallhomeStatusReporter statusReporter; - public IetfZeroTouchCallHomeServerProvider(DataBroker dataBroker, CallHomeMountDispatcher mountDispacher) { + public IetfZeroTouchCallHomeServerProvider(final DataBroker dataBroker, + final CallHomeMountDispatcher mountDispacher) { this.dataBroker = dataBroker; this.mountDispacher = mountDispacher; this.authProvider = new CallHomeAuthProviderImpl(dataBroker); @@ -82,7 +84,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } } - public void setPort(String portStr) { + public void setPort(final String portStr) { try { Configuration configuration = new Configuration(); configuration.set(CALL_HOME_PORT_KEY, portStr); @@ -105,6 +107,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT if (port > 0) { builder.setBindAddress(new InetSocketAddress(port)); } + builder.setNettyGroup(new NioEventLoopGroup()); server = builder.build(); server.bind(); mountDispacher.createTopology(); @@ -112,7 +115,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } @VisibleForTesting - void assertValid(Object obj, String description) { + void assertValid(final Object obj, final String description) { if (obj == null) { throw new RuntimeException( String.format("Failed to find %s in IetfZeroTouchCallHomeProvider.initialize()", description)); @@ -120,7 +123,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } @Override - public void close() throws Exception { + public void close() { authProvider.close(); statusReporter.close(); @@ -136,7 +139,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } @Override - public void onDataTreeChanged(@Nonnull Collection> changes) { + public void onDataTreeChanged(@Nonnull final Collection> changes) { // In case of any changes to the devices datatree, register the changed values with callhome server // As of now, no way to add a new callhome client key to the CallHomeAuthorization instance since // its created under CallHomeAuthorizationProvider. @@ -169,27 +172,23 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } } - private void handleDeletedDevices(Set> deletedDevices) { + private void handleDeletedDevices(final Set> deletedDevices) { if (deletedDevices.isEmpty()) { return; } ReadWriteTransaction opTx = dataBroker.newReadWriteTransaction(); - int numRemoved = deletedDevices.size(); - for (InstanceIdentifier removedIID : deletedDevices) { LOG.info("Deleting the entry for callhome device {}", removedIID); opTx.delete(LogicalDatastoreType.OPERATIONAL, removedIID); } - if (numRemoved > 0) { - opTx.submit(); - } + opTx.commit(); } - private List getReadDevices( - ListenableFuture> devicesFuture) throws InterruptedException, ExecutionException { + private static List getReadDevices(final ListenableFuture> devicesFuture) + throws InterruptedException, ExecutionException { Optional opt = devicesFuture.get(); return opt.isPresent() ? opt.get().getDevice() : Collections.emptyList(); } @@ -205,13 +204,13 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT Device1 devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build(); if (opDevGet.isPresent()) { Device opDevice = opDevGet.get(); - devStatus = opDevice.getAugmentation(Device1.class); + devStatus = opDevice.augmentation(Device1.class); } cfgDevice = new DeviceBuilder().addAugmentation(Device1.class, devStatus) .setSshHostKey(cfgDevice.getSshHostKey()).setUniqueId(cfgDevice.getUniqueId()).build(); tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIID, cfgDevice); - tx.submit(); + tx.commit(); } }