blob: 383e981a9c0fa903a346a780b876e4bdc721e0b8 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
2 * Copyright 2014 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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.core.impl;
Brian O'Connor520c0522014-11-23 23:50:47 -080017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.core.IdBlock;
Brian O'Connor520c0522014-11-23 23:50:47 -080019
20public class DummyIdBlockAllocator implements IdBlockAllocator {
21 private long blockTop;
22 private static final long BLOCK_SIZE = 0x1000000L;
23
24 /**
25 * Returns a block of IDs which are unique and unused.
26 * Range of IDs is fixed size and is assigned incrementally as this method
27 * called.
28 *
29 * @return an IdBlock containing a set of unique IDs
30 */
31 @Override
32 public IdBlock allocateUniqueIdBlock() {
33 synchronized (this) {
34 long blockHead = blockTop;
35 long blockTail = blockTop + BLOCK_SIZE;
36
37 IdBlock block = new IdBlock(blockHead, BLOCK_SIZE);
38 blockTop = blockTail;
39
40 return block;
41 }
42 }
43
44 @Override
45 public IdBlock allocateUniqueIdBlock(long range) {
46 throw new UnsupportedOperationException("Not supported yet");
47 }
48}