Sho SHIMIZU
Committed by Gerrit Code Review

Refactor: Rearrange method definition order

Change-Id: I86d853a0066b0ac42508091f5b76042c3e8cabfa
...@@ -270,32 +270,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu ...@@ -270,32 +270,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu
270 } 270 }
271 271
272 /** 272 /**
273 - * Checks if current allocations on given resource can satisfy request.
274 - * If the resource is null, return true.
275 - *
276 - * @param resource the resource on which to map the intent
277 - * @return true if the resource can accept the request, false otherwise
278 - */
279 - private boolean isAvailable(IntentId resource) {
280 - if (resource == null) {
281 - return true;
282 - }
283 -
284 - Set<IntentId> mapping = intentSetMultimap.getMapping(resource);
285 -
286 - if (mapping == null) {
287 - return true;
288 - }
289 -
290 - return mapping.size() < maxCapacity;
291 - }
292 -
293 - private boolean isAllowed(ConnectPoint circuitCp, ConnectPoint connectivityCp) {
294 - ConnectPoint staticPort = staticPort(circuitCp);
295 - return staticPort == null || staticPort.equals(connectivityCp);
296 - }
297 -
298 - /**
299 * Returns existing and available optical connectivity intent that matches the given circuit intent. 273 * Returns existing and available optical connectivity intent that matches the given circuit intent.
300 * 274 *
301 * @param src source connect point of optical circuit intent 275 * @param src source connect point of optical circuit intent
...@@ -325,6 +299,32 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu ...@@ -325,6 +299,32 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu
325 .orElse(null); 299 .orElse(null);
326 } 300 }
327 301
302 + private boolean isAllowed(ConnectPoint circuitCp, ConnectPoint connectivityCp) {
303 + ConnectPoint staticPort = staticPort(circuitCp);
304 + return staticPort == null || staticPort.equals(connectivityCp);
305 + }
306 +
307 + /**
308 + * Checks if current allocations on given resource can satisfy request.
309 + * If the resource is null, return true.
310 + *
311 + * @param resource the resource on which to map the intent
312 + * @return true if the resource can accept the request, false otherwise
313 + */
314 + private boolean isAvailable(IntentId resource) {
315 + if (resource == null) {
316 + return true;
317 + }
318 +
319 + Set<IntentId> mapping = intentSetMultimap.getMapping(resource);
320 +
321 + if (mapping == null) {
322 + return true;
323 + }
324 +
325 + return mapping.size() < maxCapacity;
326 + }
327 +
328 private boolean isAvailableTributarySlots(ConnectPoint src, ConnectPoint dst, int requestedTsNum) { 328 private boolean isAvailableTributarySlots(ConnectPoint src, ConnectPoint dst, int requestedTsNum) {
329 Set<TributarySlot> common = findCommonTributarySlotsOnCps(src, dst); 329 Set<TributarySlot> common = findCommonTributarySlotsOnCps(src, dst);
330 if (common.isEmpty()) { 330 if (common.isEmpty()) {
...@@ -388,6 +388,29 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu ...@@ -388,6 +388,29 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu
388 return null; 388 return null;
389 } 389 }
390 390
391 + private Pair<OchPort, OchPort> findPorts(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
392 + // According to the OpticalCircuitIntent's signalType find OCH ports with available TributarySlots resources
393 + switch (signalType) {
394 + case CLT_1GBE:
395 + case CLT_10GBE:
396 + // First search for OCH ports with OduSignalType of ODU2. If not found - search for those with ODU4
397 + return findPorts(src, dst, OduSignalType.ODU2)
398 + .orElse(findPorts(src, dst, OduSignalType.ODU4).orElse(null));
399 + case CLT_100GBE:
400 + return findPorts(src, dst, OduSignalType.ODU4).orElse(null);
401 + case CLT_40GBE:
402 + default:
403 + return null;
404 + }
405 + }
406 +
407 + private Optional<Pair<OchPort, OchPort>> findPorts(ConnectPoint src, ConnectPoint dst,
408 + OduSignalType ochPortSignalType) {
409 + return findAvailableOchPort(src, ochPortSignalType)
410 + .flatMap(srcOch ->
411 + findAvailableOchPort(dst, ochPortSignalType).map(dstOch -> Pair.of(srcOch, dstOch)));
412 + }
413 +
391 private Optional<OchPort> findAvailableOchPort(ConnectPoint oduPort, OduSignalType ochPortSignalType) { 414 private Optional<OchPort> findAvailableOchPort(ConnectPoint oduPort, OduSignalType ochPortSignalType) {
392 // First see if the port mappings are constrained 415 // First see if the port mappings are constrained
393 ConnectPoint ochCP = staticPort(oduPort); 416 ConnectPoint ochCP = staticPort(oduPort);
...@@ -440,29 +463,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu ...@@ -440,29 +463,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu
440 return Optional.empty(); 463 return Optional.empty();
441 } 464 }
442 465
443 - private Pair<OchPort, OchPort> findPorts(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
444 - // According to the OpticalCircuitIntent's signalType find OCH ports with available TributarySlots resources
445 - switch (signalType) {
446 - case CLT_1GBE:
447 - case CLT_10GBE:
448 - // First search for OCH ports with OduSignalType of ODU2. If not found - search for those with ODU4
449 - return findPorts(src, dst, OduSignalType.ODU2)
450 - .orElse(findPorts(src, dst, OduSignalType.ODU4).orElse(null));
451 - case CLT_100GBE:
452 - return findPorts(src, dst, OduSignalType.ODU4).orElse(null);
453 - case CLT_40GBE:
454 - default:
455 - return null;
456 - }
457 - }
458 -
459 - private Optional<Pair<OchPort, OchPort>> findPorts(ConnectPoint src, ConnectPoint dst,
460 - OduSignalType ochPortSignalType) {
461 - return findAvailableOchPort(src, ochPortSignalType)
462 - .flatMap(srcOch ->
463 - findAvailableOchPort(dst, ochPortSignalType).map(dstOch -> Pair.of(srcOch, dstOch)));
464 - }
465 -
466 /** 466 /**
467 * Builds flow rule for mapping between two ports. 467 * Builds flow rule for mapping between two ports.
468 * 468 *
......