Change sequential stream to parallel stream
If some devices are late to response result, remained switches's information will be pended to update.
So, to reduce the execution time and to prevent delay of update information, change sequential stream to parallel stream.
Change-Id: Id0fe2307c2c5705e781dc61d07faecb2a1e55d65
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index 24ec529..fe6060d 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -404,7 +404,7 @@
//Connecting devices with initial config
private void connectDevices() {
Set<DeviceId> deviceSubjects = cfgService.getSubjects(DeviceId.class, NetconfDeviceConfig.class);
- deviceSubjects.forEach(deviceId -> {
+ deviceSubjects.parallelStream().forEach(deviceId -> {
connectionExecutor.execute(exceptionSafe(() -> runElectionFor(deviceId)));
});
}
@@ -412,7 +412,7 @@
//updating keys and device info
private void checkAndUpdateDevices() {
Set<DeviceId> deviceSubjects = cfgService.getSubjects(DeviceId.class, NetconfDeviceConfig.class);
- deviceSubjects.forEach(deviceId -> {
+ deviceSubjects.parallelStream().forEach(deviceId -> {
log.debug("check and update {}", deviceId);
NetconfDeviceConfig config = cfgService.getConfig(deviceId, NetconfDeviceConfig.class);
storeDeviceKey(config.sshKey(), config.username(), config.password(), deviceId);