Sho SHIMIZU
Committed by Gerrit Code Review

Replace Stream#forEach() with Collection#forEach()

Change-Id: I2b261c3d91d345907b165bd61eb7b6c45011c247
...@@ -231,7 +231,7 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope ...@@ -231,7 +231,7 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope
231 sIncomingBuilder.matchEthType(Ethernet.TYPE_IPV4) 231 sIncomingBuilder.matchEthType(Ethernet.TYPE_IPV4)
232 .matchIPDst(floatingIp.toIpPrefix()); 232 .matchIPDst(floatingIp.toIpPrefix());
233 233
234 - gatewayService.getGatewayDeviceIds().stream().forEach(deviceId -> { 234 + gatewayService.getGatewayDeviceIds().forEach(deviceId -> {
235 TrafficSelector.Builder sForTrafficFromVmBuilder = DefaultTrafficSelector.builder() 235 TrafficSelector.Builder sForTrafficFromVmBuilder = DefaultTrafficSelector.builder()
236 .matchEthType(Ethernet.TYPE_IPV4) 236 .matchEthType(Ethernet.TYPE_IPV4)
237 .matchIPDst(floatingIp.toIpPrefix()) 237 .matchIPDst(floatingIp.toIpPrefix())
...@@ -278,8 +278,8 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope ...@@ -278,8 +278,8 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope
278 .matchIPDst(floatingIp.toIpPrefix()) 278 .matchIPDst(floatingIp.toIpPrefix())
279 .build(); 279 .build();
280 280
281 - gatewayService.getGatewayDeviceIds().stream().forEach(gnodeId -> { 281 + gatewayService.getGatewayDeviceIds().forEach(gnodeId -> {
282 - TrafficTreatment treatmentForTrafficFromExternal = DefaultTrafficTreatment.builder() 282 + TrafficTreatment treatmentForTrafficFromExternal = DefaultTrafficTreatment.builder()
283 .setEthSrc(Constants.DEFAULT_GATEWAY_MAC) 283 .setEthSrc(Constants.DEFAULT_GATEWAY_MAC)
284 .setEthDst(associatedVm.mac()) 284 .setEthDst(associatedVm.mac())
285 .setIpDst(associatedVm.ipAddresses().stream().findFirst().get()) 285 .setIpDst(associatedVm.ipAddresses().stream().findFirst().get())
...@@ -336,7 +336,7 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope ...@@ -336,7 +336,7 @@ public class OpenstackFloatingIpManager extends AbstractVmHandler implements Ope
336 .matchIPSrc(associatedVm.ipAddresses().stream().findFirst().get().toIpPrefix()) 336 .matchIPSrc(associatedVm.ipAddresses().stream().findFirst().get().toIpPrefix())
337 .build(); 337 .build();
338 338
339 - gatewayService.getGatewayDeviceIds().stream().forEach(gnodeId -> { 339 + gatewayService.getGatewayDeviceIds().forEach(gnodeId -> {
340 TrafficTreatment treatment = DefaultTrafficTreatment.builder() 340 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
341 .setIpSrc(floatingIp) 341 .setIpSrc(floatingIp)
342 .setEthSrc(Constants.DEFAULT_GATEWAY_MAC) 342 .setEthSrc(Constants.DEFAULT_GATEWAY_MAC)
......
...@@ -125,7 +125,7 @@ public class OpenstackIcmpHandler { ...@@ -125,7 +125,7 @@ public class OpenstackIcmpHandler {
125 .matchIPProtocol(IPv4.PROTOCOL_ICMP) 125 .matchIPProtocol(IPv4.PROTOCOL_ICMP)
126 .build(); 126 .build();
127 127
128 - gatewayService.getGatewayDeviceIds().stream().forEach(gateway -> { 128 + gatewayService.getGatewayDeviceIds().forEach(gateway -> {
129 packetService.requestPackets(icmpSelector, 129 packetService.requestPackets(icmpSelector,
130 PacketPriority.CONTROL, 130 PacketPriority.CONTROL,
131 appId, 131 appId,
......
...@@ -315,7 +315,7 @@ public class OpenstackPnatHandler { ...@@ -315,7 +315,7 @@ public class OpenstackPnatHandler {
315 } 315 }
316 316
317 tBuilder.setIpSrc(externalIp); 317 tBuilder.setIpSrc(externalIp);
318 - gatewayService.getGatewayNodes().stream().forEach(gateway -> { 318 + gatewayService.getGatewayNodes().forEach(gateway -> {
319 TrafficTreatment.Builder tmpBuilder = DefaultTrafficTreatment.builder(tBuilder.build()); 319 TrafficTreatment.Builder tmpBuilder = DefaultTrafficTreatment.builder(tBuilder.build());
320 tmpBuilder.setOutput(gatewayService.getUplinkPort(gateway.getGatewayDeviceId())); 320 tmpBuilder.setOutput(gatewayService.getUplinkPort(gateway.getGatewayDeviceId()));
321 ForwardingObjective fo = DefaultForwardingObjective.builder() 321 ForwardingObjective fo = DefaultForwardingObjective.builder()
...@@ -374,7 +374,7 @@ public class OpenstackPnatHandler { ...@@ -374,7 +374,7 @@ public class OpenstackPnatHandler {
374 return; 374 return;
375 } 375 }
376 376
377 - gatewayService.getGatewayDeviceIds().stream().forEach(deviceId -> { 377 + gatewayService.getGatewayDeviceIds().forEach(deviceId -> {
378 DeviceId srcDeviceId = srcVm.get().location().deviceId(); 378 DeviceId srcDeviceId = srcVm.get().location().deviceId();
379 TrafficTreatment.Builder tmpBuilder = DefaultTrafficTreatment.builder(tBuilder.build()); 379 TrafficTreatment.Builder tmpBuilder = DefaultTrafficTreatment.builder(tBuilder.build());
380 tmpBuilder.extension(RulePopulatorUtil.buildExtension( 380 tmpBuilder.extension(RulePopulatorUtil.buildExtension(
...@@ -431,4 +431,4 @@ public class OpenstackPnatHandler { ...@@ -431,4 +431,4 @@ public class OpenstackPnatHandler {
431 } 431 }
432 } 432 }
433 } 433 }
434 -}
...\ No newline at end of file ...\ No newline at end of file
434 +}
......
...@@ -197,9 +197,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst ...@@ -197,9 +197,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
197 if (gatewayIp == null) { 197 if (gatewayIp == null) {
198 return; 198 return;
199 } 199 }
200 - gatewayService.getGatewayDeviceIds().stream().forEach(deviceId -> { 200 + gatewayService.getGatewayDeviceIds().forEach(deviceId -> populateGatewayIcmpRule(gatewayIp, deviceId));
201 - populateGatewayIcmpRule(gatewayIp, deviceId);
202 - });
203 } 201 }
204 202
205 private void populateGatewayIcmpRule(Ip4Address gatewayIp, DeviceId deviceId) { 203 private void populateGatewayIcmpRule(Ip4Address gatewayIp, DeviceId deviceId) {
...@@ -371,7 +369,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst ...@@ -371,7 +369,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
371 } 369 }
372 370
373 Map<String, String> vniMap = new HashMap<>(); 371 Map<String, String> vniMap = new HashMap<>();
374 - openstackService.networks().stream().forEach(n -> vniMap.put(n.id(), n.segmentId())); 372 + openstackService.networks().forEach(n -> vniMap.put(n.id(), n.segmentId()));
375 373
376 // TODO improve pipeline, do we have to install access rules between networks 374 // TODO improve pipeline, do we have to install access rules between networks
377 // for every single VMs? 375 // for every single VMs?
...@@ -402,7 +400,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst ...@@ -402,7 +400,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
402 } 400 }
403 401
404 Map<String, String> vniMap = new HashMap<>(); 402 Map<String, String> vniMap = new HashMap<>();
405 - openstackService.networks().stream().forEach(n -> vniMap.put(n.id(), n.segmentId())); 403 + openstackService.networks().forEach(n -> vniMap.put(n.id(), n.segmentId()));
406 404
407 osSubNets.stream().filter(osSubNet -> !osSubNet.id().equals(osSubNetId)).forEach(osSubNet -> { 405 osSubNets.stream().filter(osSubNet -> !osSubNet.id().equals(osSubNetId)).forEach(osSubNet -> {
408 TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); 406 TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
......
...@@ -663,7 +663,7 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv ...@@ -663,7 +663,7 @@ public final class OpenstackNodeManager extends ListenerRegistry<OpenstackNodeEv
663 prevNodeMap.remove(node.hostname()); 663 prevNodeMap.remove(node.hostname());
664 addOrUpdateNode(node); 664 addOrUpdateNode(node);
665 }); 665 });
666 - prevNodeMap.values().stream().forEach(this::deleteNode); 666 + prevNodeMap.values().forEach(this::deleteNode);
667 } 667 }
668 668
669 private class InternalConfigListener implements NetworkConfigListener { 669 private class InternalConfigListener implements NetworkConfigListener {
......
...@@ -166,17 +166,16 @@ public class SdnIpFib { ...@@ -166,17 +166,16 @@ public class SdnIpFib {
166 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet(); 166 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
167 167
168 // TODO this should be only peering interfaces 168 // TODO this should be only peering interfaces
169 - interfaceService.getInterfaces().stream() 169 + interfaceService.getInterfaces().forEach(intf -> {
170 - .forEach(intf -> { 170 + // Get ony ingress interfaces with IPs configured
171 - // Get ony ingress interfaces with IPs configured 171 + if (validIngressIntf(intf, egressInterface)) {
172 - if (validIngressIntf(intf, egressInterface)) { 172 + TrafficSelector.Builder selector =
173 - TrafficSelector.Builder selector = 173 + buildIngressTrafficSelector(intf, prefix);
174 - buildIngressTrafficSelector(intf, prefix); 174 + FilteredConnectPoint ingressFilteredCP =
175 - FilteredConnectPoint ingressFilteredCP = 175 + new FilteredConnectPoint(intf.connectPoint(), selector.build());
176 - new FilteredConnectPoint(intf.connectPoint(), selector.build()); 176 + ingressFilteredCPs.add(ingressFilteredCP);
177 - ingressFilteredCPs.add(ingressFilteredCP); 177 + }
178 - } 178 + });
179 - });
180 179
181 // Build treatment: rewrite the destination MAC address 180 // Build treatment: rewrite the destination MAC address
182 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder() 181 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
......
...@@ -191,7 +191,7 @@ implements VirtualPortService { ...@@ -191,7 +191,7 @@ implements VirtualPortService {
191 public VirtualPort getPort(MacAddress mac) { 191 public VirtualPort getPort(MacAddress mac) {
192 checkNotNull(mac, MAC_NOT_NULL); 192 checkNotNull(mac, MAC_NOT_NULL);
193 List<VirtualPort> vPorts = new ArrayList<>(); 193 List<VirtualPort> vPorts = new ArrayList<>();
194 - vPortStore.values().stream().forEach(p -> { 194 + vPortStore.values().forEach(p -> {
195 if (p.macAddress().equals(mac)) { 195 if (p.macAddress().equals(mac)) {
196 vPorts.add(p); 196 vPorts.add(p);
197 } 197 }
......
...@@ -137,7 +137,7 @@ public class PredictableExecutor ...@@ -137,7 +137,7 @@ public class PredictableExecutor
137 137
138 @Override 138 @Override
139 public void shutdown() { 139 public void shutdown() {
140 - backends.stream().forEach(ExecutorService::shutdown); 140 + backends.forEach(ExecutorService::shutdown);
141 } 141 }
142 142
143 @Override 143 @Override
......