Sho SHIMIZU
Committed by Gerrit Code Review

Use Collection#forEach() instead of Stream#forEach() for simplicity

Change-Id: I0a1aea4bdb5d305c50273e6ff749fe71bd2a295a
Showing 48 changed files with 128 additions and 149 deletions
......@@ -37,7 +37,7 @@ public class GetAllActiveAlarms extends AbstractShellCommand {
}
void printAlarms(Set<Alarm> alarms) {
alarms.stream().forEach((alarm) -> {
alarms.forEach((alarm) -> {
print(ToStringBuilder.reflectionToString(alarm, ToStringStyle.SHORT_PREFIX_STYLE));
});
}
......
......@@ -36,7 +36,7 @@ public class GetAllAlarms extends AbstractShellCommand {
}
void printAlarms(Set<Alarm> alarms) {
alarms.stream().forEach((alarm) -> {
alarms.forEach((alarm) -> {
print(ToStringBuilder.reflectionToString(alarm, ToStringStyle.SHORT_PREFIX_STYLE));
});
}
......
......@@ -36,7 +36,7 @@ public class GetAllAlarmsCounts extends AbstractShellCommand {
}
void printCounts(Map<Alarm.SeverityLevel, Long> alarmCounts) {
alarmCounts.entrySet().stream().forEach((countEntry) -> {
alarmCounts.entrySet().forEach((countEntry) -> {
print(String.format("%s, %d",
countEntry.getKey(), countEntry.getValue()));
......
......@@ -42,9 +42,9 @@ public class GetDeviceAlarmsCounts extends AbstractShellCommand {
}
void printCounts(Map<Alarm.SeverityLevel, Long> alarmCounts) {
alarmCounts.entrySet().stream().forEach((countEntry) -> {
alarmCounts.entrySet().forEach((countEntry) -> {
print(String.format("%s, %d",
countEntry.getKey(), countEntry.getValue()));
countEntry.getKey(), countEntry.getValue()));
});
}
......
......@@ -113,7 +113,7 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
AlarmServiceUtil.lookUpAlarms() :
AlarmServiceUtil.lookUpAlarms(DeviceId.deviceId(devId));
alarms.stream().forEach((alarm) -> {
alarms.forEach((alarm) -> {
populateRow(tm.addRow(), alarm);
});
......
......@@ -195,7 +195,7 @@ public class DefaultInfluxDbMetricsReporter implements InfluxDbMetricsReporter {
MetricRegistry moddedRegistry = new MetricRegistry();
ControllerNode node = clusterService.getLocalNode();
String prefix = node.id().id() + ".";
metricRegistry.getNames().stream().forEach(name ->
metricRegistry.getNames().forEach(name ->
moddedRegistry.register(prefix + name, metricRegistry.getMetrics().get(name)));
return moddedRegistry;
......
......@@ -215,7 +215,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
.filter(h -> routableNetIds.contains(h.annotations().value(NETWORK_ID)))
.collect(Collectors.toSet());
hosts.stream().forEach(h -> populateRoutingRules(h, routableNets));
hosts.forEach(h -> populateRoutingRules(h, routableNets));
}
private void unsetRoutes(OpenstackRouter osRouter, OpenstackNetwork osNet) {
......@@ -226,7 +226,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
h.annotations().value(NETWORK_ID), osNet.id()))
.forEach(h -> removeRoutingRules(h, routableNets));
routableNets.stream().forEach(n -> {
routableNets.forEach(n -> {
Tools.stream(hostService.getHosts())
.filter(h -> Objects.equals(
h.annotations().value(NETWORK_ID),
......@@ -269,7 +269,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
.matchTunnelId(Long.valueOf(osNet.segmentId()))
.matchEthDst(Constants.DEFAULT_GATEWAY_MAC);
nodeService.completeNodes().stream().forEach(node -> {
nodeService.completeNodes().forEach(node -> {
ForwardingObjective.Flag flag = node.type().equals(GATEWAY) ?
ForwardingObjective.Flag.VERSATILE :
ForwardingObjective.Flag.SPECIFIC;
......@@ -359,8 +359,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst
.fromApp(appId)
.add();
gatewayService.getGatewayDeviceIds().stream()
.forEach(deviceId -> flowObjectiveService.forward(deviceId, fo));
gatewayService.getGatewayDeviceIds().forEach(deviceId -> flowObjectiveService.forward(deviceId, fo));
}
private void populateCnodeToGateway(long vni) {
......
......@@ -121,7 +121,7 @@ public class OpenstackSecurityGroupManager extends AbstractVmHandler
.filter(entry -> getTenantId(entry.getKey()).equals(tenantId))
.forEach(entry -> {
Host local = entry.getKey();
entry.getValue().stream().forEach(sgRule -> {
entry.getValue().forEach(sgRule -> {
setSecurityGroupRule(local.location().deviceId(),
sgRule.rule(),
getIp(local),
......@@ -250,10 +250,10 @@ public class OpenstackSecurityGroupManager extends AbstractVmHandler
}
Set<SecurityGroupRule> rules = Sets.newHashSet();
osPort.securityGroups().stream().forEach(sgId -> {
osPort.securityGroups().forEach(sgId -> {
OpenstackSecurityGroup osSecGroup = openstackService.securityGroup(sgId);
if (osSecGroup != null) {
osSecGroup.rules().stream().forEach(rule -> rules.addAll(getSgRules(rule)));
osSecGroup.rules().forEach(rule -> rules.addAll(getSgRules(rule)));
} else {
// TODO handle the case that the security group removed
log.warn("Failed to get security group {}", sgId);
......
......@@ -194,8 +194,7 @@ public final class OpenstackSwitchingArpHandler extends AbstractVmHandler {
log.warn("Failed to get OpenStack network for {}", host);
return;
}
osNet.subnets().stream()
.forEach(subnet -> gateways.add(Ip4Address.valueOf(subnet.gatewayIp())));
osNet.subnets().forEach(subnet -> gateways.add(Ip4Address.valueOf(subnet.gatewayIp())));
}
@Override
......
......@@ -530,7 +530,7 @@ public class VtnManager implements VtnService {
Iterable<Host> allHosts = hostService.getHosts();
String tunnelName = "vxlan-" + DEFAULT_IP;
if (allHosts != null) {
Sets.newHashSet(allHosts).stream().forEach(host -> {
Sets.newHashSet(allHosts).forEach(host -> {
MacAddress hostMac = host.mac();
String ifaceId = host.annotations().value(IFACEID);
if (ifaceId == null) {
......@@ -549,7 +549,7 @@ public class VtnManager implements VtnService {
.getControllerIpOfSwitch(remoteDevice);
if (remoteControllerIp == null) {
log.error("Can't find remote controller of device: {}",
remoteDeviceId.toString());
remoteDeviceId.toString());
return;
}
IpAddress remoteIpAddress = IpAddress
......@@ -557,10 +557,10 @@ public class VtnManager implements VtnService {
ports.stream()
.filter(p -> p.name().equalsIgnoreCase(tunnelName))
.forEach(p -> {
l2ForwardService
.programTunnelOut(device.id(), segmentationId, p,
hostMac, type, remoteIpAddress);
});
l2ForwardService
.programTunnelOut(device.id(), segmentationId, p,
hostMac, type, remoteIpAddress);
});
});
}
}
......@@ -899,7 +899,7 @@ public class VtnManager implements VtnService {
programRouterInterface(routerInf, operation);
if (interfacesSet.size() == 1) {
routerInfFlagOfTenantRouter.remove(tenantRouter);
interfacesSet.stream().forEach(r -> {
interfacesSet.forEach(r -> {
programRouterInterface(r, operation);
});
}
......@@ -961,7 +961,7 @@ public class VtnManager implements VtnService {
TenantRouter tenantRouter = TenantRouter
.tenantRouter(r.tenantId(), r.routerId());
routerInfFlagOfTenantRouter.put(tenantRouter, true);
interfacesSet.stream().forEach(f -> {
interfacesSet.forEach(f -> {
programRouterInterface(f, operation);
});
break;
......@@ -977,7 +977,7 @@ public class VtnManager implements VtnService {
SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
// Get all the host of the subnet
Map<HostId, Host> hosts = hostsOfSubnet.get(routerInf.subnetId());
hosts.values().stream().forEach(h -> {
hosts.values().forEach(h -> {
applyEastWestL3Flows(h, l3vni, operation);
});
}
......@@ -1292,7 +1292,7 @@ public class VtnManager implements VtnService {
.stream().filter(r -> r.tenantId().equals(tenantId))
.filter(r -> r.subnetId().equals(subnetId))
.collect(Collectors.toSet());
hostInterfaces.stream().forEach(routerInf -> {
hostInterfaces.forEach(routerInf -> {
Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces)
.stream().filter(r -> r.tenantId().equals(tenantId))
.filter(r -> r.routerId().equals(routerInf.routerId()))
......
......@@ -105,7 +105,7 @@ public class ClassifierServiceImpl implements ClassifierService {
log.info("No tunnel port in device");
return;
}
Sets.newHashSet(localTunnelPorts).stream().forEach(tp -> {
Sets.newHashSet(localTunnelPorts).forEach(tp -> {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(tp).add(Criteria.matchTunnelId(Long
.parseLong(segmentationId.toString())))
......
......@@ -83,7 +83,7 @@ public final class L2ForwardServiceImpl implements L2ForwardService {
log.info("No other host port and tunnel in the device");
return;
}
Sets.newHashSet(localVmPorts).stream().forEach(lp -> {
Sets.newHashSet(localVmPorts).forEach(lp -> {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(lp).matchEthDst(MacAddress.BROADCAST)
.add(Criteria.matchTunnelId(Long
......@@ -124,7 +124,7 @@ public final class L2ForwardServiceImpl implements L2ForwardService {
log.info("No other host port or tunnel ports in the device");
return;
}
Sets.newHashSet(localTunnelPorts).stream().forEach(tp -> {
Sets.newHashSet(localTunnelPorts).forEach(tp -> {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(tp)
.add(Criteria.matchTunnelId(Long
......
......@@ -128,7 +128,7 @@ public final class VtnData {
FixedIp fixedIP) {
if (vPortStore != null) {
List<VirtualPort> vPorts = new ArrayList<>();
vPortStore.values().stream().forEach(p -> {
vPortStore.values().forEach(p -> {
Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
while (fixedIps.hasNext()) {
if (fixedIps.next().equals(fixedIP)) {
......
......@@ -150,7 +150,7 @@ implements VirtualPortService {
public VirtualPort getPort(FixedIp fixedIP) {
checkNotNull(fixedIP, FIXEDIP_NOT_NULL);
List<VirtualPort> vPorts = new ArrayList<>();
vPortStore.values().stream().forEach(p -> {
vPortStore.values().forEach(p -> {
Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
while (fixedIps.hasNext()) {
if (fixedIps.next().equals(fixedIP)) {
......
......@@ -129,7 +129,7 @@ public class SfcViewMessageHandler extends UiMessageHandler {
StringBuffer srcipbuf = new StringBuffer();
StringBuffer dstipbuf = new StringBuffer();
if (flowClassifierList != null) {
flowClassifierList.stream().forEach(fcid -> {
flowClassifierList.forEach(fcid -> {
FlowClassifier fc = fcs.getFlowClassifier(fcid);
String srcip = fc.srcIpPrefix().toString();
String dstip = fc.dstIpPrefix().toString();
......@@ -157,11 +157,11 @@ public class SfcViewMessageHandler extends UiMessageHandler {
VirtualPortService vps = get(VirtualPortService.class);
List<VirtualPort> vpList = new ArrayList<VirtualPort>();
if (portPairGroupList != null) {
portPairGroupList.stream().forEach(ppgid -> {
portPairGroupList.forEach(ppgid -> {
PortPairGroup ppg = ppgs.getPortPairGroup(ppgid);
List<PortPairId> portPairList = ppg.portPairs();
if (portPairList != null) {
portPairList.stream().forEach(ppid -> {
portPairList.forEach(ppid -> {
PortPair pp = pps.getPortPair(ppid);
VirtualPort vp = vps.getPort(VirtualPortId.portId(pp.ingress()));
vpList.add(vp);
......
......@@ -115,9 +115,9 @@ public final class DefaultVtnPortApi extends XosApi implements VtnPortApi {
}
Map<IpAddress, MacAddress> addressPairs = Maps.newHashMap();
osPort.getAllowedAddressPairs().stream().forEach(
osPort.getAllowedAddressPairs().forEach(
pair -> addressPairs.put(IpAddress.valueOf(pair.getIpAddress()),
MacAddress.valueOf(pair.getMacAddress())));
MacAddress.valueOf(pair.getMacAddress())));
return VtnPort.builder()
.id(VtnPortId.of(osPort.getId()))
......
......@@ -60,13 +60,12 @@ public class MapsListCommand extends AbstractShellCommand {
ArrayNode maps = mapper.createArrayNode();
// Create a JSON node for each map
mapInfo.stream()
.forEach(info -> {
ObjectNode map = mapper.createObjectNode();
map.put("name", info.name())
.put("size", info.size());
maps.add(map);
});
mapInfo.forEach(info -> {
ObjectNode map = mapper.createObjectNode();
map.put("name", info.name())
.put("size", info.size());
maps.add(map);
});
return maps;
}
......
......@@ -123,23 +123,20 @@ public class PartitionsListCommand extends AbstractShellCommand {
ArrayNode partitions = mapper.createArrayNode();
// Create a JSON node for each partition
partitionInfo.stream()
.forEach(info -> {
ObjectNode partition = mapper.createObjectNode();
partitionInfo.forEach(info -> {
ObjectNode partition = mapper.createObjectNode();
// Add each member to the "members" array for this partition
ArrayNode members = partition.putArray("members");
info.members()
.stream()
.forEach(members::add);
// Add each member to the "members" array for this partition
ArrayNode members = partition.putArray("members");
info.members().forEach(members::add);
// Complete the partition attributes and add it to the array
partition.put("name", info.name())
.put("term", info.term())
.put("leader", info.leader());
partitions.add(partition);
// Complete the partition attributes and add it to the array
partition.put("name", info.name())
.put("term", info.term())
.put("leader", info.leader());
partitions.add(partition);
});
});
return partitions;
}
......@@ -155,25 +152,24 @@ public class PartitionsListCommand extends AbstractShellCommand {
ClusterService clusterService = get(ClusterService.class);
// Create a JSON node for each partition client
partitionClientInfo.stream()
.forEach(info -> {
ObjectNode partition = mapper.createObjectNode();
// Add each member to the "servers" array for this partition
ArrayNode servers = partition.putArray("servers");
info.servers()
.stream()
.map(clusterService::getNode)
.map(node -> String.format("%s:%d", node.ip(), node.tcpPort()))
.forEach(servers::add);
// Complete the partition attributes and add it to the array
partition.put("partitionId", info.partitionId().toString())
.put("sessionId", info.sessionId())
.put("status", info.status().toString());
partitions.add(partition);
});
partitionClientInfo.forEach(info -> {
ObjectNode partition = mapper.createObjectNode();
// Add each member to the "servers" array for this partition
ArrayNode servers = partition.putArray("servers");
info.servers()
.stream()
.map(clusterService::getNode)
.map(node -> String.format("%s:%d", node.ip(), node.tcpPort()))
.forEach(servers::add);
// Complete the partition attributes and add it to the array
partition.put("partitionId", info.partitionId().toString())
.put("sessionId", info.sessionId())
.put("status", info.status().toString());
partitions.add(partition);
});
return partitions;
}
......
......@@ -72,7 +72,7 @@ public class VirtualHostCreateCommand extends AbstractShellCommand {
Set<IpAddress> hostIps = new HashSet<>();
if (hostIpStrings != null) {
Arrays.asList(hostIpStrings).stream().forEach(s -> hostIps.add(IpAddress.valueOf(s)));
Arrays.stream(hostIpStrings).forEach(s -> hostIps.add(IpAddress.valueOf(s)));
}
HostLocation hostLocation = new HostLocation(DeviceId.deviceId(hostLocationDeviceId),
PortNumber.portNumber(hostLocationPortNumber),
......
......@@ -400,7 +400,6 @@ public class DefaultFlowRule implements FlowRule {
private int hash() {
Funnel<TrafficSelector> selectorFunnel = (from, into) -> from.criteria()
.stream()
.forEach(c -> into.putString(c.toString(), Charsets.UTF_8));
HashFunction hashFunction = Hashing.murmur3_32();
......
......@@ -360,7 +360,6 @@ public class FlowRuleCodecTest {
checkCommonData(rule);
rule.treatment().allInstructions()
.stream()
.forEach(instruction ->
{
String subType;
......@@ -551,7 +550,6 @@ public class FlowRuleCodecTest {
assertThat(rule.selector().criteria().size(), is(35));
rule.selector().criteria()
.stream()
.forEach(criterion ->
criteria.put(criterion.type().name(), criterion));
......
......@@ -518,7 +518,7 @@ public class FlowRuleManager
switch (event.type()) {
case BATCH_OPERATION_REQUESTED:
// Request has been forwarded to MASTER Node, and was
request.ops().stream().forEach(
request.ops().forEach(
op -> {
switch (op.operator()) {
......@@ -652,7 +652,7 @@ public class FlowRuleManager
if (context != null) {
final FlowRuleOperations.Builder failedOpsBuilder =
FlowRuleOperations.builder();
failures.stream().forEach(failedOpsBuilder::add);
failures.forEach(failedOpsBuilder::add);
context.onError(failedOpsBuilder.build());
}
......
......@@ -112,8 +112,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
private List<FlowRule> createRules(LinkCollectionIntent intent, DeviceId deviceId,
Set<PortNumber> inPorts, Set<PortNumber> outPorts) {
TrafficTreatment.Builder defaultTreatmentBuilder = DefaultTrafficTreatment.builder();
outPorts.stream()
.forEach(defaultTreatmentBuilder::setOutput);
outPorts.forEach(defaultTreatmentBuilder::setOutput);
TrafficTreatment outputOnlyTreatment = defaultTreatmentBuilder.build();
Set<PortNumber> ingressPorts = Collections.emptySet();
Set<PortNumber> egressPorts = Collections.emptySet();
......@@ -138,8 +137,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
if (!intent.applyTreatmentOnEgress()) {
TrafficTreatment.Builder ingressTreatmentBuilder = DefaultTrafficTreatment.builder(intent.treatment());
outPorts.stream()
.forEach(ingressTreatmentBuilder::setOutput);
outPorts.forEach(ingressTreatmentBuilder::setOutput);
intentTreatment = ingressTreatmentBuilder.build();
if (ingressPorts.contains(inPort)) {
......@@ -153,8 +151,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
if (outPorts.stream().allMatch(egressPorts::contains)) {
TrafficTreatment.Builder egressTreatmentBuilder =
DefaultTrafficTreatment.builder(intent.treatment());
outPorts.stream()
.forEach(egressTreatmentBuilder::setOutput);
outPorts.forEach(egressTreatmentBuilder::setOutput);
selectorBuilder = DefaultTrafficSelector.builder(intent.selector());
treatment = egressTreatmentBuilder.build();
......@@ -343,4 +340,4 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
});
return defaultSelectorBuilder;
}
}
\ No newline at end of file
}
......
......@@ -120,13 +120,11 @@ public class LinkCollectionIntentFlowObjectivesCompiler implements IntentCompile
.collect(Collectors.toSet());
TrafficTreatment.Builder defaultTreatmentBuilder = DefaultTrafficTreatment.builder();
outPorts.stream()
.forEach(defaultTreatmentBuilder::setOutput);
outPorts.forEach(defaultTreatmentBuilder::setOutput);
TrafficTreatment defaultTreatment = defaultTreatmentBuilder.build();
TrafficTreatment.Builder ingressTreatmentBuilder = DefaultTrafficTreatment.builder(intent.treatment());
outPorts.stream()
.forEach(ingressTreatmentBuilder::setOutput);
outPorts.forEach(ingressTreatmentBuilder::setOutput);
TrafficTreatment ingressTreatment = ingressTreatmentBuilder.build();
List<Objective> objectives = new ArrayList<>(inPorts.size());
......
......@@ -601,7 +601,7 @@ public class FlowStatisticManager implements FlowStatisticService {
}
private void checkLoadValidity(Set<FlowEntry> current, Set<FlowEntry> previous) {
current.stream().forEach(c -> {
current.forEach(c -> {
FlowEntry f = previous.stream().filter(p -> c.equals(p)).
findAny().orElse(null);
if (f != null && c.bytes() < f.bytes()) {
......
......@@ -307,7 +307,7 @@ public class MastershipManagerTest {
private void checkDeviceMasters(Set<DeviceId> deviceIds, Set<NodeId> expectedMasters,
Consumer<DeviceId> checkRole) {
// each device's master must be contained in the list of expectedMasters
deviceIds.stream().forEach(deviceId -> {
deviceIds.forEach(deviceId -> {
assertTrue("wrong master:", expectedMasters.contains(mgr.getMasterFor(deviceId)));
if (checkRole != null) {
checkRole.accept(deviceId);
......
......@@ -861,7 +861,7 @@ public class DistributedFlowRuleStore
try {
// compute a mapping from node to the set of devices whose flow entries it should backup
Map<NodeId, Set<DeviceId>> devicesToBackupByNode = Maps.newHashMap();
flowEntries.keySet().stream().forEach(deviceId -> {
flowEntries.keySet().forEach(deviceId -> {
List<NodeId> backupNodes = getBackupNodes(deviceId);
backupNodes.forEach(backupNode -> {
if (lastBackupTimes.getOrDefault(new BackupOperation(backupNode, deviceId), 0L)
......
......@@ -321,7 +321,7 @@ public class DistributedGroupStoreTest {
List<GroupEvent> eventsAfterAdds = delegate.eventsSeen();
assertThat(eventsAfterAdds, hasSize(2));
eventsAfterAdds.stream().forEach(event -> assertThat(event.type(), is(GroupEvent.Type.GROUP_ADD_REQUESTED)));
eventsAfterAdds.forEach(event -> assertThat(event.type(), is(GroupEvent.Type.GROUP_ADD_REQUESTED)));
delegate.resetEvents();
GroupOperation opAdd =
......
......@@ -89,7 +89,6 @@ public class PartitionManager extends AbstractListenerManager<PartitionEvent, Pa
metadataService.addListener(metadataListener);
currentClusterMetadata.get()
.getPartitions()
.stream()
.forEach(partition -> partitions.put(partition.getId(), new StoragePartition(partition,
messagingService,
clusterService,
......
......@@ -169,7 +169,7 @@ public class Bti7000SnmpAlarmConsumer extends AbstractHandlerBehaviour implement
if ((deviceAlarms != null) && (deviceAlarms.getActAlarmEntry() != null)
&& (!deviceAlarms.getActAlarmEntry().isEmpty())) {
deviceAlarms.getActAlarmEntry().values().stream().forEach((alarm) -> {
deviceAlarms.getActAlarmEntry().values().forEach((alarm) -> {
DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
deviceId, alarm.getActAlarmDescription(),
mapAlarmSeverity(alarm.getActAlarmSeverity()),
......
......@@ -67,7 +67,7 @@ public class NetSnmpAlarmConsumer extends AbstractHandlerBehaviour implements Al
IfTable interfaceTable = (IfTable) networkDevice.getRootObject()
.getEntity(CLASS_REGISTRY.getClassToOidMap().get(IfTable.class));
if (interfaceTable != null) {
interfaceTable.getEntries().values().stream().forEach((ifEntry) -> {
interfaceTable.getEntries().values().forEach((ifEntry) -> {
if (ifEntry.getIfAdminStatus() == 1 && ifEntry.getIfOperStatus() == 2) {
alarms.add(new DefaultAlarm.Builder(deviceId, "Link Down.",
Alarm.SeverityLevel.CRITICAL,
......
......@@ -103,7 +103,7 @@ public class CienaWaveserverDeviceDescription extends AbstractHandlerBehaviour
loadXml(controller.get(deviceId, GENERAL_PORT_REQUEST, XML));
List<HierarchicalConfiguration> portsConfig =
parseWaveServerCienaPorts(config);
portsConfig.stream().forEach(sub -> {
portsConfig.forEach(sub -> {
String portId = sub.getString(PORT_ID);
String name = sub.getString(NAME);
if (LINESIDE_PORT_ID.contains(portId)) {
......
......@@ -177,7 +177,7 @@ public abstract class AbstractCorsaPipeline extends AbstractHandlerBehaviour imp
.filter(key -> groupService.getGroup(deviceId, key) != null)
.collect(Collectors.toSet());
keys.stream().forEach(key -> {
keys.forEach(key -> {
NextObjective obj = pendingGroups.getIfPresent(key);
if (obj == null) {
return;
......
......@@ -602,7 +602,7 @@ public class CentecV350Pipeline extends AbstractHandlerBehaviour implements Pipe
.filter(key -> groupService.getGroup(deviceId, key) != null)
.collect(Collectors.toSet());
keys.stream().forEach(key -> {
keys.forEach(key -> {
NextObjective obj = pendingGroups.getIfPresent(key);
if (obj == null) {
return;
......
......@@ -114,7 +114,7 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
filter.conditions().stream().forEach(selector::add);
filter.conditions().forEach(selector::add);
if (filter.key() != null) {
selector.add(filter.key());
......
......@@ -1099,7 +1099,7 @@ public class Ofdpa2GroupHandler {
.collect(Collectors.toSet());
keys.addAll(otherkeys);
keys.stream().forEach(key ->
keys.forEach(key ->
processPendingAddGroupsOrNextObjs(key, false));
}
}
......
......@@ -1158,23 +1158,22 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
.filter(key -> groupService.getGroup(deviceId, key) != null)
.collect(Collectors.toSet());
keys.stream()
.forEach(key -> {
NextObjective obj = pendingGroups
.getIfPresent(key);
if (obj == null) {
return;
}
log.debug("Group verified: dev:{} gid:{} <<->> nextId:{}",
deviceId,
groupService.getGroup(deviceId, key).id(),
obj.id());
pass(obj);
pendingGroups.invalidate(key);
flowObjectiveStore.putNextGroup(
obj.id(),
new SpringOpenGroup(key, null));
});
keys.forEach(key -> {
NextObjective obj = pendingGroups
.getIfPresent(key);
if (obj == null) {
return;
}
log.debug("Group verified: dev:{} gid:{} <<->> nextId:{}",
deviceId,
groupService.getGroup(deviceId, key).id(),
obj.id());
pass(obj);
pendingGroups.invalidate(key);
flowObjectiveStore.putNextGroup(
obj.id(),
new SpringOpenGroup(key, null));
});
if (!pendingGroups.asMap().isEmpty()) {
// Periodically execute only if entry remains in pendingGroups.
......
......@@ -65,7 +65,7 @@ public class LumentumAlarmConsumer extends AbstractHandlerBehaviour implements A
}
// Gets the alarm table and for each entry get the ID and create the proper alarm.
snmp.get(ALARMS_TABLE_OID).stream()
snmp.get(ALARMS_TABLE_OID)
.forEach(alarm -> snmp.get(ALARMS_ID_OID).forEach(alarmIdEvent -> {
int alarmId = getAlarmId(alarmIdEvent);
alarms.add(new DefaultAlarm.Builder(deviceId, getMessage(alarmId),
......
......@@ -153,11 +153,10 @@ public class LumentumFlowRuleProgrammable extends AbstractHandlerBehaviour imple
// Cache the cookie/priority
CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
added.stream()
.forEach(xc -> cache.set(
Objects.hash(data().deviceId(), xc.selector(), xc.treatment()),
xc.id(),
xc.priority()));
added.forEach(xc -> cache.set(
Objects.hash(data().deviceId(), xc.selector(), xc.treatment()),
xc.id(),
xc.priority()));
return added;
}
......@@ -185,9 +184,8 @@ public class LumentumFlowRuleProgrammable extends AbstractHandlerBehaviour imple
// Remove flow rule from cache
CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
removed.stream()
.forEach(xc -> cache.remove(
Objects.hash(data().deviceId(), xc.selector(), xc.treatment())));
removed.forEach(xc -> cache.remove(
Objects.hash(data().deviceId(), xc.selector(), xc.treatment())));
return removed;
}
......
......@@ -69,7 +69,7 @@ public class YangXmlUtils {
XMLConfiguration complete = new XMLConfiguration();
List<String> paths = new ArrayList<>();
Map<String, String> valuesWithKey = new HashMap<>();
values.keySet().stream().forEach(path -> {
values.keySet().forEach(path -> {
List<String> allPaths = findPaths(cfg, path);
String key = nullIsNotFound(allPaths.isEmpty() ? null : allPaths.get(0),
"Yang model does not contain desired path");
......@@ -163,7 +163,7 @@ public class YangXmlUtils {
HierarchicalConfiguration originalCfg, String path,
String originalKey) {
//consider each sub configuration
configurations.stream().forEach(config -> {
configurations.forEach(config -> {
YangElement element = new YangElement(path, new HashMap<>());
//for each of the keys of the sub configuration
......
......@@ -106,7 +106,7 @@ public class YangXmlUtilsTest {
List<ControllerInfo> controllers =
ImmutableList.of(new ControllerInfo(IpAddress.valueOf("1.1.1.1"), 1, "tcp"),
new ControllerInfo(IpAddress.valueOf("2.2.2.2"), 2, "tcp"));
controllers.stream().forEach(cInfo -> {
controllers.forEach(cInfo -> {
elements.add(new YangElement("controller", ImmutableMap.of("id", cInfo.target(),
"ip-address", cInfo.ip().toString())));
});
......@@ -162,4 +162,4 @@ public class YangXmlUtilsTest {
return YangXmlUtilsAdap.class.getResourceAsStream(file);
}
}
}
\ No newline at end of file
}
......
......@@ -216,7 +216,7 @@ public class MeterManager extends AbstractListenerProviderRegistry<MeterEvent, M
.filter(m -> storedMeterMap.remove(Pair.of(m.deviceId(), m.id())) != null)
.forEach(m -> store.updateMeterState(m));
storedMeterMap.values().stream().forEach(m -> {
storedMeterMap.values().forEach(m -> {
if (m.state() == MeterState.PENDING_ADD) {
provider().performMeterOperation(m.deviceId(),
new MeterOperation(m,
......
......@@ -78,8 +78,7 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider {
rpcRegistry.unregister(this);
// shutdown all channels
channels.values().stream()
.forEach(ManagedChannel::shutdown);
channels.values().forEach(ManagedChannel::shutdown);
// Should we wait for shutdown? How?
channels.clear();
log.info("Stopped");
......
......@@ -143,8 +143,7 @@ public class GrpcRemoteServiceServer {
Thread.currentThread().interrupt();
}
registeredProviders.stream()
.forEach(deviceProviderRegistry::unregister);
registeredProviders.forEach(deviceProviderRegistry::unregister);
server.shutdown();
// Should we wait for shutdown?
......
......@@ -307,7 +307,7 @@ public class NetconfDeviceProvider extends AbstractProvider
NetconfProviderConfig cfg = cfgService.getConfig(appId, NetconfProviderConfig.class);
if (cfg != null) {
try {
cfg.getDevicesAddresses().stream().forEach(addr -> {
cfg.getDevicesAddresses().forEach(addr -> {
DeviceId deviceId = getDeviceId(addr.ip().toString(), addr.port());
Preconditions.checkNotNull(deviceId, ISNULL);
//Netconf configuration object
......@@ -375,7 +375,7 @@ public class NetconfDeviceProvider extends AbstractProvider
if (cfg != null) {
log.info("Checking connection to devices in configuration");
try {
cfg.getDevicesAddresses().stream().forEach(addr -> {
cfg.getDevicesAddresses().forEach(addr -> {
DeviceId deviceId = getDeviceId(addr.ip().toString(), addr.port());
Preconditions.checkNotNull(deviceId, ISNULL);
//Netconf configuration object
......
......@@ -212,7 +212,7 @@ public class RestDeviceProvider extends AbstractProvider
deviceAdded(device);
});
//Removing devices not wanted anymore
toBeRemoved.stream().forEach(device -> deviceRemoved(device.deviceId()));
toBeRemoved.forEach(device -> deviceRemoved(device.deviceId()));
}
} catch (ConfigException e) {
......
......@@ -137,7 +137,7 @@ public class SnmpDeviceProvider extends AbstractProvider
public void deactivate(ComponentContext context) {
try {
controller.getDevices().stream().forEach(device -> {
controller.getDevices().forEach(device -> {
deviceBuilderExecutor.execute(new DeviceFactory(device, false));
});
deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS);
......@@ -161,7 +161,7 @@ public class SnmpDeviceProvider extends AbstractProvider
SnmpProviderConfig cfg = netCfgService.getConfig(appId, SnmpProviderConfig.class);
if (cfg != null) {
try {
cfg.getDevicesInfo().stream().forEach(info -> {
cfg.getDevicesInfo().forEach(info -> {
SnmpDevice device = new DefaultSnmpDevice(info.ip().toString(),
info.port(), info.username(), info.password());
buildDevice(device);
......
......@@ -290,7 +290,7 @@ public class OnosSwaggerMojo extends AbstractMojo {
private void addJsonSchemaDefinition(ObjectNode definitions, DocletTag tag) {
File definitionsDirectory = new File(srcDirectory + "/src/main/resources/definitions");
if (tag != null) {
tag.getParameters().stream().forEach(param -> {
tag.getParameters().forEach(param -> {
try {
File config = new File(definitionsDirectory.getAbsolutePath() + "/"
+ param + ".json");
......@@ -340,7 +340,7 @@ public class OnosSwaggerMojo extends AbstractMojo {
responses.set("200", success);
if (tag != null && responseJson) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(
tag.getParameters().forEach(
param -> schema.put("$ref", "#/definitions/" + param));
success.set("schema", schema);
}
......@@ -403,7 +403,7 @@ public class OnosSwaggerMojo extends AbstractMojo {
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(param -> {
tag.getParameters().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
......