blob: 3872b976c30a489b9208d8d18417ff946ff8147e [file] [log] [blame]
Brian O'Connorabafb502014-12-02 22:26:20 -08001package org.onosproject.core.impl;
Brian O'Connor520c0522014-11-23 23:50:47 -08002
Brian O'Connorabafb502014-12-02 22:26:20 -08003import org.onosproject.core.IdBlock;
Brian O'Connor520c0522014-11-23 23:50:47 -08004
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}