Committed by
Gerrit Code Review
[ONOS-3831,ONOS-3836] Load balance algorithm for sfc
Change-Id: I48a428587420ce6d782c128b835b5bb90e0cacfe
Showing
5 changed files
with
20 additions
and
57 deletions
apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/NshSpiIdGenerators.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.sfc.manager; | ||
| 17 | - | ||
| 18 | -import java.util.concurrent.atomic.AtomicInteger; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * Unique NSH SPI Id generator for NSH header. | ||
| 22 | - */ | ||
| 23 | -public final class NshSpiIdGenerators { | ||
| 24 | - | ||
| 25 | - private static final AtomicInteger NSH_SPI_ID_GEN = new AtomicInteger(); | ||
| 26 | - private static final int MAX_NSH_SPI_ID = 0x7FFFFFFF; | ||
| 27 | - private static int nshSpiId; | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * Default constructor. | ||
| 31 | - */ | ||
| 32 | - private NshSpiIdGenerators() { | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * Get the next NSH SPI id. | ||
| 37 | - * | ||
| 38 | - * @return NSH SPI id | ||
| 39 | - */ | ||
| 40 | - public static int create() { | ||
| 41 | - do { | ||
| 42 | - if (nshSpiId >= MAX_NSH_SPI_ID) { | ||
| 43 | - if (NSH_SPI_ID_GEN.get() >= MAX_NSH_SPI_ID) { | ||
| 44 | - NSH_SPI_ID_GEN.set(0); | ||
| 45 | - } | ||
| 46 | - } | ||
| 47 | - nshSpiId = NSH_SPI_ID_GEN.incrementAndGet(); | ||
| 48 | - } while (nshSpiId > MAX_NSH_SPI_ID); | ||
| 49 | - return nshSpiId; | ||
| 50 | - } | ||
| 51 | -} |
This diff is collapsed. Click to expand it.
| ... | @@ -142,6 +142,14 @@ public final class DefaultPortChain implements PortChain { | ... | @@ -142,6 +142,14 @@ public final class DefaultPortChain implements PortChain { |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | @Override | 144 | @Override |
| 145 | + public int getLoadBalancePathSize() { | ||
| 146 | + if (sfcLoadBalanceIdMap.isEmpty()) { | ||
| 147 | + return 0; | ||
| 148 | + } | ||
| 149 | + return sfcLoadBalanceIdMap.size(); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + @Override | ||
| 145 | public Optional<LoadBalanceId> matchPath(List<PortPairId> path) { | 153 | public Optional<LoadBalanceId> matchPath(List<PortPairId> path) { |
| 146 | 154 | ||
| 147 | LoadBalanceId id = null; | 155 | LoadBalanceId id = null; | ... | ... |
| ... | @@ -113,6 +113,13 @@ public interface PortChain { | ... | @@ -113,6 +113,13 @@ public interface PortChain { |
| 113 | List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple); | 113 | List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple); |
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| 116 | + * Get the no of load balance paths created. | ||
| 117 | + * | ||
| 118 | + * @return size of load balanced paths | ||
| 119 | + */ | ||
| 120 | + int getLoadBalancePathSize(); | ||
| 121 | + | ||
| 122 | + /** | ||
| 116 | * Match the given path with existing load balanced paths. | 123 | * Match the given path with existing load balanced paths. |
| 117 | * | 124 | * |
| 118 | * @param path load balanced path | 125 | * @param path load balanced path | ... | ... |
| ... | @@ -142,38 +142,37 @@ public class PortChainResourceTest extends VtnResourceTest { | ... | @@ -142,38 +142,37 @@ public class PortChainResourceTest extends VtnResourceTest { |
| 142 | 142 | ||
| 143 | @Override | 143 | @Override |
| 144 | public void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id, List<PortPairId> path) { | 144 | public void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id, List<PortPairId> path) { |
| 145 | - // TODO Auto-generated method stub | ||
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | @Override | 147 | @Override |
| 149 | public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) { | 148 | public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) { |
| 150 | - // TODO Auto-generated method stub | ||
| 151 | return null; | 149 | return null; |
| 152 | } | 150 | } |
| 153 | 151 | ||
| 154 | @Override | 152 | @Override |
| 155 | public Set<FiveTuple> getLoadBalanceIdMapKeys() { | 153 | public Set<FiveTuple> getLoadBalanceIdMapKeys() { |
| 156 | - // TODO Auto-generated method stub | ||
| 157 | return null; | 154 | return null; |
| 158 | } | 155 | } |
| 159 | 156 | ||
| 160 | @Override | 157 | @Override |
| 161 | public List<PortPairId> getLoadBalancePath(LoadBalanceId id) { | 158 | public List<PortPairId> getLoadBalancePath(LoadBalanceId id) { |
| 162 | - // TODO Auto-generated method stub | ||
| 163 | return null; | 159 | return null; |
| 164 | } | 160 | } |
| 165 | 161 | ||
| 166 | @Override | 162 | @Override |
| 167 | public List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple) { | 163 | public List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple) { |
| 168 | - // TODO Auto-generated method stub | ||
| 169 | return null; | 164 | return null; |
| 170 | } | 165 | } |
| 171 | 166 | ||
| 172 | @Override | 167 | @Override |
| 173 | public Optional<LoadBalanceId> matchPath(List<PortPairId> path) { | 168 | public Optional<LoadBalanceId> matchPath(List<PortPairId> path) { |
| 174 | - // TODO Auto-generated method stub | ||
| 175 | return null; | 169 | return null; |
| 176 | } | 170 | } |
| 171 | + | ||
| 172 | + @Override | ||
| 173 | + public int getLoadBalancePathSize() { | ||
| 174 | + return 0; | ||
| 175 | + } | ||
| 177 | } | 176 | } |
| 178 | 177 | ||
| 179 | /** | 178 | /** | ... | ... |
-
Please register or login to post a comment