blob: f0da9ab5c216ef2c6613720656a3e8c09b5de1d5 [file] [log] [blame]
Sithara Punnassery112ed822016-10-24 14:55:19 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Sithara Punnassery112ed822016-10-24 14:55:19 -07003 *
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 */
16package org.onosproject.store.primitives.impl;
17
18import org.onosproject.store.primitives.DistributedPrimitiveCreator;
19import org.onosproject.store.service.AsyncDocumentTree;
20import org.onosproject.store.service.DocumentTreeBuilder;
21
22/**
23 * Default {@link AsyncDocumentTree} builder.
24 *
25 * @param <V> type for document tree value
26 */
27public 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 HIGUCHI4fda7002017-10-16 15:26:47 -070037 return primitiveCreator.newAsyncDocumentTree(name(), serializer(), ordering());
Sithara Punnassery112ed822016-10-24 14:55:19 -070038 }
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 Halterman8d8da592017-08-28 14:45:19 -070050 AsyncDocumentTree<V> tree = primitiveCreator.newAsyncDocumentTree(name(), serializer(), ordering());
51 tree = relaxedReadConsistency() ? DistributedPrimitives.newCachingDocumentTree(tree) : tree;
52 return tree;
Sithara Punnassery112ed822016-10-24 14:55:19 -070053 }
54}