Committed by
Gerrit Code Review
Save memory consumption by avoding unnecessary instantiation
Change-Id: I7ce66c11136653fabc490aa7f33fdadf4454d2cc
Showing
18 changed files
with
73 additions
and
73 deletions
| ... | @@ -18,7 +18,7 @@ package org.onosproject.segmentrouting.grouphandler; | ... | @@ -18,7 +18,7 @@ package org.onosproject.segmentrouting.grouphandler; |
| 18 | import static org.slf4j.LoggerFactory.getLogger; | 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | 19 | ||
| 20 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
| 21 | -import java.util.Arrays; | 21 | +import java.util.Collections; |
| 22 | import java.util.HashMap; | 22 | import java.util.HashMap; |
| 23 | import java.util.Iterator; | 23 | import java.util.Iterator; |
| 24 | import java.util.List; | 24 | import java.util.List; |
| ... | @@ -95,8 +95,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -95,8 +95,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 95 | new GroupBucketIdentifier(label, sp); | 95 | new GroupBucketIdentifier(label, sp); |
| 96 | PolicyGroupIdentifier key = new | 96 | PolicyGroupIdentifier key = new |
| 97 | PolicyGroupIdentifier(id, | 97 | PolicyGroupIdentifier(id, |
| 98 | - Arrays.asList(param), | 98 | + Collections.singletonList(param), |
| 99 | - Arrays.asList(bucketId)); | 99 | + Collections.singletonList(bucketId)); |
| 100 | TrafficTreatment.Builder tBuilder = | 100 | TrafficTreatment.Builder tBuilder = |
| 101 | DefaultTrafficTreatment.builder(); | 101 | DefaultTrafficTreatment.builder(); |
| 102 | tBuilder.setOutput(sp) | 102 | tBuilder.setOutput(sp) |
| ... | @@ -122,8 +122,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -122,8 +122,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 122 | previousGroupkey); | 122 | previousGroupkey); |
| 123 | PolicyGroupIdentifier key = new | 123 | PolicyGroupIdentifier key = new |
| 124 | PolicyGroupIdentifier(id, | 124 | PolicyGroupIdentifier(id, |
| 125 | - Arrays.asList(param), | 125 | + Collections.singletonList(param), |
| 126 | - Arrays.asList(bucketId)); | 126 | + Collections.singletonList(bucketId)); |
| 127 | // Add to group dependency list | 127 | // Add to group dependency list |
| 128 | dependentGroups.put(previousGroupkey, key); | 128 | dependentGroups.put(previousGroupkey, key); |
| 129 | previousGroupkey = key; | 129 | previousGroupkey = key; |
| ... | @@ -283,8 +283,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -283,8 +283,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 283 | new GroupBucketIdentifier(label, sp); | 283 | new GroupBucketIdentifier(label, sp); |
| 284 | PolicyGroupIdentifier key = new | 284 | PolicyGroupIdentifier key = new |
| 285 | PolicyGroupIdentifier(id, | 285 | PolicyGroupIdentifier(id, |
| 286 | - Arrays.asList(param), | 286 | + Collections.singletonList(param), |
| 287 | - Arrays.asList(bucketId)); | 287 | + Collections.singletonList(bucketId)); |
| 288 | previousGroupkey = key; | 288 | previousGroupkey = key; |
| 289 | } else { | 289 | } else { |
| 290 | // Intermediate Groups | 290 | // Intermediate Groups |
| ... | @@ -293,8 +293,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -293,8 +293,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 293 | previousGroupkey); | 293 | previousGroupkey); |
| 294 | PolicyGroupIdentifier key = new | 294 | PolicyGroupIdentifier key = new |
| 295 | PolicyGroupIdentifier(id, | 295 | PolicyGroupIdentifier(id, |
| 296 | - Arrays.asList(param), | 296 | + Collections.singletonList(param), |
| 297 | - Arrays.asList(bucketId)); | 297 | + Collections.singletonList(bucketId)); |
| 298 | previousGroupkey = key; | 298 | previousGroupkey = key; |
| 299 | } | 299 | } |
| 300 | } | 300 | } |
| ... | @@ -348,4 +348,4 @@ public class PolicyGroupHandler extends DefaultGroupHandler { | ... | @@ -348,4 +348,4 @@ public class PolicyGroupHandler extends DefaultGroupHandler { |
| 348 | } | 348 | } |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 351 | +} | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
| 17 | 17 | ||
| 18 | import java.util.Arrays; | 18 | import java.util.Arrays; |
| 19 | +import java.util.Collections; | ||
| 19 | 20 | ||
| 20 | import org.junit.Test; | 21 | import org.junit.Test; |
| 21 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
| ... | @@ -93,7 +94,7 @@ public class PathIntentTest extends ConnectivityIntentTest { | ... | @@ -93,7 +94,7 @@ public class PathIntentTest extends ConnectivityIntentTest { |
| 93 | .appId(APPID) | 94 | .appId(APPID) |
| 94 | .selector(MATCH) | 95 | .selector(MATCH) |
| 95 | .treatment(NOP) | 96 | .treatment(NOP) |
| 96 | - .path(new DefaultPath(provider1, Arrays.asList(link1), cost)) | 97 | + .path(new DefaultPath(provider1, Collections.singletonList(link1), cost)) |
| 97 | .build(); | 98 | .build(); |
| 98 | } | 99 | } |
| 99 | 100 | ... | ... |
| ... | @@ -17,8 +17,8 @@ package org.onosproject.net.group.impl; | ... | @@ -17,8 +17,8 @@ package org.onosproject.net.group.impl; |
| 17 | 17 | ||
| 18 | import static org.slf4j.LoggerFactory.getLogger; | 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | 19 | ||
| 20 | -import java.util.Arrays; | ||
| 21 | import java.util.Collection; | 20 | import java.util.Collection; |
| 21 | +import java.util.Collections; | ||
| 22 | import java.util.Iterator; | 22 | import java.util.Iterator; |
| 23 | import java.util.Set; | 23 | import java.util.Set; |
| 24 | 24 | ||
| ... | @@ -261,7 +261,7 @@ public class GroupManager | ... | @@ -261,7 +261,7 @@ public class GroupManager |
| 261 | group.type(), | 261 | group.type(), |
| 262 | group.buckets()); | 262 | group.buckets()); |
| 263 | groupOps = new GroupOperations( | 263 | groupOps = new GroupOperations( |
| 264 | - Arrays.asList(groupAddOp)); | 264 | + Collections.singletonList(groupAddOp)); |
| 265 | groupProvider.performGroupOperation(group.deviceId(), groupOps); | 265 | groupProvider.performGroupOperation(group.deviceId(), groupOps); |
| 266 | break; | 266 | break; |
| 267 | 267 | ||
| ... | @@ -273,7 +273,7 @@ public class GroupManager | ... | @@ -273,7 +273,7 @@ public class GroupManager |
| 273 | group.type(), | 273 | group.type(), |
| 274 | group.buckets()); | 274 | group.buckets()); |
| 275 | groupOps = new GroupOperations( | 275 | groupOps = new GroupOperations( |
| 276 | - Arrays.asList(groupModifyOp)); | 276 | + Collections.singletonList(groupModifyOp)); |
| 277 | groupProvider.performGroupOperation(group.deviceId(), groupOps); | 277 | groupProvider.performGroupOperation(group.deviceId(), groupOps); |
| 278 | break; | 278 | break; |
| 279 | 279 | ||
| ... | @@ -284,7 +284,7 @@ public class GroupManager | ... | @@ -284,7 +284,7 @@ public class GroupManager |
| 284 | createDeleteGroupOperation(group.id(), | 284 | createDeleteGroupOperation(group.id(), |
| 285 | group.type()); | 285 | group.type()); |
| 286 | groupOps = new GroupOperations( | 286 | groupOps = new GroupOperations( |
| 287 | - Arrays.asList(groupDeleteOp)); | 287 | + Collections.singletonList(groupDeleteOp)); |
| 288 | groupProvider.performGroupOperation(group.deviceId(), groupOps); | 288 | groupProvider.performGroupOperation(group.deviceId(), groupOps); |
| 289 | break; | 289 | break; |
| 290 | 290 | ||
| ... | @@ -335,7 +335,7 @@ public class GroupManager | ... | @@ -335,7 +335,7 @@ public class GroupManager |
| 335 | group.type(), | 335 | group.type(), |
| 336 | group.buckets()); | 336 | group.buckets()); |
| 337 | GroupOperations groupOps = new GroupOperations( | 337 | GroupOperations groupOps = new GroupOperations( |
| 338 | - Arrays.asList(groupAddOp)); | 338 | + Collections.singletonList(groupAddOp)); |
| 339 | gp.performGroupOperation(group.deviceId(), groupOps); | 339 | gp.performGroupOperation(group.deviceId(), groupOps); |
| 340 | break; | 340 | break; |
| 341 | default: | 341 | default: | ... | ... |
| ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.LinkCollectionIntent; | ... | @@ -44,7 +44,7 @@ import org.onosproject.net.intent.LinkCollectionIntent; |
| 44 | import org.onosproject.net.resource.LinkResourceAllocations; | 44 | import org.onosproject.net.resource.LinkResourceAllocations; |
| 45 | 45 | ||
| 46 | import java.util.ArrayList; | 46 | import java.util.ArrayList; |
| 47 | -import java.util.Arrays; | 47 | +import java.util.Collections; |
| 48 | import java.util.List; | 48 | import java.util.List; |
| 49 | import java.util.Set; | 49 | import java.util.Set; |
| 50 | import java.util.stream.Collectors; | 50 | import java.util.stream.Collectors; |
| ... | @@ -104,7 +104,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti | ... | @@ -104,7 +104,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti |
| 104 | for (DeviceId deviceId: outputPorts.keys()) { | 104 | for (DeviceId deviceId: outputPorts.keys()) { |
| 105 | rules.addAll(createRules(intent, deviceId, inputPorts.get(deviceId), outputPorts.get(deviceId))); | 105 | rules.addAll(createRules(intent, deviceId, inputPorts.get(deviceId), outputPorts.get(deviceId))); |
| 106 | } | 106 | } |
| 107 | - return Arrays.asList(new FlowRuleIntent(appId, rules, intent.resources())); | 107 | + return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources())); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | private List<FlowRule> createRules(LinkCollectionIntent intent, DeviceId deviceId, | 110 | private List<FlowRule> createRules(LinkCollectionIntent intent, DeviceId deviceId, | ... | ... |
| ... | @@ -52,7 +52,7 @@ import org.onosproject.net.resource.ResourceAllocation; | ... | @@ -52,7 +52,7 @@ import org.onosproject.net.resource.ResourceAllocation; |
| 52 | import org.onosproject.net.resource.ResourceType; | 52 | import org.onosproject.net.resource.ResourceType; |
| 53 | import org.slf4j.Logger; | 53 | import org.slf4j.Logger; |
| 54 | 54 | ||
| 55 | -import java.util.Arrays; | 55 | +import java.util.Collections; |
| 56 | import java.util.Iterator; | 56 | import java.util.Iterator; |
| 57 | import java.util.LinkedList; | 57 | import java.util.LinkedList; |
| 58 | import java.util.List; | 58 | import java.util.List; |
| ... | @@ -86,7 +86,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -86,7 +86,7 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
| 86 | LinkResourceAllocations allocations = assignMplsLabel(intent); | 86 | LinkResourceAllocations allocations = assignMplsLabel(intent); |
| 87 | List<FlowRule> rules = generateRules(intent, allocations); | 87 | List<FlowRule> rules = generateRules(intent, allocations); |
| 88 | 88 | ||
| 89 | - return Arrays.asList(new FlowRuleIntent(appId, rules, intent.resources())); | 89 | + return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources())); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | @Activate | 92 | @Activate | ... | ... |
| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.intent.impl.compiler; | 16 | package org.onosproject.net.intent.impl.compiler; |
| 17 | 17 | ||
| 18 | -import java.util.Arrays; | 18 | +import java.util.Collections; |
| 19 | import java.util.HashMap; | 19 | import java.util.HashMap; |
| 20 | import java.util.List; | 20 | import java.util.List; |
| 21 | import java.util.Map; | 21 | import java.util.Map; |
| ... | @@ -110,7 +110,7 @@ public class MultiPointToSinglePointIntentCompiler | ... | @@ -110,7 +110,7 @@ public class MultiPointToSinglePointIntentCompiler |
| 110 | .constraints(intent.constraints()) | 110 | .constraints(intent.constraints()) |
| 111 | .build(); | 111 | .build(); |
| 112 | 112 | ||
| 113 | - return Arrays.asList(result); | 113 | + return Collections.singletonList(result); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | /** | 116 | /** | ... | ... |
| ... | @@ -46,7 +46,7 @@ import org.onosproject.net.resource.ResourceAllocation; | ... | @@ -46,7 +46,7 @@ import org.onosproject.net.resource.ResourceAllocation; |
| 46 | import org.onosproject.net.resource.ResourceType; | 46 | import org.onosproject.net.resource.ResourceType; |
| 47 | import org.onosproject.net.topology.TopologyService; | 47 | import org.onosproject.net.topology.TopologyService; |
| 48 | 48 | ||
| 49 | -import java.util.Arrays; | 49 | +import java.util.Collections; |
| 50 | import java.util.LinkedList; | 50 | import java.util.LinkedList; |
| 51 | import java.util.List; | 51 | import java.util.List; |
| 52 | import java.util.Set; | 52 | import java.util.Set; |
| ... | @@ -88,7 +88,8 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte | ... | @@ -88,7 +88,8 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte |
| 88 | Set<LinkResourceAllocations> resources) { | 88 | Set<LinkResourceAllocations> resources) { |
| 89 | LinkResourceAllocations allocations = assignWavelength(intent); | 89 | LinkResourceAllocations allocations = assignWavelength(intent); |
| 90 | 90 | ||
| 91 | - return Arrays.asList(new FlowRuleIntent(appId, createRules(intent, allocations), intent.resources())); | 91 | + return Collections.singletonList( |
| 92 | + new FlowRuleIntent(appId, createRules(intent, allocations), intent.resources())); | ||
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) { | 95 | private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) { | ... | ... |
| ... | @@ -38,7 +38,7 @@ import org.onosproject.net.intent.PathIntent; | ... | @@ -38,7 +38,7 @@ import org.onosproject.net.intent.PathIntent; |
| 38 | import org.onosproject.net.resource.LinkResourceAllocations; | 38 | import org.onosproject.net.resource.LinkResourceAllocations; |
| 39 | 39 | ||
| 40 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
| 41 | -import java.util.Arrays; | 41 | +import java.util.Collections; |
| 42 | import java.util.List; | 42 | import java.util.List; |
| 43 | import java.util.Set; | 43 | import java.util.Set; |
| 44 | 44 | ||
| ... | @@ -80,7 +80,7 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { | ... | @@ -80,7 +80,7 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { |
| 80 | rules.add(rule); | 80 | rules.add(rule); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | - return Arrays.asList(new FlowRuleIntent(appId, null, rules, intent.resources())); | 83 | + return Collections.singletonList(new FlowRuleIntent(appId, null, rules, intent.resources())); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | private FlowRule createFlowRule(TrafficSelector originalSelector, TrafficTreatment originalTreatment, | 86 | private FlowRule createFlowRule(TrafficSelector originalSelector, TrafficTreatment originalTreatment, | ... | ... |
| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.intent.impl.compiler; | 16 | package org.onosproject.net.intent.impl.compiler; |
| 17 | 17 | ||
| 18 | -import java.util.Arrays; | 18 | +import java.util.Collections; |
| 19 | import java.util.HashSet; | 19 | import java.util.HashSet; |
| 20 | import java.util.List; | 20 | import java.util.List; |
| 21 | import java.util.Set; | 21 | import java.util.Set; |
| ... | @@ -77,6 +77,6 @@ public class SinglePointToMultiPointIntentCompiler | ... | @@ -77,6 +77,6 @@ public class SinglePointToMultiPointIntentCompiler |
| 77 | .constraints(intent.constraints()) | 77 | .constraints(intent.constraints()) |
| 78 | .build(); | 78 | .build(); |
| 79 | 79 | ||
| 80 | - return Arrays.asList(result); | 80 | + return Collections.singletonList(result); |
| 81 | } | 81 | } |
| 82 | } | 82 | } | ... | ... |
| ... | @@ -63,7 +63,6 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -63,7 +63,6 @@ import org.onosproject.net.provider.ProviderId; |
| 63 | import org.onosproject.store.trivial.impl.SimpleFlowRuleStore; | 63 | import org.onosproject.store.trivial.impl.SimpleFlowRuleStore; |
| 64 | 64 | ||
| 65 | import java.util.ArrayList; | 65 | import java.util.ArrayList; |
| 66 | -import java.util.Arrays; | ||
| 67 | import java.util.Collections; | 66 | import java.util.Collections; |
| 68 | import java.util.HashMap; | 67 | import java.util.HashMap; |
| 69 | import java.util.List; | 68 | import java.util.List; |
| ... | @@ -412,7 +411,7 @@ public class FlowRuleManagerTest { | ... | @@ -412,7 +411,7 @@ public class FlowRuleManagerTest { |
| 412 | 411 | ||
| 413 | @Override | 412 | @Override |
| 414 | public Iterable<Device> getDevices() { | 413 | public Iterable<Device> getDevices() { |
| 415 | - return Arrays.asList(DEV); | 414 | + return Collections.singletonList(DEV); |
| 416 | } | 415 | } |
| 417 | 416 | ||
| 418 | @Override | 417 | @Override | ... | ... |
| ... | @@ -258,9 +258,9 @@ public class GroupManagerTest { | ... | @@ -258,9 +258,9 @@ public class GroupManagerTest { |
| 258 | DID, | 258 | DID, |
| 259 | Group.Type.SELECT, | 259 | Group.Type.SELECT, |
| 260 | createdGroup.buckets()); | 260 | createdGroup.buckets()); |
| 261 | - List<Group> groupEntries = Arrays.asList(createdGroup); | 261 | + List<Group> groupEntries = Collections.singletonList(createdGroup); |
| 262 | providerService.pushGroupMetrics(DID, groupEntries); | 262 | providerService.pushGroupMetrics(DID, groupEntries); |
| 263 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADDED)); | 263 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADDED)); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | // Test group add bucket operations | 266 | // Test group add bucket operations |
| ... | @@ -296,15 +296,15 @@ public class GroupManagerTest { | ... | @@ -296,15 +296,15 @@ public class GroupManagerTest { |
| 296 | addKey, | 296 | addKey, |
| 297 | appId); | 297 | appId); |
| 298 | GroupBuckets updatedBuckets = new GroupBuckets(buckets); | 298 | GroupBuckets updatedBuckets = new GroupBuckets(buckets); |
| 299 | - List<GroupOperation> expectedGroupOps = Arrays.asList( | 299 | + List<GroupOperation> expectedGroupOps = Collections.singletonList( |
| 300 | - GroupOperation.createModifyGroupOperation(createdGroup.id(), | 300 | + GroupOperation.createModifyGroupOperation(createdGroup.id(), |
| 301 | - Group.Type.SELECT, | 301 | + Group.Type.SELECT, |
| 302 | - updatedBuckets)); | 302 | + updatedBuckets)); |
| 303 | internalProvider.validate(DID, expectedGroupOps); | 303 | internalProvider.validate(DID, expectedGroupOps); |
| 304 | Group existingGroup = groupService.getGroup(DID, addKey); | 304 | Group existingGroup = groupService.getGroup(DID, addKey); |
| 305 | - List<Group> groupEntries = Arrays.asList(existingGroup); | 305 | + List<Group> groupEntries = Collections.singletonList(existingGroup); |
| 306 | providerService.pushGroupMetrics(DID, groupEntries); | 306 | providerService.pushGroupMetrics(DID, groupEntries); |
| 307 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED)); | 307 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED)); |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | // Test group remove bucket operations | 310 | // Test group remove bucket operations |
| ... | @@ -340,15 +340,15 @@ public class GroupManagerTest { | ... | @@ -340,15 +340,15 @@ public class GroupManagerTest { |
| 340 | removeKey, | 340 | removeKey, |
| 341 | appId); | 341 | appId); |
| 342 | GroupBuckets updatedBuckets = new GroupBuckets(buckets); | 342 | GroupBuckets updatedBuckets = new GroupBuckets(buckets); |
| 343 | - List<GroupOperation> expectedGroupOps = Arrays.asList( | 343 | + List<GroupOperation> expectedGroupOps = Collections.singletonList( |
| 344 | - GroupOperation.createModifyGroupOperation(createdGroup.id(), | 344 | + GroupOperation.createModifyGroupOperation(createdGroup.id(), |
| 345 | - Group.Type.SELECT, | 345 | + Group.Type.SELECT, |
| 346 | - updatedBuckets)); | 346 | + updatedBuckets)); |
| 347 | internalProvider.validate(DID, expectedGroupOps); | 347 | internalProvider.validate(DID, expectedGroupOps); |
| 348 | Group existingGroup = groupService.getGroup(DID, removeKey); | 348 | Group existingGroup = groupService.getGroup(DID, removeKey); |
| 349 | - List<Group> groupEntries = Arrays.asList(existingGroup); | 349 | + List<Group> groupEntries = Collections.singletonList(existingGroup); |
| 350 | providerService.pushGroupMetrics(DID, groupEntries); | 350 | providerService.pushGroupMetrics(DID, groupEntries); |
| 351 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED)); | 351 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED)); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | // Test group remove operations | 354 | // Test group remove operations |
| ... | @@ -356,13 +356,13 @@ public class GroupManagerTest { | ... | @@ -356,13 +356,13 @@ public class GroupManagerTest { |
| 356 | GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes()); | 356 | GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes()); |
| 357 | Group existingGroup = groupService.getGroup(DID, currKey); | 357 | Group existingGroup = groupService.getGroup(DID, currKey); |
| 358 | groupService.removeGroup(DID, currKey, appId); | 358 | groupService.removeGroup(DID, currKey, appId); |
| 359 | - List<GroupOperation> expectedGroupOps = Arrays.asList( | 359 | + List<GroupOperation> expectedGroupOps = Collections.singletonList( |
| 360 | - GroupOperation.createDeleteGroupOperation(existingGroup.id(), | 360 | + GroupOperation.createDeleteGroupOperation(existingGroup.id(), |
| 361 | - Group.Type.SELECT)); | 361 | + Group.Type.SELECT)); |
| 362 | internalProvider.validate(DID, expectedGroupOps); | 362 | internalProvider.validate(DID, expectedGroupOps); |
| 363 | List<Group> groupEntries = Collections.emptyList(); | 363 | List<Group> groupEntries = Collections.emptyList(); |
| 364 | providerService.pushGroupMetrics(DID, groupEntries); | 364 | providerService.pushGroupMetrics(DID, groupEntries); |
| 365 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVED)); | 365 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED)); |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | /** | 368 | /** |
| ... | @@ -423,7 +423,7 @@ public class GroupManagerTest { | ... | @@ -423,7 +423,7 @@ public class GroupManagerTest { |
| 423 | createdGroup.type(), | 423 | createdGroup.type(), |
| 424 | createdGroup.buckets()); | 424 | createdGroup.buckets()); |
| 425 | providerService.groupOperationFailed(DID, groupAddOp); | 425 | providerService.groupOperationFailed(DID, groupAddOp); |
| 426 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADD_FAILED)); | 426 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADD_FAILED)); |
| 427 | 427 | ||
| 428 | // Group Mod failure test | 428 | // Group Mod failure test |
| 429 | groupService.addGroup(newGroupDesc); | 429 | groupService.addGroup(newGroupDesc); |
| ... | @@ -435,7 +435,7 @@ public class GroupManagerTest { | ... | @@ -435,7 +435,7 @@ public class GroupManagerTest { |
| 435 | createdGroup.type(), | 435 | createdGroup.type(), |
| 436 | createdGroup.buckets()); | 436 | createdGroup.buckets()); |
| 437 | providerService.groupOperationFailed(DID, groupModOp); | 437 | providerService.groupOperationFailed(DID, groupModOp); |
| 438 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATE_FAILED)); | 438 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATE_FAILED)); |
| 439 | 439 | ||
| 440 | // Group Delete failure test | 440 | // Group Delete failure test |
| 441 | groupService.addGroup(newGroupDesc); | 441 | groupService.addGroup(newGroupDesc); |
| ... | @@ -446,7 +446,7 @@ public class GroupManagerTest { | ... | @@ -446,7 +446,7 @@ public class GroupManagerTest { |
| 446 | createDeleteGroupOperation(createdGroup.id(), | 446 | createDeleteGroupOperation(createdGroup.id(), |
| 447 | createdGroup.type()); | 447 | createdGroup.type()); |
| 448 | providerService.groupOperationFailed(DID, groupDelOp); | 448 | providerService.groupOperationFailed(DID, groupDelOp); |
| 449 | - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVE_FAILED)); | 449 | + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVE_FAILED)); |
| 450 | 450 | ||
| 451 | } | 451 | } |
| 452 | 452 | ... | ... |
| ... | @@ -46,7 +46,6 @@ import org.onosproject.net.intent.Key; | ... | @@ -46,7 +46,6 @@ import org.onosproject.net.intent.Key; |
| 46 | import org.onosproject.net.resource.LinkResourceAllocations; | 46 | import org.onosproject.net.resource.LinkResourceAllocations; |
| 47 | import org.onosproject.store.trivial.impl.SimpleIntentStore; | 47 | import org.onosproject.store.trivial.impl.SimpleIntentStore; |
| 48 | 48 | ||
| 49 | -import java.util.Arrays; | ||
| 50 | import java.util.Collection; | 49 | import java.util.Collection; |
| 51 | import java.util.Collections; | 50 | import java.util.Collections; |
| 52 | import java.util.List; | 51 | import java.util.List; |
| ... | @@ -151,7 +150,7 @@ public class IntentManagerTest { | ... | @@ -151,7 +150,7 @@ public class IntentManagerTest { |
| 151 | private static class MockInstallableIntent extends FlowRuleIntent { | 150 | private static class MockInstallableIntent extends FlowRuleIntent { |
| 152 | 151 | ||
| 153 | public MockInstallableIntent() { | 152 | public MockInstallableIntent() { |
| 154 | - super(APPID, Arrays.asList(new MockFlowRule(100))); | 153 | + super(APPID, Collections.singletonList(new MockFlowRule(100))); |
| 155 | } | 154 | } |
| 156 | } | 155 | } |
| 157 | 156 | ... | ... |
| ... | @@ -38,7 +38,7 @@ import org.onosproject.net.resource.BandwidthResource; | ... | @@ -38,7 +38,7 @@ import org.onosproject.net.resource.BandwidthResource; |
| 38 | import org.onosproject.net.resource.LambdaResource; | 38 | import org.onosproject.net.resource.LambdaResource; |
| 39 | import org.onosproject.net.resource.LinkResourceService; | 39 | import org.onosproject.net.resource.LinkResourceService; |
| 40 | 40 | ||
| 41 | -import java.util.Arrays; | 41 | +import java.util.Collections; |
| 42 | import java.util.List; | 42 | import java.util.List; |
| 43 | 43 | ||
| 44 | import static org.hamcrest.CoreMatchers.instanceOf; | 44 | import static org.hamcrest.CoreMatchers.instanceOf; |
| ... | @@ -228,8 +228,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -228,8 +228,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
| 228 | 228 | ||
| 229 | final LinkResourceService resourceService = | 229 | final LinkResourceService resourceService = |
| 230 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0); | 230 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0); |
| 231 | - final List<Constraint> constraints = Arrays.asList( | 231 | + final List<Constraint> constraints = |
| 232 | - new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); | 232 | + Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); |
| 233 | 233 | ||
| 234 | final PointToPointIntent intent = makeIntent("s1", "s3", constraints); | 234 | final PointToPointIntent intent = makeIntent("s1", "s3", constraints); |
| 235 | 235 | ||
| ... | @@ -250,8 +250,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -250,8 +250,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
| 250 | 250 | ||
| 251 | final LinkResourceService resourceService = | 251 | final LinkResourceService resourceService = |
| 252 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); | 252 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); |
| 253 | - final List<Constraint> constraints = Arrays.asList( | 253 | + final List<Constraint> constraints = |
| 254 | - new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); | 254 | + Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); |
| 255 | 255 | ||
| 256 | try { | 256 | try { |
| 257 | final PointToPointIntent intent = makeIntent("s1", "s3", constraints); | 257 | final PointToPointIntent intent = makeIntent("s1", "s3", constraints); |
| ... | @@ -274,7 +274,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -274,7 +274,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
| 274 | @Test | 274 | @Test |
| 275 | public void testLambdaConstrainedIntentSuccess() { | 275 | public void testLambdaConstrainedIntentSuccess() { |
| 276 | 276 | ||
| 277 | - final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1))); | 277 | + final List<Constraint> constraints = |
| 278 | + Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); | ||
| 278 | final LinkResourceService resourceService = | 279 | final LinkResourceService resourceService = |
| 279 | IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); | 280 | IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); |
| 280 | 281 | ||
| ... | @@ -297,7 +298,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { | ... | @@ -297,7 +298,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { |
| 297 | @Test | 298 | @Test |
| 298 | public void testLambdaConstrainedIntentFailure() { | 299 | public void testLambdaConstrainedIntentFailure() { |
| 299 | 300 | ||
| 300 | - final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1))); | 301 | + final List<Constraint> constraints = |
| 302 | + Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); | ||
| 301 | final LinkResourceService resourceService = | 303 | final LinkResourceService resourceService = |
| 302 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); | 304 | IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); |
| 303 | try { | 305 | try { | ... | ... |
| ... | @@ -40,7 +40,7 @@ import org.onosproject.net.intent.impl.IntentProcessor; | ... | @@ -40,7 +40,7 @@ import org.onosproject.net.intent.impl.IntentProcessor; |
| 40 | import org.onosproject.net.provider.ProviderId; | 40 | import org.onosproject.net.provider.ProviderId; |
| 41 | import org.onosproject.store.Timestamp; | 41 | import org.onosproject.store.Timestamp; |
| 42 | 42 | ||
| 43 | -import java.util.Arrays; | 43 | +import java.util.Collections; |
| 44 | import java.util.List; | 44 | import java.util.List; |
| 45 | import java.util.Optional; | 45 | import java.util.Optional; |
| 46 | 46 | ||
| ... | @@ -70,7 +70,7 @@ public class CompilingTest { | ... | @@ -70,7 +70,7 @@ public class CompilingTest { |
| 70 | private final ConnectPoint cp3 = new ConnectPoint(deviceId("2"), portNumber(1)); | 70 | private final ConnectPoint cp3 = new ConnectPoint(deviceId("2"), portNumber(1)); |
| 71 | private final ConnectPoint cp4 = new ConnectPoint(deviceId("2"), portNumber(2)); | 71 | private final ConnectPoint cp4 = new ConnectPoint(deviceId("2"), portNumber(2)); |
| 72 | 72 | ||
| 73 | - private final List<Link> links = Arrays.asList(new DefaultLink(pid, cp2, cp4, DIRECT)); | 73 | + private final List<Link> links = Collections.singletonList(new DefaultLink(pid, cp2, cp4, DIRECT)); |
| 74 | private final Path path = new DefaultPath(pid, links, 10); | 74 | private final Path path = new DefaultPath(pid, links, 10); |
| 75 | 75 | ||
| 76 | private PointToPointIntent input; | 76 | private PointToPointIntent input; |
| ... | @@ -118,7 +118,7 @@ public class CompilingTest { | ... | @@ -118,7 +118,7 @@ public class CompilingTest { |
| 118 | public void testMoveToNextPhaseWithoutError() { | 118 | public void testMoveToNextPhaseWithoutError() { |
| 119 | IntentData pending = new IntentData(input, INSTALL_REQ, version); | 119 | IntentData pending = new IntentData(input, INSTALL_REQ, version); |
| 120 | 120 | ||
| 121 | - expect(processor.compile(input, null)).andReturn(Arrays.asList(compiled)); | 121 | + expect(processor.compile(input, null)).andReturn(Collections.singletonList(compiled)); |
| 122 | replay(processor); | 122 | replay(processor); |
| 123 | 123 | ||
| 124 | Compiling sut = new Compiling(processor, pending, Optional.empty()); | 124 | Compiling sut = new Compiling(processor, pending, Optional.empty()); | ... | ... |
| ... | @@ -78,7 +78,6 @@ import org.osgi.service.component.ComponentContext; | ... | @@ -78,7 +78,6 @@ import org.osgi.service.component.ComponentContext; |
| 78 | import org.slf4j.Logger; | 78 | import org.slf4j.Logger; |
| 79 | 79 | ||
| 80 | import java.util.ArrayList; | 80 | import java.util.ArrayList; |
| 81 | -import java.util.Arrays; | ||
| 82 | import java.util.Collections; | 81 | import java.util.Collections; |
| 83 | import java.util.Dictionary; | 82 | import java.util.Dictionary; |
| 84 | import java.util.HashSet; | 83 | import java.util.HashSet; |
| ... | @@ -388,7 +387,7 @@ public class DistributedFlowRuleStore | ... | @@ -388,7 +387,7 @@ public class DistributedFlowRuleStore |
| 388 | @Override | 387 | @Override |
| 389 | public void storeFlowRule(FlowRule rule) { | 388 | public void storeFlowRule(FlowRule rule) { |
| 390 | storeBatch(new FlowRuleBatchOperation( | 389 | storeBatch(new FlowRuleBatchOperation( |
| 391 | - Arrays.asList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), | 390 | + Collections.singletonList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), |
| 392 | rule.deviceId(), idGenerator.getNewId())); | 391 | rule.deviceId(), idGenerator.getNewId())); |
| 393 | } | 392 | } |
| 394 | 393 | ||
| ... | @@ -516,7 +515,7 @@ public class DistributedFlowRuleStore | ... | @@ -516,7 +515,7 @@ public class DistributedFlowRuleStore |
| 516 | public void deleteFlowRule(FlowRule rule) { | 515 | public void deleteFlowRule(FlowRule rule) { |
| 517 | storeBatch( | 516 | storeBatch( |
| 518 | new FlowRuleBatchOperation( | 517 | new FlowRuleBatchOperation( |
| 519 | - Arrays.asList( | 518 | + Collections.singletonList( |
| 520 | new FlowRuleBatchEntry( | 519 | new FlowRuleBatchEntry( |
| 521 | FlowRuleOperation.REMOVE, | 520 | FlowRuleOperation.REMOVE, |
| 522 | rule)), rule.deviceId(), idGenerator.getNewId())); | 521 | rule)), rule.deviceId(), idGenerator.getNewId())); | ... | ... |
| ... | @@ -71,7 +71,6 @@ import org.onosproject.store.serializers.impl.DistributedStoreSerializers; | ... | @@ -71,7 +71,6 @@ import org.onosproject.store.serializers.impl.DistributedStoreSerializers; |
| 71 | import org.osgi.service.component.ComponentContext; | 71 | import org.osgi.service.component.ComponentContext; |
| 72 | import org.slf4j.Logger; | 72 | import org.slf4j.Logger; |
| 73 | 73 | ||
| 74 | -import java.util.Arrays; | ||
| 75 | import java.util.Collections; | 74 | import java.util.Collections; |
| 76 | import java.util.Dictionary; | 75 | import java.util.Dictionary; |
| 77 | import java.util.HashSet; | 76 | import java.util.HashSet; |
| ... | @@ -378,7 +377,7 @@ public class NewDistributedFlowRuleStore | ... | @@ -378,7 +377,7 @@ public class NewDistributedFlowRuleStore |
| 378 | @Override | 377 | @Override |
| 379 | public void storeFlowRule(FlowRule rule) { | 378 | public void storeFlowRule(FlowRule rule) { |
| 380 | storeBatch(new FlowRuleBatchOperation( | 379 | storeBatch(new FlowRuleBatchOperation( |
| 381 | - Arrays.asList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), | 380 | + Collections.singletonList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), |
| 382 | rule.deviceId(), idGenerator.getNewId())); | 381 | rule.deviceId(), idGenerator.getNewId())); |
| 383 | } | 382 | } |
| 384 | 383 | ||
| ... | @@ -484,7 +483,7 @@ public class NewDistributedFlowRuleStore | ... | @@ -484,7 +483,7 @@ public class NewDistributedFlowRuleStore |
| 484 | public void deleteFlowRule(FlowRule rule) { | 483 | public void deleteFlowRule(FlowRule rule) { |
| 485 | storeBatch( | 484 | storeBatch( |
| 486 | new FlowRuleBatchOperation( | 485 | new FlowRuleBatchOperation( |
| 487 | - Arrays.asList( | 486 | + Collections.singletonList( |
| 488 | new FlowRuleBatchEntry( | 487 | new FlowRuleBatchEntry( |
| 489 | FlowRuleOperation.REMOVE, | 488 | FlowRuleOperation.REMOVE, |
| 490 | rule)), rule.deviceId(), idGenerator.getNewId())); | 489 | rule)), rule.deviceId(), idGenerator.getNewId())); | ... | ... |
| ... | @@ -20,6 +20,7 @@ import static org.onosproject.net.DeviceId.deviceId; | ... | @@ -20,6 +20,7 @@ import static org.onosproject.net.DeviceId.deviceId; |
| 20 | 20 | ||
| 21 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
| 22 | import java.util.Arrays; | 22 | import java.util.Arrays; |
| 23 | +import java.util.Collections; | ||
| 23 | import java.util.List; | 24 | import java.util.List; |
| 24 | import java.util.Optional; | 25 | import java.util.Optional; |
| 25 | 26 | ||
| ... | @@ -307,7 +308,7 @@ public class SimpleGroupStoreTest { | ... | @@ -307,7 +308,7 @@ public class SimpleGroupStoreTest { |
| 307 | PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), | 308 | PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), |
| 308 | PortNumber.portNumber(42)}; | 309 | PortNumber.portNumber(42)}; |
| 309 | List<PortNumber> newOutPorts = new ArrayList<PortNumber>(); | 310 | List<PortNumber> newOutPorts = new ArrayList<PortNumber>(); |
| 310 | - newOutPorts.addAll(Arrays.asList(newNeighborPorts[0])); | 311 | + newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); |
| 311 | 312 | ||
| 312 | List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>(); | 313 | List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>(); |
| 313 | for (PortNumber portNumber: newOutPorts) { | 314 | for (PortNumber portNumber: newOutPorts) { | ... | ... |
| ... | @@ -73,7 +73,6 @@ import org.onosproject.net.group.GroupService; | ... | @@ -73,7 +73,6 @@ import org.onosproject.net.group.GroupService; |
| 73 | import org.slf4j.Logger; | 73 | import org.slf4j.Logger; |
| 74 | 74 | ||
| 75 | import java.util.ArrayList; | 75 | import java.util.ArrayList; |
| 76 | -import java.util.Arrays; | ||
| 77 | import java.util.Collection; | 76 | import java.util.Collection; |
| 78 | import java.util.Collections; | 77 | import java.util.Collections; |
| 79 | import java.util.List; | 78 | import java.util.List; |
| ... | @@ -313,7 +312,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour | ... | @@ -313,7 +312,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour |
| 313 | log.warn("Unsupported Group type {}", group.type()); | 312 | log.warn("Unsupported Group type {}", group.type()); |
| 314 | return; | 313 | return; |
| 315 | } | 314 | } |
| 316 | - GroupBuckets bucketsToAdd = new GroupBuckets(Arrays.asList(bucket)); | 315 | + GroupBuckets bucketsToAdd = new GroupBuckets(Collections.singletonList(bucket)); |
| 317 | groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId); | 316 | groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId); |
| 318 | } | 317 | } |
| 319 | 318 | ||
| ... | @@ -339,7 +338,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour | ... | @@ -339,7 +338,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour |
| 339 | log.warn("Unsupported Group type {}", group.type()); | 338 | log.warn("Unsupported Group type {}", group.type()); |
| 340 | return; | 339 | return; |
| 341 | } | 340 | } |
| 342 | - GroupBuckets removeBuckets = new GroupBuckets(Arrays.asList(bucket)); | 341 | + GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket)); |
| 343 | groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId); | 342 | groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId); |
| 344 | } | 343 | } |
| 345 | } | 344 | } | ... | ... |
-
Please register or login to post a comment