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