Sithara Punnassery | 112ed82 | 2016-10-24 14:55:19 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sithara Punnassery | 112ed82 | 2016-10-24 14:55:19 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.store.primitives.impl; |
| 17 | |
| 18 | import org.onosproject.store.primitives.DistributedPrimitiveCreator; |
| 19 | import org.onosproject.store.service.AsyncDocumentTree; |
| 20 | import org.onosproject.store.service.DocumentTreeBuilder; |
| 21 | |
| 22 | /** |
| 23 | * Default {@link AsyncDocumentTree} builder. |
| 24 | * |
| 25 | * @param <V> type for document tree value |
| 26 | */ |
| 27 | public class DefaultDocumentTreeBuilder<V> extends DocumentTreeBuilder<V> { |
| 28 | |
| 29 | private final DistributedPrimitiveCreator primitiveCreator; |
| 30 | |
| 31 | public DefaultDocumentTreeBuilder(DistributedPrimitiveCreator primitiveCreator) { |
| 32 | this.primitiveCreator = primitiveCreator; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public AsyncDocumentTree<V> buildDocumentTree() { |
Yuta HIGUCHI | 4fda700 | 2017-10-16 15:26:47 -0700 | [diff] [blame] | 37 | return primitiveCreator.newAsyncDocumentTree(name(), serializer(), ordering()); |
Sithara Punnassery | 112ed82 | 2016-10-24 14:55:19 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | //TODO |
| 41 | /* |
| 42 | public ConsistentDocumentTree<V> build() { |
| 43 | return buildDocumentTree().asDocumentTree(); |
| 44 | } |
| 45 | }*/ |
| 46 | //writing a dummy implementation till we have ConsistentDocumentTree. |
| 47 | @Deprecated |
| 48 | @Override |
| 49 | public AsyncDocumentTree<V> build() { |
Jordan Halterman | 8d8da59 | 2017-08-28 14:45:19 -0700 | [diff] [blame] | 50 | AsyncDocumentTree<V> tree = primitiveCreator.newAsyncDocumentTree(name(), serializer(), ordering()); |
| 51 | tree = relaxedReadConsistency() ? DistributedPrimitives.newCachingDocumentTree(tree) : tree; |
| 52 | return tree; |
Sithara Punnassery | 112ed82 | 2016-10-24 14:55:19 -0700 | [diff] [blame] | 53 | } |
| 54 | } |