Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 1 | package org.onlab.onos.core.impl; |
| 2 | |
| 3 | import org.onlab.onos.core.IdBlock; |
| 4 | |
| 5 | public class DummyIdBlockAllocator implements IdBlockAllocator { |
| 6 | private long blockTop; |
| 7 | private static final long BLOCK_SIZE = 0x1000000L; |
| 8 | |
| 9 | /** |
| 10 | * Returns a block of IDs which are unique and unused. |
| 11 | * Range of IDs is fixed size and is assigned incrementally as this method |
| 12 | * called. |
| 13 | * |
| 14 | * @return an IdBlock containing a set of unique IDs |
| 15 | */ |
| 16 | @Override |
| 17 | public IdBlock allocateUniqueIdBlock() { |
| 18 | synchronized (this) { |
| 19 | long blockHead = blockTop; |
| 20 | long blockTail = blockTop + BLOCK_SIZE; |
| 21 | |
| 22 | IdBlock block = new IdBlock(blockHead, BLOCK_SIZE); |
| 23 | blockTop = blockTail; |
| 24 | |
| 25 | return block; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public IdBlock allocateUniqueIdBlock(long range) { |
| 31 | throw new UnsupportedOperationException("Not supported yet"); |
| 32 | } |
| 33 | } |