alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame] | 1 | /* |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.core.impl; |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.core.IdBlock; |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 19 | |
| 20 | public 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 | } |