Search in sources :

Example 1 with DefaultOchSignalComparator

use of org.onosproject.net.DefaultOchSignalComparator in project onos by opennetworkinglab.

the class OpticalConnectivityIntentCompiler method findFirstLambda.

/**
 * Returns list of consecutive resources in given set of lambdas.
 *
 * @param lambdas list of lambdas
 * @param count   number of consecutive lambdas to return
 * @return list of consecutive lambdas
 */
private List<OchSignal> findFirstLambda(Set<OchSignal> lambdas, int count) {
    // Sort available lambdas
    List<OchSignal> lambdaList = new ArrayList<>(lambdas);
    lambdaList.sort(new DefaultOchSignalComparator());
    // Means there is only exactly one set of lambdas available
    if (lambdaList.size() == count) {
        return lambdaList;
    }
    // Look ahead by count and ensure spacing multiplier is as expected (i.e., no gaps)
    for (int i = 0; i < lambdaList.size() - count; i++) {
        if (lambdaList.get(i).spacingMultiplier() + 2 * count == lambdaList.get(i + count).spacingMultiplier()) {
            return lambdaList.subList(i, i + count);
        }
    }
    return Collections.emptyList();
}
Also used : DefaultOchSignalComparator(org.onosproject.net.DefaultOchSignalComparator) ArrayList(java.util.ArrayList) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ArrayList (java.util.ArrayList)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DefaultOchSignalComparator (org.onosproject.net.DefaultOchSignalComparator)1 OchSignal (org.onosproject.net.OchSignal)1