blob: d4c0e642798614f33d2e66ff8465aeb7f26d5ae6 [file] [log] [blame]
Brian O'Connor520c0522014-11-23 23:50:47 -08001package org.onlab.onos.core.impl;
2
3import org.onlab.onos.core.IdBlock;
4
5public 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}